Ask Your Question
2

Trim not working on SSD

asked 2013-05-05 06:25:24 -0600

koneton gravatar image

Hello, I need Your support with enabling TRIM on my SSD drive. I've installed Fedora 18 (32 bit with PAE) on my SSD disk KINGSTON SV300S37A120G. This drive should support TRIM command: hdparm -I /dev/sdb | grep "TRIM supported" return Data Set Management TRIM supported (limit 1 block) I've modify my fstab to:

UUID=0126d794-94a9-40ec-90f6-d5f1fa3654a7 /                       ext4    discard,noatime,nodiratime,errors=remount-ro        1 1
UUID=181ea4b6-6130-4708-b17b-ed24e8551631 /boot                   ext4    discard,noatime,nodiratime,errors=remount-ro        1 2
UUID=ae025038-ac45-4b21-8109-ee3a3ace2fa8 /home                   ext4    discard,noatime,nodiratime,errors=remount-ro        1 2

I'm expecting that's all I need to make TRIM working but it doesn't work. My test was:

dd if=/dev/urandom of=tempfile bs=1M count=3
hdparm --fibmap tempfile
hdparm --read-sector [ADDRESS] /dev/sdb
rm tempfile && sync && sleep 120
hdparm --read-sector [ADDRESS] /dev/sdb

Read-section option always return the same values (non zero). My uname -a returns: Linux ******* 3.8.9-200.fc18.i686.PAE #1 SMP Fri Apr 26 13:01:35 UTC 2013 i686 i686 i386 GNU/Linux.

Please let me know, what should I change or modify to make TRIM working.

edit retag flag offensive close merge delete

Comments

The TRIM feature should be enabled by default. What is the return of 'lsblk -D' command? Related post: https://ask.fedoraproject.org/question/7384/is-trim-command-working-on-lvm-or-not/?answer=15813#post-id-15813

Bucic gravatar imageBucic ( 2013-05-07 12:40:25 -0600 )edit

8 Answers

Sort by » oldest newest most voted
2

answered 2013-11-25 22:32:05 -0600

sandeen gravatar image

Trim doesn't necessarily mean that the trimmed block will return zeros when read.

If the device has properly advertised discard to the kernel, you should see it here (substituting your device name for "sda" of course):

$ cat  /sys/block/sda/queue/discard_granularity 
512

and if you can expect trimmed blocks to return 0s on a post-trim read, you can see it here:

$ cat  /sys/block/sda/queue/discard_zeroes_data
1

If you see 0 there, you'll read stale data instead.

edit flag offensive delete link more
3

answered 2013-08-05 03:42:55 -0600

none gravatar image

updated 2013-11-26 15:12:33 -0600

TRIM doesn't mean that your free block will be filled by zero. It means, that your SSD controller knows about free blocks. Please refer to this link.

edit flag offensive delete link more
1

answered 2013-05-23 13:41:24 -0600

Bucic gravatar image

updated 2013-05-23 13:44:03 -0600

The TRIM feature should be enabled by default.
What is the return of 'lsblk -D' command?

If you see "0B" in both the DISC-GRAN and DISC-MAX columns then discard is not passing through to the LVM partition. If you see something besides 0B then discard is enabled.

Source:
https://ask.fedoraproject.org/question/7384/is-trim-command-working-on-lvm-or-not/?answer=15813#post-id-15813

edit flag offensive delete link more
1

answered 2013-10-11 16:16:57 -0600

B0D_Mr4ZU gravatar image

Hello, and what do you say about LVM config file (/etc/lvm/lvm.conf)? Shouldn't be issue_discards = 0 option set to 1? What do you think?

edit flag offensive delete link more
0

answered 2013-05-07 14:49:33 -0600

koneton gravatar image

This command returns:

NAME   DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda           0        0B       0B         0
├─sda1        0        0B       0B         0
├─sda2        0        0B       0B         0
├─sda5        0        0B       0B         0
└─sda6        0        0B       0B         0
sdb           0      512B       2G         0
├─sdb1        0      512B       2G         0
├─sdb2        0      512B       2G         0
└─sdb3        0      512B       2G         0
sr0           0        0B       0B         0

So, its look like TRIM works?

edit flag offensive delete link more

Comments

If sdb is your SSD, then yes, it works :) Verify the drive letters using the Disks (GNOME app).

Bucic gravatar imageBucic ( 2013-05-10 11:50:03 -0600 )edit
0

answered 2013-08-10 17:52:49 -0600

rstrode gravatar image

note, as aside, kernel filesystem developers discourage using the "discard" fs option, and instead recommend using the wiper.sh script shipped with hdparam occasionally.

edit flag offensive delete link more

Comments

1

Please don't leave it at that if you can improve tha answers given here. Particularly if you've noticed some incorrect bits of information...

Bucic gravatar imageBucic ( 2013-08-11 04:03:54 -0600 )edit
0

answered 2014-04-06 15:31:06 -0600

Blanca Higgins gravatar image

To enable TRIM for SSD on Fedora

Back up fstab first in case something wrong happen.

# cp /etc/fstab ~/fstab.bk

Edit fstab file

# nano /etc/fstab

Add discard to your ssd drives or partitions, after ext4

UUID=bef10b86-494d-41c6-aa46-af72cfba90fd / ext4 discard,errors=remount-ro 0 1
edit flag offensive delete link more
0

answered 2014-04-07 02:29:31 -0600

Ahmad Samir gravatar image

Expanding on @rstrode's answer, according to Theodore Ts'o, the ext4 filesystem developer, enabling the "discard" mount option isn't recommended for most SATA SSD drives; instead it's better to run the fstrim command as a cron job.

Another point is, you don't necessarily need to worry about TRIM if you have enough over-provisioning, see this blog post by Kent Smith from LSI (they develop the SandForce SSD controllers that are used in e.g. Intel SSD), the comments on that blog post were very informative - for me at least.

See also this post on the fedora users ML, and the whole thread.

I am not an expert on the subject, but to sum up, personally I don't use the "discard" mount option, and make sure not to fill the SSD to capacity and also, if you can manage it, leave some free un-partitioned space on the SSD for more over-provisioning.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2013-05-05 06:25:24 -0600

Seen: 6,902 times

Last updated: Apr 07 '14