Enable TRIM for SSD with ext4, dmcrypt and md
Depending on why you're encrypting your SSDs it might be acceptable to enable TRIM (aka discard). With this configuration observing raw content on SSDs will reveal which blocks are used and which aren't. Doesn't matter for me, but might not be same for you.
How useful TRIM is varies between SSD controller manufacturers. Especially SandForce when paired with encrypted filesystem is good candidate for TRIM use. SandForce compresses data before writing to flash chips and encrypted data doesn't compress at all. If you want compression try using ROT13 cipher with dmcrypt. :) Anyway, design of SandForce SSDs assumes some average data compression ratio and can get with less reserved space even with TRIM disabled, but that isn't true anymore with crypto.
To enable TRIM with dmcrypt simply edit /etc/crypttab and replace "luks" with "luks,discard".
For ext4 edit /etc/fstab and add "discard" to mount options.
MD doesn't require configuration as with recent kernels it will passthru trim commands.
Finally update initramfs with "update-initramfs -u".
After making crypttab edit reboot. Then run "fstrim -v /boot; fstrim -v /", edit fstab and reboot. This will trim any unused blocks on your SSDs instantly and not only after you've used them once.
For more details check these two blog posts:
http://blog.neutrino.es/2013/howto-properly-activate-trim-for-your-ssd-on-linux-fstrim-lvm-and-dmcrypt/
http://clusterbuffer.wordpress.com/2011/10/02/how-do-you-know-trim-is-working-with-your-ssd-in-your-system/
How useful TRIM is varies between SSD controller manufacturers. Especially SandForce when paired with encrypted filesystem is good candidate for TRIM use. SandForce compresses data before writing to flash chips and encrypted data doesn't compress at all. If you want compression try using ROT13 cipher with dmcrypt. :) Anyway, design of SandForce SSDs assumes some average data compression ratio and can get with less reserved space even with TRIM disabled, but that isn't true anymore with crypto.
To enable TRIM with dmcrypt simply edit /etc/crypttab and replace "luks" with "luks,discard".
For ext4 edit /etc/fstab and add "discard" to mount options.
MD doesn't require configuration as with recent kernels it will passthru trim commands.
Finally update initramfs with "update-initramfs -u".
After making crypttab edit reboot. Then run "fstrim -v /boot; fstrim -v /", edit fstab and reboot. This will trim any unused blocks on your SSDs instantly and not only after you've used them once.
For more details check these two blog posts:
http://blog.neutrino.es/2013/howto-properly-activate-trim-for-your-ssd-on-linux-fstrim-lvm-and-dmcrypt/
http://clusterbuffer.wordpress.com/2011/10/02/how-do-you-know-trim-is-working-with-your-ssd-in-your-system/
Comments
Post a Comment
Got something to say?!