What is the correct way to setup the fstrim service on an encrypted SSD in Fedora 23?
Hi Everyone, This is my first post. I've been using Linux on and off for several years now but am a newbie to Fedora.
I performed a fresh Fedora 23 install and partitioned using LVM and ext4. I used the default anaconda encryption during install. The computer has both an SSD (sda) and an HDD (sdb).
After reading different posts all over the internet offering advice on how to optimize an SSD, I'm starting to get more confused than clear on what needs to be done to correctly fstrim my encrypted ssd, especially with recent advances and using Fedora 23. I can really use your expert help.
- Preliminary checks:
$ sudo blockdev --getalignoff /dev/sda I get a 0 (which as I understand confirms alignment)
$ su -c 'hdparm -I /dev/sda' | grep TRIM I get that TRIM is supported
My goal is to to use the fstrim.service to TRIM weekly and verify that it works. From my understanding (this may be wrong), before this will work correctly, I need to enable TRIM on all the filesystem layers (LVM, ext4, and crypt). To set this up, I edited as follows:
/etc/lvm/lvm.conf set issue_discards=1
/etc/crypttab
Tried three different ways to allow discard (none seem to work) by adding the following at the end of the lines in crypttab:
- ...none allow-discards
- ...none discard
- ...none luks,discard
Then trying both:
- $ sudo dracut -f
and
- $ sudo dracut -f -I /etc/crypttab
Then after reboot:
$ sudo cryptsetup status luks-e34...11 (for the sda) I get no flags showing discard enabled
- I also read that I'm suppose to edit /etc/default/grub... I tried:
rd.luks.allow-discards=e43...11
rd.luks.options=discard
both (1) and (2) together
followed each time with:
$ sudo grub2-mkconfig -o /boot/grub2/grub.cfg; reboot
Starting fstrim:
$ sudo systemctl enable fstrim.timer;
$ sudo systemctl start fstrim.service;
$ sudo systemctl status fstrim.service;
Gives: fstrim.service - Discard unused blocks Loaded: loaded (/usr/lib/systemd/system/fstrim.service; static; vendor preset: disabled) Active: inactive (dead)
- Testing using:
$ sudo systemctl start fstrim
Gives nothing
$ sudo fstrim -all
Gives: fstrim: failed to parse length: 'l'
$ sudo fstrim -v /home
Gives: fstrim: /home: the discard operation is not supported
$ sudo lsblk -D
Does seem to show the appropriate DISC-GRAN (512B) and DISC-MAX (2G) for the ssd but shows DISC-ZERO to be 0. From my understanding, this is a sign that the command does not propagate.
Basically, when trying to test fstrim I get operation not supported. So, as you can see, I'm in need of help. Your feedback on how to correctly setup fstrim to TRIM weekly for an encrypted SSD in Fedora 23 will be greatly appreciated. Many thanks in advance.
In your section Starting fstrim:, the command should be
systemctl enable fstrim.timer
, notenable fstrim.service
.Yes. Thank you. I'll make the edit.
Make sure you set
issue_discards = 1
, notissue_discards=1
.