{"id":141,"date":"2023-07-23T19:07:17","date_gmt":"2023-07-23T23:07:17","guid":{"rendered":"https:\/\/triosdevelopers.com\/J.Smith\/rjeffsmith.ca\/wordpress\/?p=141"},"modified":"2024-10-11T09:30:03","modified_gmt":"2024-10-11T13:30:03","slug":"install-cryptsetup-on-linux","status":"publish","type":"post","link":"https:\/\/triosdevelopers.com\/J.Smith\/rjeffsmith.ca\/wordpress\/?p=141","title":{"rendered":"Install cryptsetup on Linux"},"content":{"rendered":"\n<p>In this example, we\u2019ll set up a 16Gb encrypted partition on a separate disk.<\/p>\n\n\n\n<p><strong>Note<\/strong> that this will wipe everything on your partition.<\/p>\n\n\n\n<p>As root, use fdisk to determine which partition you want to use:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># fdisk -l<\/pre>\n\n\n\n<p>You could also use lsblk to show your installed drives:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># lsblk<\/pre>\n\n\n\n<p>In our case, we\u2019re going to encrypt \/dev\/sde1, a 16GB USB stick.<\/p>\n\n\n\n<p>First thing you need to do is to come up with a passphrase that you can remember.<\/p>\n\n\n\n<p>Next, we\u2019ll start the encryption process.<\/p>\n\n\n\n<p>In our case, we want:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># cryptsetup -v luksFormat --type=luks2 \/dev\/sde1<\/pre>\n\n\n\n<p>Pay attention to the prompts.<\/p>\n\n\n\n<p>You can check the man page for more options.<\/p>\n\n\n\n<p>Now let\u2019s open the encrypted volume, and give it a name for mapping the partition:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># cryptsetup open \/dev\/sde1 mypart<\/pre>\n\n\n\n<p>Next, give it a filesystem, using ext4:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># mkfs.ext4 \/dev\/mapper\/mypart<\/pre>\n\n\n\n<p>Now create a mount point:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># mkdir \/mnt\/testenc<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">To mount the encrypted volume, you can use the cryptsetup with the mount command.<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"># cryptsetup --type luks open \/dev\/sde1 mypart<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"># mount -t ext4 \/dev\/mapper\/mypart \/mnt\/testenc<\/pre>\n\n\n\n<p>To close the partition, do the following:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># umount \/place\/to\/mount<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"># cryptsetup close mypart<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In this example, we\u2019ll set up a 16Gb encrypted partition on a separate disk. Note that this will wipe everything on your partition. As root, use fdisk to determine which partition you want to use: # fdisk -l You could also use lsblk to show your installed drives: # lsblk In our case, we\u2019re going [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-141","post","type-post","status-publish","format-standard","hentry","category-file-management"],"_links":{"self":[{"href":"https:\/\/triosdevelopers.com\/J.Smith\/rjeffsmith.ca\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/141","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/triosdevelopers.com\/J.Smith\/rjeffsmith.ca\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/triosdevelopers.com\/J.Smith\/rjeffsmith.ca\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/triosdevelopers.com\/J.Smith\/rjeffsmith.ca\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/triosdevelopers.com\/J.Smith\/rjeffsmith.ca\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=141"}],"version-history":[{"count":1,"href":"https:\/\/triosdevelopers.com\/J.Smith\/rjeffsmith.ca\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/141\/revisions"}],"predecessor-version":[{"id":142,"href":"https:\/\/triosdevelopers.com\/J.Smith\/rjeffsmith.ca\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/141\/revisions\/142"}],"wp:attachment":[{"href":"https:\/\/triosdevelopers.com\/J.Smith\/rjeffsmith.ca\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/triosdevelopers.com\/J.Smith\/rjeffsmith.ca\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/triosdevelopers.com\/J.Smith\/rjeffsmith.ca\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}