Sunday, September 18, 2011

Verify TRIM support on Linux

Wasted my time today puzzling why the trim support of my ssd does not work, or I thought it wasn't but was working alright. When you google "linux trim verify" the link below and most people link to the site below. Apparently the tests is not fully correct. Most of the time it works for others, but not me. Maybe it has to do that I formatted my ext4 w/ -E stripe-width=128
Anyway this is a better test I found, but I can't seem to see the link anymore. Using my bash history for reference.
dd if=/dev/urandom of=tmpfile bs=1M count=10 && sync
hdparm --fibmap tmpfile
hdparm --read-sector [address between begin_LBA and end_LBA of previous command] # expecting random numbers here
rm tmpfile && sync && sleep 120
hdparm --read-sector [address between begin_LBA and end_LBA of previous command] # expecting zeroes
The real key is the sector address is somewhere in between and NOT the start sector, as its possible the trim command will not set things to zeroes if files overlap. As it had happened to me 9 out of 10 tries using the test below I get random numbers still. The test above I get zeroes consistently.

No comments: