alghanmi / ubuntu-desktop_setup

Initial setup and customization of an Ubuntu LTS desktop environment
MIT License
50 stars 19 forks source link

SSD Configuration on Linux Wiki issues #10

Open filakhtov opened 6 years ago

filakhtov commented 6 years ago

Hello,

I have stumbled upon SSD configuration wiki while Googling some SSD optimization tricks and discovered that information here should be improved to avoid misinformation and possible issues for those who follow it.

I would not recommend doing sudo tune2fs -O ^has_journal $SSD_DRIVE, because disabling Journalling increases chances of data corruption during power loss. Sure that will reduce writes, but it has associated risks disabling it that aren't outlined in the Wiki. Some info from superuser.com.

sudo tune2fs -o discard $SSD_DRIVE is also not recommended nowadays, because with continuous TRIM commands you will lose performance. Alternative and recommended approach is to periodically run fstrim from util-linux using Cron, Anacron or SystemD timers. See here for background.

Changing scheduler to deadline via echo deadline > /sys/block/sdX/queue/scheduler should also be tested first, specifically because newest Kernels have improvements in this area, i.e.:

CFQ has some optimizations for SSDs and if it detects a non-rotational media which can support higher queue depth (multiple requests at in flight at a time), then it cuts down on idling of individual queues and all the queues move to sync-noidle tree and only tree idle remains. This tree idling provides isolation with buffered write queues on async tree.

cfq-iosched.txt from Kernel documentation. People also sometimes recommend noop scheduler, see here.

Cheers, Garry

filakhtov commented 6 years ago

Another extremely important bit about TRIM support that is missing here - every block layer must be aware of it. This means if LVM partitions are used then LVM stack has to issue discards and it can be enabled by adding the following into /etc/lvm/lvm.conf:

devices {
...
    issue_discards = 1
...
}

If LUKS encrypted partitions are used it is necessary to add discard option into crypttab or custom systemd-cryptsetup@ service if one is used.

Depending on the configuration, initrd/initramfs has to also be aware of these options.