{"id":146,"date":"2012-10-11T11:00:22","date_gmt":"2012-10-11T11:00:22","guid":{"rendered":"http:\/\/www.buildingcubes.com\/?p=146"},"modified":"2025-02-21T14:59:04","modified_gmt":"2025-02-21T14:59:04","slug":"checking-if-ssd-trim-is-working-discard","status":"publish","type":"post","link":"https:\/\/www.voodoo.business\/blog\/2012\/10\/11\/checking-if-ssd-trim-is-working-discard\/","title":{"rendered":"Checking if SSD trim is working (discard)"},"content":{"rendered":"<p>Note that if your kernel is before 2.6.33 you can check, but it won&#8217;t be working !<\/p>\n<p>in the case that you don&#8217;t want to update your kernel, and you just want to trim your disk, try wiper.sh or fstrim, both are command line tools that you can run manually or put in a cron job. if you do want to update your kernel, here is how on debian squeeze<\/p>\n<p>So for example, if you are on debian 6 squeeze, you need to get a kernel from the backports (add the line &#8220;deb http:\/\/backports.debian.org\/debian-backports squeeze-backports main&#8221; to your \/etc\/apt\/sources.list then apt-get update then apt-get -t squeeze-backports install linux-image-3.2.0-0.bpo.2-amd64) to get the new kernel, it will then work.<\/p>\n<p>I assume you already have an ext4 file system with discard option in fstab as described on this website<\/p>\n<p>Also note: Many modern SSDs will not reclaim the TRIMmed space., so if using the test below you see zeros, discard (trim) is working 100%, if you don&#8217;t. it may or may not be working&#8230; but if you wait fdor a significant amount of time, then reboot, the zeros should appear in that exact location even if the disk does not reclaim instantly &#8230; happyt trimming, now to the procedure<\/p>\n<p>now, write a file to the ssd (random numbers)<br \/>\ndd if=\/dev\/urandom of=\/hds\/ssd300\/myfile.bin bs=1M count=3<\/p>\n<p>Find the location where the file begins<br \/>\nhdparm &#8211;fibmap \/hds\/ssd300\/myfile.bin<\/p>\n<p>Now, take note of the start address and use it in this command replacing xxxxx<\/p>\n<p>hdparm &#8211;read-sector xxxxxx \/dev\/sdb<br \/>\nYou should see random numbers<\/p>\n<p>Delete the file<br \/>\nrm \/hds\/ssd300\/myfile.bin<br \/>\nSync with the command<br \/>\nsync<\/p>\n<p>Wait for 2 minutes<br \/>\nthe issue the same command to read again<br \/>\nhdparm &#8211;read-sector xxxxxx \/dev\/sdb<br \/>\nYou should now see all zeros, if you do not, the disk has not been trimmed \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Note that if your kernel is before 2.6.33 you can check, but it won&#8217;t be working ! in the case that you don&#8217;t want to update your kernel, and you just want to trim your disk, try wiper.sh or fstrim, both are command line tools that you can run manually or put in a cron [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,215,9],"tags":[],"class_list":["post-146","post","type-post","status-publish","format-standard","hentry","category-hard-disks","category-hdparm","category-pc-hardware"],"_links":{"self":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/146","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/comments?post=146"}],"version-history":[{"count":1,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/146\/revisions"}],"predecessor-version":[{"id":5017,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/146\/revisions\/5017"}],"wp:attachment":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/media?parent=146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/categories?post=146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/tags?post=146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}