You are not logged in.

#1 2012-03-09 16:12:43

wombat23
Member
Registered: 2011-01-14
Posts: 46

[SOLVED] SSD discard not working

i have a solid state disk and want to use the discard option. my fstab is this:

tmpfs		/tmp		tmpfs	nodev,nosuid			0	0
tmpfs		/var/lock	tmpfs	nodev,nosuid			0	0
tmpfs		/var/run	tmpfs	nodev,nosuid			0	0
tmpfs		/var/log	tmpfs	nodev,nosuid			0	0

/dev/sda2	/		ext4	defaults,noatime,discard	0	1

I also activated discard on that partition via tune2fs -o discard /dev/sda2

however, my mount output is this:

proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
/sys on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
/dev on /dev type devtmpfs (rw,nosuid,relatime,size=1020848k,nr_inodes=224476,mode=755)
/run on /run type tmpfs (rw,nosuid,nodev,relatime,mode=755)
/dev/sda2 on / type ext4 (rw,noatime,user_xattr,acl,barrier=1,data=ordered)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
shm on /dev/shm type tmpfs (rw,nosuid,nodev,relatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,relatime)
tmpfs on /var/lock type tmpfs (rw,nosuid,nodev,relatime)
tmpfs on /var/run type tmpfs (rw,nosuid,nodev,relatime)
tmpfs on /var/log type tmpfs (rw,nosuid,nodev,relatime)
gvfs-fuse-daemon on /home/wombat/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,relatime,user_id=1000,group_id=100)

so it looks like sda2 is mounted without discard. what's wrong here?

Last edited by wombat23 (2012-10-03 19:26:43)

Offline

#2 2012-03-09 21:41:47

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,592
Website

Re: [SOLVED] SSD discard not working

Dunno what to tell you; I didn't mess with tune2fs to enable it, just made the entries in the fstab.  You sure your SSD supports it?

$ grep discard /etc/fstab
/dev/disk/by-label/arch64	/			ext4    defaults,noatime,discard	0	1
/dev/disk/by-label/homes	/home	ext4    defaults,noatime,discard	0	2

$ mount | grep discard
/dev/sdb1 on / type ext4 (rw,noatime,user_xattr,acl,barrier=1,data=ordered,discard)
/dev/sdb2 on /home type ext4 (rw,noatime,user_xattr,acl,barrier=1,data=ordered,discard)

Last edited by graysky (2012-03-09 21:43:24)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#3 2012-03-11 10:15:31

wombat23
Member
Registered: 2011-01-14
Posts: 46

Re: [SOLVED] SSD discard not working

graysky wrote:

Dunno what to tell you; I didn't mess with tune2fs to enable it, just made the entries in the fstab.  You sure your SSD supports it?

It's a fairly new OCZ agility 3, I think it supports it.
I removed the discard option with tune2fs, now the mount says it is mounted with discard. So basically, problem solved - but WHY  did it not work? is it a bug?

Offline

#4 2012-03-11 12:20:58

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,592
Website

Re: [SOLVED] SSD discard not working

Perhaps... What if u add it with tune2fs but not in fstab?  Why not report it to upstream.  If it is a bug they will fix it.  If it is expected behavior they will close your bug report.


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#5 2012-03-11 16:04:32

wombat23
Member
Registered: 2011-01-14
Posts: 46

Re: [SOLVED] SSD discard not working

tested with discard set via tune2fs, and no discard in fstab.
result according to "mount" was no discard.

i'd report it as a bug somewhere, but i don't know where. is that kernel code?

Offline

#6 2012-03-11 17:00:29

broken pipe
Member
Registered: 2010-12-10
Posts: 238

Re: [SOLVED] SSD discard not working

i also own a OCZ agility 3 sata III and discard works. don't tune anything with tunefs, just add the option in the fstab. here's mine:

UUID=718af3d3-8622-4126-a539-e07ba9aa84c6 /home ext4 defaults,noatime,discard 0 1
UUID=7e4badd1-13d7-4dda-9820-81958495e476 /var ext4 defaults,noatime,discard 0 1
UUID=91c98608-2fc6-4346-a60e-3dd1ced19ef0 /boot ext4 defaults,noatime,discard 0 1
UUID=9e0dbe1c-070e-4fd8-a2c7-6d82a3a31ca7 / ext4 defaults,noatime,discard 0 1
UUID=a6e5c6bd-f428-4182-9c0e-88a4b767117d /tmp ext4 defaults,noatime,discard 0 1

tmpfs 		/tmp		tmpfs	nodev,nosuid,noatime	0	0
tmpfs 		/var/tmp 	tmpfs 	defaults,noatime 		0 	0
tmpfs		/var/lock	tmpfs	defaults,noatime		0	0
tmpfs		/var/run	tmpfs	defaults,noatime		0	0

tmpfs /home/markus/.thumbnails tmpfs defaults,noatime 	0	0
tmpfs /home/markus/.cache tmpfs defaults,noatime 		0 	0

reboot and check if the partition is mounted with the discard option: cat /etc/mtab | grep discard

Offline

#7 2012-03-11 17:05:04

lifeafter2am
Member
From: 127.0.0.1
Registered: 2009-06-10
Posts: 1,332

Re: [SOLVED] SSD discard not working

Working fine here on an OCZ Agility 3 Sata III:

/dev/sda3 on / type ext4 (rw,noatime,user_xattr,barrier=1,data=ordered,discard)

Only setting via fstab.


#binarii @ irc.binarii.net
Matrix Server: https://matrix.binarii.net
-------------
Allan -> ArchBang is not supported because it is stupid.

Offline

#8 2012-03-11 17:39:56

kazimir
Member
Registered: 2012-01-20
Posts: 79

Re: [SOLVED] SSD discard not working

I remember reading about the discard option sometimes not showing up in mount.
I don't remember the details as I wasn't affected by this problem but I do remember than you could tell if discard was enabled but not showing by using:

dmesg | grep discard

Last edited by kazimir (2012-03-11 17:40:16)

Offline

#9 2012-09-30 02:16:30

MajorTom
Member
Registered: 2008-09-12
Posts: 58

Re: [SOLVED] SSD discard not working

Can't help it but must dig up this old(er) post and bump it to the top. This info might potentially help others.

As the OP, I also noticed that after setting 'discard' as one of the default mount options with 'tune2fs' directly on ext4, 'mount' will not show it as being used:

# tune2fs -o discard /dev/sda2
# tune2fs -l /dev/sda2 | grep discard
Default mount options:    user_xattr acl discard
# grep discard /etc/fstab
LABEL=archlinux-ssd	/	ext4	defaults,noatime,discard	0	1
# mount | grep sda2
/dev/sda2 on / type ext4 (rw,noatime,data=ordered)

But when that fs option is cleared, everything looks good after mounting via fstab:

# tune2fs -o^discard /dev/sda2
# mount | grep sda2
/dev/sda2 on / type ext4 (rw,noatime,discard,data=ordered)

I got curious and spent some time researching this and found an acceptable answer on gmane.comp.file-systems.ext4.

In essence, default mount options for the fs are just not shown by design. Thus, in my case I couldn't see 'user_xattr', 'acl' and 'discard' but I *think* they were active and working.

Any input on this from the kernel/fs gurus?

Last edited by MajorTom (2012-10-01 18:01:22)

Offline

#10 2012-10-01 04:28:18

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] SSD discard not working

I am no guru, so I cannot speak in regard to the design decisions regarding this, but you can always test to see if discard is working.

http://nedoboi.wordpress.com/2011/11/12 … -it-works/

Offline

#11 2012-10-02 16:40:03

MajorTom
Member
Registered: 2008-09-12
Posts: 58

Re: [SOLVED] SSD discard not working

WonderWoofy wrote:

I am no guru, so I cannot speak in regard to the design decisions regarding this, but you can always test to see if discard is working.

http://nedoboi.wordpress.com/2011/11/12 … -it-works/

This was helpful; thanks.

To summarize it for others reading this thread: testing is done by creating a file, checking its sector ranges and contents on disk with hdparm --fibmap and --read-sector, then deleting the file and checking sectors again. After a successful TRIM, deleted data should be zeroed out.

According to a discussion on redhat linux-lvm and another on centos hardware support, the above depends on the SSD TRIM implementation. (Look for Deterministic read data after TRIM or Deterministic read ZEROs after TRIM in hdparm -I output.)

But here's another significant (confirmed) discovery I've made: TRIM doesn't immediately work on ext4 without a journal. It works when manually invoking the fstrim command though. After adding the journal back, deleted files followed by sync were promptly zeroed out as expected.

Offline

#12 2012-10-03 00:37:07

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] SSD discard not working

I am glad to have helped.  I created a new partition on my ssd, and I wanted to see if my drive worked as expected.  So I tested it out using the tune2fs -o discard method. 

$ mount -l
...
/dev/sdb5 on /mnt type ext4 (rw,noatime,data=ordered)
... 

As you can see, no indication that trim is present or on.

Here is after I wrote a file

 hdparm --read-sector 168866824 /dev/sdb

/dev/sdb:
reading sector 168866824: succeeded
3031 3030 2031 6574 7473 6c20 6e69 0a65
3031 3030 2032 6574 7473 6c20 6e69 0a65
3031 3030 2033 6574 7473 6c20 6e69 0a65
3031 3030 2034 6574 7473 6c20 6e69 0a65
3031 3030 2035 6574 7473 6c20 6e69 0a65
3031 3030 2036 6574 7473 6c20 6e69 0a65
3031 3030 2037 6574 7473 6c20 6e69 0a65
...

...and here is after I deleted the file

hdparm --read-sector 168866824 /dev/sdb

/dev/sdb:
reading sector 168866824: succeeded
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
...

As you can see it is working flawlessly.  I think I may turn this option on with all my ssd partitions.  Maybe also get some noatime up in this sh*t!


Edit:  It no likey my attempts to add noatime.  I guess that is not meant to be set this way.

Last edited by WonderWoofy (2012-10-03 00:38:56)

Offline

#13 2012-10-03 00:48:31

MajorTom
Member
Registered: 2008-09-12
Posts: 58

Re: [SOLVED] SSD discard not working

WonderWoofy wrote:

tune2fs -o discard
...
it is working flawlessly.  I think I may turn this option on with all my ssd partitions.  Maybe also get some noatime up in this sh*t!


Edit:  It no likey my attempts to add noatime.  I guess that is not meant to be set this way.

I finally got a chance to test it myself and my results are the same as yours. It is working just fine even though mount isn't showing the discard option in its output.

As for turning on noatime via tune2fs, this one doesn't seem to be listed among the supported mount options. See man tune2fs, the -o option.

All this is valuable info and should make it to the SSD wiki. I don't have time for it at the moment, but I'll see what I can do if nobody else decides to chip in.

Offline

#14 2012-10-03 19:31:02

wombat23
Member
Registered: 2011-01-14
Posts: 46

Re: [SOLVED] SSD discard not working

Good job on working this out.
I wonder why the developers made it this way that mount does not show options that are set via tune2fs.

I currently don't have time to change the WIKI, so you're welcome to do it ;-)

Offline

#15 2012-10-04 02:56:39

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] SSD discard not working

Okay, I had a few minutes so I added it.  Please check it out and make any necessary changes if you have time.

Offline

#16 2012-12-12 21:12:40

Frezeeer
Member
Registered: 2012-08-10
Posts: 22

Re: [SOLVED] SSD discard not working

WonderWoofy wrote:

I am no guru, so I cannot speak in regard to the design decisions regarding this, but you can always test to see if discard is working.

http://nedoboi.wordpress.com/2011/11/12 … -it-works/

I have TRIM enable by fstab, my SSD suports it.
I tryed what the web (nodoboi) says but I can no see the 00 00 00...
Can anybody help?

Offline

Board footer

Powered by FluxBB