I used to install Linux on HDD. It's easy. But now I have a SSD, and I want to install Fedora 17 on it.

What should I do to make Fedora 17 issue TRIM commands to the SSD?

  • How big is your SSD? It should work fine. Did you try installing it already? – Mikel Aug 1 '12 at 2:41
  • 128GB. It's on my notebook computer. – CodeSun Aug 1 '12 at 3:01
  • So what problem are you having? Do you need help partitioning? Help with the bootloader? What exactly are you asking? – Mikel Aug 1 '12 at 4:04
  • The Fedora Guide (for 14) has a chapter on deployment on SSD, is it helpful? – sr_ Aug 1 '12 at 6:45
  • I don't see any difference on installation, what you expecting, tuning ? – daisy Aug 1 '12 at 8:01

This is pretty easy, now that TRIM can pass through LVM to the underlying device(s).

  1. When you install, make sure your filesystems are all set to ext4. TRIM is not supported on ext3.

  2. After you install, login as root and edit /etc/fstab. In the fourth column (that usually reads defaults) add the keyword discard. Do this for both the / and /boot partitions, and any other partitions you created on the SSD.

    An example:

    /dev/mapper/vg_mymachine-lv_root /                       ext4    discard         1 1
    UUID=94b6d32d-ec21-4028-9a89-b1a19849c4ad /boot                   ext4    discard         1 2

    (If defaults is the only keyword there, it can be replaced with discard. If other keywords are there, append it with a comma, e.g. whatever,discard.)

    Nothing needs to be done for swap; all swap partitions automatically support TRIM.

  3. LVM support for discard is disabled by default. Enable it by editing /etc/lvm/lvm.conf and changing issue_discards = 0 to issue_discards = 1.

  4. Restart the computer.


There were some problems in Fedora 18 with LUKS not propagating TRIM commands, but this was fixed in Fedora 19. On my system, TRIM commands propagate successfully. One just needs to make few changes in the configuration. First of all, we need to check if TRIM propagates for all partitions to the end device:

[lzap@lzapx ~]$ lsblk -D
NAME                                            DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda                                                    0      512B       2G         1
├─sda1                                                 0      512B       2G         1
└─sda2                                                 0      512B       2G         1
  ├─fedora_lzapx-root                                  0      512B       2G         1
  ├─fedora_lzapx-swap                                  0      512B       2G         1
  └─fedora_lzapx-home                                  0      512B       2G         1
    └─luks-aaaaaaaa-6657-44f4-8297-bbbbbbbb1111        0      512B       2G         0

The last column shows if TRIM commands do propagate. We can see all is set, except the encrypted home (the last line). To get full TRIM support on LUKS-encrypted devices, we need to allow TRIM commands. Note that this can decrease encryption strengh. This is the Fedora 19 default crypttab file:

$ cat /etc/crypttab
luks-aaaaaaaa-6657-44f4-8297-bbbbbbbb1111 UUID=aaaaaaaa-6657-44f4-8297-a571e02e5492 none

I added allow-discards option there:

$ cat /etc/crypttab
luks-aaaaaaaa-6657-44f4-8297-bbbbbbbb1111 UUID=aaaaaaaa-6657-44f4-8297-a571e02e5492 none allow-discards

Optional LVM configuration

If you modify your LVM logical volumes often (e.g. shrinking, deleting), you want to set issue_discards to 1 in `/etc/lvm/lvm.conf. Then you need to do the next optional step described bellow.

Optional init RAM disk regeneration

If you have root partition encrypted by LUKS (not my case) or if you have your root partition on LVM and you want LVM trimming when shrinking or deleting (see above optional step), initial RAM disk needs to be regenerated using the following command:

dracut -f

You will need to reboot to make this change effective of course.

Now, to enable TRIM and take advantage of it, there are two options:

TRIM when deleting files

It is possible to configure ext4 to send TRIM commands while deleting data. You can do this by adding discard option to partitions in /etc/fstab. Note that this slows down deleting a bit. It depends on the SSD drive, but this can slow down quite significantly on some drives.

Do not put discard option to swap devices as this is not required (and perhaps it will not work either). Swap is SSD friendly by default and propagates TRIM command.

TRIM from cron

This is the preferred option because it can be scheduled daily, weekly or during night if you do not turn off your laptop/server:

cat /etc/cron.weekly/01-fstrim
fstrim /
fstrim /home

chmod +x /etc/cron.weekly/01-fstrim

Try to run the script now, it should not print any error message. If you changed LUKS configuration, you might need restart before doing that.


  • 1
    If your root filesystem is encrypted, you must do this and then rebuild your initramfs by rerunning dracut before it will take effect for the root filesystem. – Michael Hampton Nov 20 '13 at 16:58
  • Yes, it is not as you can see from the above lsblk command. I made a note in my blogpost tho. And also changed the answer not to confuse googlers - thanks! – lzap Nov 21 '13 at 9:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.