linux:system:ssd
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| linux:system:ssd [2022/01/15 11:38] – created - external edit 127.0.0.1 | linux:system:ssd [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== SSD Optimization ====== | ||
| - | ===== Kernel SSD Awareness ===== | ||
| - | To check if the kernel knows about SSDs try: | ||
| - | < | ||
| - | # for f in / | ||
| - | / | ||
| - | / | ||
| - | / | ||
| - | </ | ||
| - | ===== Partitions and Alignment ===== | ||
| - | Since Debian Wheezy, all tools should automatically align filesystems and partitions to the 4096 byte page size. This is one of the most important optimization aspects. | ||
| - | Alignment can be checked with the Parted command, which has an align-check build in. | ||
| - | < | ||
| - | # parted / | ||
| - | align-check opt n (n is the partition you want to check) | ||
| - | </ | ||
| - | |||
| - | ===== Mounting SSD Filesystems ===== | ||
| - | relatime is a default mount option and is much better than atime. The former requires a write for the first read after a write, the latter requires a write for every read. But with noatime each read is free of a write. Therefore add **noatime, nodiratime** to the mount options. | ||
| - | |||
| - | < | ||
| - | # nano /etc/fstab | ||
| - | |||
| - | UUID=b2fa2xxx-670f-4d44-becc-d9xxxxxa41 / | ||
| - | </ | ||
| - | ===== TRIM ===== | ||
| - | ==== Continues TRIM ==== | ||
| - | The real reason Ubuntu doesn’t TRIM SSDs by default is because the Linux kernel’s implementation of TRIM is slow and results in poor performance in normal use. Windows sends a TRIM command each time it deletes a file, telling the drive to immediately delete the bits of the file. Linux supports this when file systems are mounted with the “discard” option. However, Debian, Ubuntu — and other distributions — don’t do this by default for performance reasons. Continuous TRIM is not the most preferred way to issue TRIM commands in Linux. Continuous TRIM is enabled by the discard option for a mount in /etc/fstab: enables continuous TRIM in device operations: | ||
| - | < | ||
| - | / | ||
| - | </ | ||
| - | ==== Periodic trim ==== | ||
| - | Check if the fstrim service is already existing in / | ||
| - | < | ||
| - | # nano / | ||
| - | -------------------------------------------- | ||
| - | |||
| - | [Unit] | ||
| - | Description=Discard unused blocks on filesystems from /etc/fstab | ||
| - | Documentation=man: | ||
| - | |||
| - | [Service] | ||
| - | Type=oneshot | ||
| - | ExecStart=/ | ||
| - | </ | ||
| - | < | ||
| - | # nano / | ||
| - | ------------------------------------------ | ||
| - | |||
| - | [Unit] | ||
| - | Description=Discard unused blocks once a week | ||
| - | Documentation=man: | ||
| - | |||
| - | [Timer] | ||
| - | OnCalendar=weekly | ||
| - | AccuracySec=1h | ||
| - | Persistent=true | ||
| - | |||
| - | [Install] | ||
| - | WantedBy=timers.target | ||
| - | </ | ||
| - | |||
| - | Start the timer and check if timer is activated properly: | ||
| - | < | ||
| - | # systemctl enable fstrim.timer | ||
| - | # systemctl start fstrim.timer | ||
| - | # systemctl list-timers | ||
| - | </ | ||
| - | |||
| - | ===== Ramdisks ===== | ||
| - | Add ramdisks for temporary data files in /etc/fstab. | ||
| - | < | ||
| - | #nano /etc/fstab | ||
| - | |||
| - | tmpfs /tmp | ||
| - | tmpfs / | ||
| - | tmpfs / | ||
| - | tmpfs / | ||
| - | tmpfs / | ||
| - | </ | ||
| - | ===== Swappiness ===== | ||
| - | The default value of vm.swappiness is 60 and represents the percentage of the free memory before activating swap. The lower the value, the less swapping is used and the more memory pages are kept in physical memory.These values are defined: | ||
| - | * 0: swap is disable | ||
| - | * 1: minimum amount of swapping without disabling it entirely | ||
| - | * 10: recommended value to improve performance when sufficient memory exists in a system | ||
| - | * 100: aggressive swapping | ||
| - | === Get current value === | ||
| - | With the following 2 commands the current value of vm.swappiness can be retrieved: | ||
| - | < | ||
| - | # sysctl vm.swappiness | ||
| - | or | ||
| - | # cat / | ||
| - | </ | ||
| - | === Set new value === | ||
| - | With the following 2 commands the current value of vm.swappiness can be set: | ||
| - | < | ||
| - | # echo 10 > / | ||
| - | or | ||
| - | # sysctl -w vm.swappiness=10 | ||
| - | </ | ||
| - | To set the value permanently, | ||
| - | < | ||
| - | # nano / | ||
| - | ---------------------------------- | ||
| - | Add line to the bottom of the file: | ||
| - | |||
| - | vm.swappiness = 10 | ||
| - | </ | ||
| - | ===== Turn off Journaling in EXT4 ===== | ||
| - | === Check current status === | ||
| - | First thing' | ||
| - | < | ||
| - | sudo dumpe2fs /dev/sdaX | grep has_journal | ||
| - | </ | ||
| - | If nothing is returned journaling is off. If something is returned, like: " | ||
| - | === Disable journaling === | ||
| - | Disabling journaling is rather easy, the only drag is that to make structural changes to a filesystem, | ||
| - | the filesystem cannot be mounted with read/write privileges. So, run a live cd and hit | ||
| - | < | ||
| - | sudo tune2fs -O ^has_journal /dev/sdaX | ||
| - | </ | ||
| - | And it's done. Now when you boot, the change will be noted and the disk will be checked for errors. | ||
| - | When the system is finally up we can run this again to confirm that in fact ext4 is running without a journal | ||
| - | < | ||
| - | sudo dumpe2fs /dev/sdaX | grep has_journal | ||
| - | </ | ||
| - | should now return nothing. With this quick fix, no more constant IO peaks. | ||
| - | BTW, one good way to format ext4 from scratch, W/O journalling, | ||
| - | is to specifically issue the command | ||
| - | < | ||
| - | mke2fs -t ext4 -O ^has_journal -cv /dev/sda1 | ||
| - | </ | ||
| - | ===== IO-Scheduler ===== | ||
| - | This step is not necessary for SSDs using the NVMe protocol instead of SATA, which bypass the traditional I/O scheduler and use the blk-mq module instead. | ||
| - | An I/O scheduler decides the order in which applications are given access to the SSD for writes and reads. In Linux, the default I/O scheduler in Linux is called CFQ, Completely Fair Queuing. CFQ generally works well, but it is not perfect for SSDs. Its default behavior is to give drive access on a first come - first serve basis. Sometimes overall system performance can be enhanced by using a different scheduling order. Also, there are schedulers which cause less wear on solid state drives. Two of the better I/O schedulers for SSDs are noop and **deadline**, | ||
| - | === Query current scheduler mode === | ||
| - | To see the current scheduler in use for a disk on your system (and alternative I/O schedulers), | ||
| - | < | ||
| - | # cat / | ||
| - | |||
| - | noop [deadline] cfq | ||
| - | </ | ||
| - | === Set proper scheduler mode === | ||
| - | If the scheduler mode is not deadline, we need to change it. To change the I/O scheduler of a disk to deadline (temporarily - until shutdown or reboot), use the " | ||
| - | the scheduler file. | ||
| - | < | ||
| - | echo deadline > / | ||
| - | </ | ||
| - | ===== Firefox ===== | ||
| - | ==== Save Interval ==== | ||
| - | The Firefox browser writes between 300 kb and 2 MB every 15 seconds to a recovery file to recover unexpectedly terminated sessions. The solution is to increase that interval. Recommends setting it to 30 minutes. You can adjust the value in **about: | ||
| - | ==== Move Firefox cache to ram ==== | ||
| - | Moving the cache into RAM enhances the browser' | ||
| - | **browser.cache.disk.parent_directory** | ||
| - | Set the new string value to: | ||
| - | **/ | ||
linux/system/ssd.1642246727.txt.gz · Last modified: by 127.0.0.1
