{"id":146,"date":"2008-03-05T11:18:15","date_gmt":"2008-03-05T19:18:15","guid":{"rendered":"http:\/\/www.outflux.net\/blog\/archives\/2008\/03\/05\/swapping-encryption-hurting-your-head\/"},"modified":"2008-12-02T13:05:19","modified_gmt":"2008-12-02T21:05:19","slug":"swapping-encryption-hurting-your-head","status":"publish","type":"post","link":"https:\/\/outflux.net\/blog\/archives\/2008\/03\/05\/swapping-encryption-hurting-your-head\/","title":{"rendered":"swapping encryption, hurting your head"},"content":{"rendered":"<p>Last week <a href=\"http:\/\/warma.dk\/blog\/\">Soren<\/a> helped me move my manually cryptsetup&#8217;d swap partition into the initramfs logic so that I could hibernate.  Bottom line was:<\/p>\n<ol>\n<li>Create <code>\/etc\/initramfs-tools\/conf.d\/cryptroot<\/code> for your partition, based on the logic and defaults in <code>\/usr\/share\/initramfs-tools\/scripts\/local-top\/cryptroot<\/code>.<\/li>\n<li>Convert the existing encrypted swap to the new configuration.<\/li>\n<li>Update initrd, reboot, enjoy.<\/li>\n<\/ol>\n<p>Assuming your swap partition (in encrypted form) is stored at \/dev\/laptopvg\/swaprawlv, and you want your accessible swap partition as \/dev\/mapper\/swap, here are the above steps in detail:<\/p>\n<p>Doing step 1 is simple, we&#8217;re assuming the defaults from the cryptroot script above:<\/p>\n<ul>\n<pre>\r\necho source=\/dev\/laptopvg\/swaprawlv target=swap > \/etc\/initramfs-tools\/conf.d\/cryptroot\r\n<\/pre>\n<\/ul>\n<p>Step 2 hurt my head.  Make sure you&#8217;ve unmounted your swap before attempting this, or you can destroy the partition contents.  The parameters come from the cryptroot script again:<\/p>\n<ul>\n<pre>\r\nswapoff \/dev\/mapper\/swap\r\nvol_id \/dev\/mapper\/swap\r\ncryptsetup -c aes-cbc-essiv:sha256 -h sha256 -s 256 create swap2 \/dev\/laptopvg\/swaprawlv\r\ndd if=\/dev\/mapper\/swap of=\/dev\/mapper\/swap2 bs=4k\r\ncryptsetup remove swap\r\nvol_id \/dev\/mapper\/swap2\r\n<\/pre>\n<\/ul>\n<p>Step 3 is simple again:<\/p>\n<ul>\n<pre>\r\nupdate-initramfs -u\r\nshutdown -r now\r\n<\/pre>\n<\/ul>\n<p>Ta-da!<\/p>\n<p style='text-align:left'>&copy; 2008, <a href=\"https:\/\/outflux.net\/blog\/\">Kees Cook<\/a>. This work is licensed under a <a rel=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/\">Creative Commons Attribution-ShareAlike 4.0 License<\/a>.<br \/><a rel=\"license\" href=\"http:\/\/creativecommons.org\/licenses\/by-sa\/4.0\/\"><img decoding=\"async\" alt=\"CC BY-SA 4.0\" style=\"border-width:0\" src=\"https:\/\/i.creativecommons.org\/l\/by-sa\/4.0\/88x31.png\" \/><\/a> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last week Soren helped me move my manually cryptsetup&#8217;d swap partition into the initramfs logic so that I could hibernate. Bottom line was: Create \/etc\/initramfs-tools\/conf.d\/cryptroot for your partition, based on the logic and defaults in \/usr\/share\/initramfs-tools\/scripts\/local-top\/cryptroot. Convert the existing encrypted swap to the new configuration. Update initrd, reboot, enjoy. Assuming your swap partition (in encrypted [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,14],"tags":[],"_links":{"self":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts\/146"}],"collection":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/comments?post=146"}],"version-history":[{"count":0,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/posts\/146\/revisions"}],"wp:attachment":[{"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/media?parent=146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/categories?post=146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/outflux.net\/blog\/wp-json\/wp\/v2\/tags?post=146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}