Home page of this blog

Thursday, November 25, 2010

Enterprise Kernel 6 has SSD TRIM support

Today morning I successfully compiled Red Hat Enterprise Kernel 6 from source into a deb. The kernel is running excellently in Ubuntu. As an added bonus, I found that it already has SSD TRIM support

Now that I have an enterprise kernel as a debian binary and running, I tested SSD TRIM functionality with EL6 kernel

SSD TRIM is a wear levelling feature and supported from kernel versions 2.6.33 and above in ext4 filesystems. Though Enterprise Kernel 6 is in version 2.6.32 it has this TRIM functionality out of box for ext4. I think it has been backported into EL6 (exciting ....) and now I have it in Ubuntu (wow wow wow)

This is how I tested it

Before testing the SSD partition should be mounted with discard option,

Mount the SSD partition with a discard option, that is after the default options of SSD partition in /etc/fstab, say / for root SSD partition in /dev/sda1, it should look like below

/dev/sdb1 /  ext4    errors=remount-ro,noatime,discard  0       1

Use hdparm to test if discard is actually using TRIM to clear the bits in hardware

Here is how

1. Create a temporary file inside the SSD partition as root. Important change the directory to the SSD partition, from home partition if home is a harddisk partition

dd if=/dev/urandom of=tempfile count=100 bs=512k oflag=direct

2. Get the device sector of the tempfile generated and copy the first sector information after value 0

hdparm --fibmap tempfile

In the above example, the sector info I copied for testing is 802816 this will be a different value for the tempfile you generate

3. Read the sector using hdparm before deleting. Here I used the value I copied from previous step and gave as input to hdparm to read the sector info to see if it is non zero. Change the number after --read-sector to the value you got for hdparm --fibmap tempfile, dont blindly give 802816. /dev/sdb is my SSD harddisk, so I used that at the end, replace with the correct harddisk name

hdparm --read-sector 802816 /dev/sdb

4. Remove the tempfile and sync

rm tempfile && sync

5. Retry step 3 and the values displayed should all be zeroes, if TRIM is in action

hdparm --read-sector 802816 /dev/sdb

Kudos, if you came to this level, you probably tried, if your kernel supported TRIM for your SSD or know that Red Hat Enterprise 6  Kernel has TRIM feature in place already!

If you thought Ubuntu Long Term Support 10.04, kernel 2.6.32 has TRIM already, sorry, it does not have it yet. But EL6 kernel has TRIM support for SSD and it rocks!!

I have built the kernel deb of EL6 from source and you can follow my earlier blog to build it yourself as I have not yet hosted it

1 comment:

  1. Hello, I use rhel 6.3 installed in Samsung 830 SSD with kernel . I followed your steps but can not get all 0's in the last step. It's strange that the kernel works in Ubuntu. Maybe a different testing method is needed in rhel 6.3?