{"id":594,"date":"2011-11-30T21:56:51","date_gmt":"2011-11-30T20:56:51","guid":{"rendered":"https:\/\/www.hutsky.cz\/blog\/?p=594"},"modified":"2014-01-09T22:23:37","modified_gmt":"2014-01-09T21:23:37","slug":"encrypt-partition-with-dm-crypt","status":"publish","type":"post","link":"https:\/\/www.hutsky.cz\/blog\/2011\/11\/encrypt-partition-with-dm-crypt\/","title":{"rendered":"Encrypt partition with dm-crypt"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-808\" title=\"images\" alt=\"\" src=\"https:\/\/www.hutsky.cz\/blog\/wp-content\/uploads\/images.jpeg\" width=\"264\" height=\"89\" \/>Ever wnated to have your external disk or USB stick encrypted? This is a way to get there on a Debian-based system using dm-crypt and LUKS.<\/p>\n<p>First, make sure dm-crypt module is loaded (see if \/dev\/mapper\/ is present), and if not, load the module:<\/p>\n<pre>modprobe dm-crypt<\/pre>\n<p>Now you can use <em>cryptsetup<\/em> to encrypt your device (you&#8217;ll be asked for a password):<\/p>\n<pre>cryptsetup --verbose --key-size 256 --verify-passphrase luksFormat \/dev\/sdb1<\/pre>\n<p>After this step, you can open the encrypted disk.<\/p>\n<pre>cryptsetup luksOpen \/dev\/sdb1 mydisk<\/pre>\n<p>The disk is not ready yet, we need to format it first, just as if we connected an empty device. In theis example, I&#8217;ll format it using <em>ext3<\/em> file system.<\/p>\n<pre>mkfs.ext3 -j -m 1 -O dir_index,filetype \/dev\/mapper\/mydisk<\/pre>\n<p>Now you can finally mount and access your disk.<\/p>\n<pre>mount -t ext3 \/dev\/mapper\/mydisk \/media\/mydisk<\/pre>\n<p>When you&#8217;re done and want to unplug the device, you unmount it the usual way:<\/p>\n<pre>umount \/dev\/mapper\/mydisk<\/pre>\n<p>and then use LUKS to close the encrypted connection:<\/p>\n<pre> cryptsetup luksClose mydisk<\/pre>\n<p>Now you can remove the device.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ever wnated to have your external disk or USB stick encrypted? This is a way to get there on a Debian-based system using dm-crypt and LUKS. First, make sure dm-crypt module is loaded (see if \/dev\/mapper\/ is present), and if &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.hutsky.cz\/blog\/2011\/11\/encrypt-partition-with-dm-crypt\/\"> <span class=\"screen-reader-text\">Encrypt partition with dm-crypt<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[10,18],"class_list":["post-594","post","type-post","status-publish","format-standard","hentry","category-operatingsystems","tag-debian","tag-linux"],"_links":{"self":[{"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/posts\/594","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/comments?post=594"}],"version-history":[{"count":13,"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/posts\/594\/revisions"}],"predecessor-version":[{"id":1002,"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/posts\/594\/revisions\/1002"}],"wp:attachment":[{"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/media?parent=594"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/categories?post=594"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hutsky.cz\/blog\/wp-json\/wp\/v2\/tags?post=594"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}