Post date: 21-Sep-2010 18:03:55
IMPORTANT: Many modern SSDs will not reclaim the TRIMmed space. For this reason you may not see zeros at the end of the test even though TRIM could be working. This weakens the reliability of the test when showing that TRIM is not working. However if you see zeros at the end, then TRIM is definitely working. To put it simply - if the test tells you that TRIM is working (zeros show up), then TRIM is working; if the test tells you that TRIM may not be working (zeros do not show up), then TRIM may or may not be working. In the latter case, simply double check that you have used the right mount options in /etc/fstab and if they look correct, TRIM most probably works. Simply your SSD is not reclaiming the space immediately, so nothing to worry about.
NOTE: If you were looking for instructions on how to enable TRIM rather than test it, look at this HOWTO.
NOTE 2: This HOWTO may not work if the filesystem we store the tempfile
on is encrypted (e.g. Encrypted Home on Ubuntu).
NOTE 3: /dev/sdX
is the SSD drive you are testing.
If you have an SSD and using Ubuntu or another flavour of GNU/Linux you probably have enabled TRIM in Ext4. However there is no obvious way to check whether it actually works. Here are several steps that can help you verify that:
sudo -i
dd if=/dev/urandom of=tempfile count=100 bs=512k oflag=direct
hdparm --fibmap tempfile
hdparm --read-sector [ADDRESS] /dev/sdX
rm tempfile
sync
hdparm --read-sector [ADDRESS] /dev/sdX
Alternatively you can use the script provided by Dorian Bolivar that automates this process. In order to do that follow these steps:
wget -O /tmp/test_trim.sh "https://sites.google.com/site/lightrush/random-1/checkiftrimonext4isenabledandworking/test_trim.sh?attredirects=0&d=1"
chmod +x /tmp/test_trim.sh
sudo /tmp/test_trim.sh tempfile 50 /dev/sdX
If TRIM is properly working the result of the last command should be a bunch of zeros. If the output is not zeros, then something could be wrong with your kernel/Ext4 configuration and TRIM may not be working. For simple instructions of how to enable TRIM, look at this HOWTO.