{"id":147,"date":"2012-07-04T21:14:43","date_gmt":"2012-07-04T18:14:43","guid":{"rendered":"http:\/\/vpv.kapsi.fi\/blog\/?p=147"},"modified":"2012-07-04T21:14:43","modified_gmt":"2012-07-04T18:14:43","slug":"ssd-trimdiscard-on-fedora-17-with-encypted-partitions","status":"publish","type":"post","link":"https:\/\/vpv.kapsi.fi\/blog\/2012\/07\/ssd-trimdiscard-on-fedora-17-with-encypted-partitions\/","title":{"rendered":"SSD TRIM\/discard on Fedora 17 with encypted partitions"},"content":{"rendered":"<p>I have not blogged for a while, now that I am on summer holiday and got a new laptop I finally have something to blog about. I got a <a href=\"http:\/\/en.wikipedia.org\/wiki\/ThinkPad_T_Series\">Thinkpad T430<\/a> and installed a <a href=\"http:\/\/www.anandtech.com\/show\/4863\/the-samsung-ssd-830-review\">Samsung SSD 830<\/a> myself. The 830 is not actually the best choice for a Linux user because  you can only download firmware updates with a Windows tool. The tool does let you make a bootable FreeDOS USB disk with which you can apply the update, so you can use a Windows system to download the update and apply it just fine on a Linux system. The reason I got this SSD is that it is 7 mm in height and fits into the T430 without removing any spacers.<\/p>\n<p>I installed Fedora 17 on the laptop and selected drive encryption in the Anaconda installer. I used ext4 and did not use LVM, I do not think it would be of much use on a laptop. After the installation I discovered that Fedora 17 does not enable SSD <a href=\"http:\/\/en.wikipedia.org\/wiki\/TRIM\">TRIM<\/a>\/discard automatically. That is probably a good default, apparently all SSDs do not support it. When you have ext4 partitions encrypted with <a href=\"http:\/\/en.wikipedia.org\/wiki\/LUKS\">LUKS<\/a> as Anaconda does it, you need to change two files and regenerate your <a href=\"http:\/\/en.wikipedia.org\/wiki\/Initrd\">initramfs<\/a> to enable TRIM.<\/p>\n<p>First, edit your <tt>\/etc\/fstab<\/tt> and add <tt>discard<\/tt> to each ext4 mount. Here is an example of my root mount:<br \/>\n<code>\/dev\/mapper\/luks-secret-id-here \/                       ext4    defaults,discard        1 1<\/code><\/p>\n<p>Second, edit your <tt>\/etc\/crypttab<\/tt> and add <tt>allow-discards<\/tt> to each line to allow the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Dm-crypt\">dmcrypt<\/a> layer to pass TRIM requests to the disk. Here is an example:<br \/>\n<code>luks-secret-id-here UUID=uuid-here none allow-discards<\/code><\/p>\n<p>You need at least <a href=\"https:\/\/admin.fedoraproject.org\/updates\/FEDORA-2012-9847\/dracut-018-78.git20120622.fc17\">dracut-018-78.git20120622.fc17<\/a> for this to work, which you should already have on an up-to-date Fedora 17.<\/p>\n<p>Third, regenerate your initramfs by doing <tt>dracut -f<\/tt>. You may want to take a backup of the old initramfs file in <tt>\/boot<\/tt> but then again, real hackers do not make backups \ud83d\ude09 .<\/p>\n<p>Fourth, reboot and check with <tt>cryptsetup status luks-secret-id-here<\/tt> and <tt>mount<\/tt> that your file systems actually use discard now.<\/p>\n<p><a href=\"http:\/\/www.truecrypt.org\/docs\/?s=trim-operation\">Please note that apparently enabling TRIM on encrypted file systems may reveal unencrypted data.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have not blogged for a while, now that I am on summer holiday and got a new laptop I finally have something to blog about. I got a Thinkpad T430 and installed a Samsung SSD 830 myself. The 830 is not actually the best choice for a Linux user because you can only download [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-147","post","type-post","status-publish","format-standard","hentry","category-fedora"],"_links":{"self":[{"href":"https:\/\/vpv.kapsi.fi\/blog\/wp-json\/wp\/v2\/posts\/147","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vpv.kapsi.fi\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vpv.kapsi.fi\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vpv.kapsi.fi\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vpv.kapsi.fi\/blog\/wp-json\/wp\/v2\/comments?post=147"}],"version-history":[{"count":4,"href":"https:\/\/vpv.kapsi.fi\/blog\/wp-json\/wp\/v2\/posts\/147\/revisions"}],"predecessor-version":[{"id":151,"href":"https:\/\/vpv.kapsi.fi\/blog\/wp-json\/wp\/v2\/posts\/147\/revisions\/151"}],"wp:attachment":[{"href":"https:\/\/vpv.kapsi.fi\/blog\/wp-json\/wp\/v2\/media?parent=147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vpv.kapsi.fi\/blog\/wp-json\/wp\/v2\/categories?post=147"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vpv.kapsi.fi\/blog\/wp-json\/wp\/v2\/tags?post=147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}