Ask Your Question

Does Fedora 20 support TRIM out of box?

asked 2014-04-22 19:00:41 -0500

foggy gravatar image

updated 2014-04-23 09:11:43 -0500

mether gravatar image

I'm getting ready to switch from Ubu to Fedora. The new Ubu 14.04 supports trim but I couldn't find anywhere that says Fedora 20 supports trim. If so, how do I enable trim? I see this one post on how to enable trim here But this is based on Fedora 15. I don't plan on encrypting my hard drive nor any of my folders.

64gb Intel X-18M G2 (Yes, it supports TRIM).

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2014-04-22 19:32:28 -0500

NickTux gravatar image

updated 2014-04-23 13:42:57 -0500

Ubuntu supports trim in userspace with the fstrim-all script. It is a script lays in /etc/cron.weekly/ directory and is being executed once a week.


It's very easy to create your own relevant script in this directory if you want fstrim to be executed once a week. fstrim is installed by default in F20, but a script like fstrim-all doesn't exist.

Create the script

Open your favorite editor and create a script inside /etc/cron.weekly/ directory.

sudo gedit /etc/cron.weekly/trim

Copy and paste inside the following content


# call fstrim to trim all mounted file systems which support it

set -e


echo "*** $(date -R) ***" >> $LOG

exec /usr/sbin/fstrim -v / >> $LOG

Above script will execute fstrim in root direcrory (/) only. In case you have a separate /home (or any other separate directory, under another partition) and you want to run fstrim there as well, you have to add it separately. Like

exec /usr/sbin/fstrim -v /home >> $LOG

Save the document and give execute permissions

sudo chmod 755 /etc/cron.weekly/trim

Test the script,

sudo /etc/cron.weekly/trim

if it works you will see a trim.log file in your /home directory where it indicates some information about trimming.


Other people support that discard parameter in kernel does the job better,

other people that is has problems and slows down the system. I don't know what is the most accurate.

If you want to test discard option rather than fstrim , you can set it in grub by editing a file called /etc/default/grub .

Again, with your preferred editor open the file and search for the line begins with GRUB_CMDLINE_LINUX=

sudo gedit /etc/default/grub

and add the discard option there. Just leave a space and write discard. Don't remove or change anything else.

The line could be become something like:

GRUB_CMDLINE_LINUX="vconsole.font=latarcyrheb-sun16 $([ -x /usr/sbin/rhcrashkernel-param ] && /usr/sbin/rhcrashkernel-param || :) discard"

Save the document and

you have to regenerate grub.conf for the changes to take effect

sudo grub2-mkconfig -o /boot/grub2/grub.cfg

edit flag offensive delete link more


Thanks! I definitely try to fstrim.

foggy gravatar imagefoggy ( 2014-04-22 20:19:28 -0500 )edit

I use fstrim as well in my F20.

NickTux gravatar imageNickTux ( 2014-04-22 20:54:55 -0500 )edit

I'd definitely go with fstrim, the discard option isn't really recommended by some of the Linux filesystem developers (e.g. ext4) for regular SSD drives. Have a look at my post in this question.

FWIW, I'd go with a monthly script rather than a weekly one, note that as long as you leave enough free space on the drive (either unallocated free space called OP (over-provisioning) or free space in partitions called dynamic OP) you don't need to worry about running fstrim regularly.

Ahmad Samir gravatar imageAhmad Samir ( 2014-04-23 01:22:03 -0500 )edit

About the script, it only runs fstrim on the root / partition, not on any other mount point e.g. if the user has a separate /home.

To be honest I don't know the benefit of using exec here.

Ahmad Samir gravatar imageAhmad Samir ( 2014-04-23 01:25:47 -0500 )edit

Correct. If the user has separate partitions it can add them to the script. The exec command is not mandatory, just a habit of mine I use in lot of scripts. If you really don't know the usage of exec you can read a good answer here. I edited my answer and added a clarification about separate /home (or any other) directory. Thanks

NickTux gravatar imageNickTux ( 2014-04-23 05:22:31 -0500 )edit

answered 2014-09-17 03:11:07 -0500

r1348 gravatar image

Just to be precise, Fedora when installed in UEFI mode saves grub.cfg in a different path, the command for creating a new grub.cfg on UEFI systems should be:

sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2014-04-22 19:00:41 -0500

Seen: 4,975 times

Last updated: Sep 17 '14