{"id":491,"date":"2023-03-16T14:19:25","date_gmt":"2023-03-16T14:19:25","guid":{"rendered":"https:\/\/lasg.dk\/wp\/?p=491"},"modified":"2025-12-23T14:54:29","modified_gmt":"2025-12-23T14:54:29","slug":"file-backed-encrypted-file-system-on-freebsd-6-2","status":"publish","type":"post","link":"https:\/\/lasg.dk\/wp\/file-backed-encrypted-file-system-on-freebsd-6-2\/","title":{"rendered":"File backed encrypted file system on FreeBSD 6.2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Lars Sommer, lasg@lasg.dk, 2008-01-10, Written as a personal note.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is useful when you need an encrypted file system,<br>without modifying the partition table.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Directly based on:<br>http:\/\/www.freebsd.org\/doc\/en_US.ISO8859-1\/books\/handbook\/disks-virtual.html<br>http:\/\/www.freebsd.org\/doc\/en_US.ISO8859-1\/books\/handbook\/disks-encrypting.html<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">Names and paths used<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I&#8217;m making my stuff in a separate folder in my homedir, just for testing<br>purposes. You should think of better places to keep some of these.<br>cryptfile is the big file containing the file system.<br>md0.key is the master encryption key. This is as important as your passphrase,<br>and should be stored securely.<br>mntpoint is the mount point for the encrypted file system.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">First time setup<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Make a 100MB file container:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dd if=\/dev\/random of=cryptfile bs=1k count=100k\n\nmdconfig -a -t vnode -f cryptfile -u 0\nbsdlabel -w md0 auto\n\ndd if=\/dev\/random of=md0.key bs=64 count=1\ngeli init -s 4096 -K md0.key \/dev\/md0\n\ngeli attach -k md0.key \/dev\/md0\ndd if=\/dev\/random of=\/dev\/md0.eli bs=1m\nnewfs \/dev\/md0.eli\nmount \/dev\/md0.eli mntpoint\n\numount mntpoint\ngeli detach md0.eli\n\nmdconfig -d -u 0<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">Daily use, mounting:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mdconfig -a -t vnode -f cryptfile -u 0\ngeli attach -k md0.key \/dev\/md0\nmount \/dev\/md0.eli mntpoint<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">Daily use, unmounting:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>umount mntpoint\ngeli detach md0.eli\nmdconfig -d -u 0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n","protected":false},"excerpt":{"rendered":"<p>Lars Sommer, lasg@lasg.dk, 2008-01-10, Written as a personal note. This is useful when you need an encrypted file system,without modifying the partition table. Directly based on:http:\/\/www.freebsd.org\/doc\/en_US.ISO8859-1\/books\/handbook\/disks-virtual.htmlhttp:\/\/www.freebsd.org\/doc\/en_US.ISO8859-1\/books\/handbook\/disks-encrypting.html Names and paths used I&#8217;m making my stuff in a separate folder in my homedir, just for testingpurposes. You should think of better places to keep some of these.cryptfile is the big file containing the file system.md0.key is the master encryption key. This is as important as your passphrase,and should be stored securely.mntpoint is the mount point for the encrypted file system. First time setup Make a 100MB file container: Daily use, mounting: Daily use, unmounting:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25,41],"tags":[24,45,35],"class_list":["post-491","post","type-post","status-publish","format-standard","hentry","category-computer","category-programmering","tag-computer","tag-freebsd","tag-it-sikkerhed"],"acf":[],"_links":{"self":[{"href":"https:\/\/lasg.dk\/wp\/wp-json\/wp\/v2\/posts\/491","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lasg.dk\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lasg.dk\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lasg.dk\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lasg.dk\/wp\/wp-json\/wp\/v2\/comments?post=491"}],"version-history":[{"count":1,"href":"https:\/\/lasg.dk\/wp\/wp-json\/wp\/v2\/posts\/491\/revisions"}],"predecessor-version":[{"id":492,"href":"https:\/\/lasg.dk\/wp\/wp-json\/wp\/v2\/posts\/491\/revisions\/492"}],"wp:attachment":[{"href":"https:\/\/lasg.dk\/wp\/wp-json\/wp\/v2\/media?parent=491"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lasg.dk\/wp\/wp-json\/wp\/v2\/categories?post=491"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lasg.dk\/wp\/wp-json\/wp\/v2\/tags?post=491"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}