OpenELEC Forum
SSD TRIM doesn't appear to be enabled - Printable Version

+- OpenELEC Forum (https://forum.openelec.tv)
+-- Forum: Generic Forum (https://forum.openelec.tv/forumdisplay.php?fid=5)
+--- Forum: STORAGE (https://forum.openelec.tv/forumdisplay.php?fid=60)
+--- Thread: SSD TRIM doesn't appear to be enabled (/showthread.php?tid=8509)

Pages: 1 2 3 4


[SOLVED]SSD TRIM doesn't appear to be enabled - amak79 - 07-20-2011

I assumed that OpenELEC had SSD TRIM support enabled and working by default. However after reading an article on Techgage titled Enabling and Testing SSD TRIM Support Under Linux, I decided to test this assumption.

Although TRIM is supported by the OpenELEC kernel, to my surprise it doesn't appear to be enabled. At least not in my case. It seems you need to pass the 'discard' option when mounting, which as far I can tell OpenELEC doesn't do.

The mount man page seems to back this up as well.

Quote:discard/nodiscard

Controls whether ext4 should issue discard/TRIM commands to the underlying block device when blocks are freed. This is useful for SSD devices and sparse/thinly-provisioned LUNs, but it is off by default until sufficient testing has been done.

Is there anyway to pass the 'discard' option to mount with OpenELEC?

I'm using OpenELEC RC5 so I don't know if this situation has changed with the development version. I apologize if the OpenELEC devs already know about this issue. I did search the forums but all the posts claimed that TRIM support was enabled and working.

Anyone wishing to confirm this can run the specified commands from the second page of the article. I have also summarized the commands below.

- Create a file with random data.
dd if=/dev/urandom of=testfile count=1 bs=4k

- Flush the filesystem buffer.
sync

- Find which sectors of the drive the file is using. Take note of the 'begin_LBA' value.
hdparm --fibmap testfile

- Read the sector contents. Use the previous 'begin_LBA' value for the '--read-sector' option.
hdparm --read-sector 638992 /dev/sda

- Delete the test file.
rm testfile

- Flush the filesystem buffer.
sync

- Read the sector contents. If TRIM is enabled, the contents of the sector should be all 0s.
hdparm --read-sector 638992 /dev/sda

- If the sector contents weren't all 0s, run fstrim to discard the unused blocks.
fstrim /storage

- Read the sector contents. The sector contents should now be all 0s.
hdparm --read-sector 638992 /dev/sda


Re: SSD TRIM doesn't appear to be enabled - josh4trunks - 07-20-2011

I believe Openelec uses ext3 which does not have trim support. Only ext4 does and btrfs has experimental support for now.
I doubt enough writing that trim will make a performance difference but it would always be a plus getting trim because allot of people are using ssd's.


Re: SSD TRIM doesn't appear to be enabled - amak79 - 07-20-2011

It appears OpenELEC uses ext4.

Code:
root ~ # blkid
/dev/sda1: LABEL="System" UUID="b2524ca4-5e10-4e07-920c-14c8401ed0d4" TYPE="ext4"
/dev/sda2: LABEL="Storage" UUID="c5fb2377-8862-4779-bd01-7d71241d14a4" TYPE="ext4"

If it does use ext3 as you say then that would explain why TRIM is not enabled.


Re: SSD TRIM doesn't appear to be enabled - josh4trunks - 07-20-2011

Hmm, I thought it used ext3 but looks like I'm wrong.
---

Anyway just remount /flash as writable
Code:
mount -o remount,rw /flash

then add discard to the APPEND line in /flash/extlinux.conf
Code:
nano /flash/extlinux.conf

Mine looks like this now
Code:
APPEND boot=LABEL=System disk=LABEL=Storage quiet vga=792 elevator=noop noatime discard

EDIT
Works! Thanks for bringing this up, now we should both get TRIM working =]


Re: SSD TRIM doesn't appear to be enabled - amak79 - 07-20-2011

Thanks I didn't realize you could add mount options via extlinux.conf.

Anyway it doesn't appear to work for me. I've waited 30 minutes and still the unused blocks haven't been discarded.

When you run 'mount' does it display the 'discard' option for the ext4 partitions? It doesn't for me.

If I check the drives info via hdparm I get
Code:
hdparm -I /dev/sda | grep TRIM
* Data Set Management TRIM supported (limit 1 block)
* Deterministic read data after TRIM

So the drive (Corsair CSSD-F40GB2) does support TRIM just as it claims in the specs. Not sure why it's not working.


Re: SSD TRIM doesn't appear to be enabled - josh4trunks - 07-20-2011

Hmm mount is telling me no discard option...
But I did get all zeros after running fstrim

Does this mean manually trim is working but it the filesystem wont automatically do it?


Re: SSD TRIM doesn't appear to be enabled - amak79 - 07-20-2011

Yes. If you run fstrim then you are manually discarding the unused blocks. The ext4 'discard' mount option should do this automatically so we don't need to run it manually.


Re: SSD TRIM doesn't appear to be enabled - josh4trunks - 07-20-2011

Hmm weird that its not taking the discard parameter... I thought we just needed a 2.6.33 kernel or higher.. guess somethings missing

Weird blkid says ext4 but mount says ext2


Re: SSD TRIM doesn't appear to be enabled - amak79 - 07-20-2011

It works if I run
Code:
mount -o remount,discard /storage

The problem now is getting the 'discard' option passed at boot. It doesn't appear to work via extlinux.conf.


Re: SSD TRIM doesn't appear to be enabled - josh4trunks - 07-20-2011

I wonder if extlinux actaully is passing parameter. noatime seems to work...

Ill confirm this later but as for now I'm sshing from my phone...');