paritybit.ca

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit b79051ccc1b2fcf7f99ab7ae76a30b58a144d2b1
parent ee08eadec15c89b4b7a6941310b25251d58bf3d0
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Wed, 15 Jul 2020 15:09:49 -0400

Publish new blog post

Diffstat:
Mpages/blog.md | 1+
Apages/blog/debian-with-btrfs.md | 172+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpages/home.md | 9++++-----
Mpublic/feeds/sitewide-feed.xml | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpublic/sitemap.xml | 1+
5 files changed, 252 insertions(+), 5 deletions(-)

diff --git a/pages/blog.md b/pages/blog.md @@ -27,6 +27,7 @@ href="https://social.paritybit.ca/@jbauer">Mastodon</a>. ### 2020 <ul> + <li>2020-07-14 <a href="blog/debian-with-btrfs">Installing Debian 10 Buster with Encrypted LVM and btrfs Subvolumes</a></li> <li>2020-07-13 <a href="blog/using-rm-with-trash">Using the "rm" Command with Trash</a></li> <li>2020-07-13 <a href="blog/new-desktop-checklist">New Desktop Checklist</a></li> <li>2020-07-12 <a href="blog/new-server-checklist">New Server Checklist</a></li> diff --git a/pages/blog/debian-with-btrfs.md b/pages/blog/debian-with-btrfs.md @@ -0,0 +1,172 @@ +## Installing Debian 10 Buster with Encrypted LVM and btrfs Subvolumes + +[//]: # "How to set up a Debian 10 Buster system with btrfs using subvolumes on your root filesystem during the installation process." + +[//]: # "main.min.css" + +[//]: # + +<div class="byline"> +<b>Written By:</b> Jake Bauer | + <b>Posted:</b> 2020-07-14 | + <b>Last Updated:</b> 2020-07-14 +</div> + +### Introduction + +Debian currently supports formatting partitions with btrfs, but doesn't support +creating subvolumes from within the installer. Below I will detail the process +of getting subvolumes on your root file system with optional LVM encryption, +should you desire. Once you're familiar with this procedure, you will find that +it is actually a lot easier than it seemed at first! + +This procedure has been adapted from this video found on YouTube: <a +href="https://www.youtube.com/watch?v=wtMj8KPRlws">Debian 9 | Installation mit +Btrfs Subvolumes (Debian Wochen)</a> by YouTube user "unicks.eu". This video is +in German but you don't need to understand the language to follow the steps on +screen. This tutorial aims to expand on the content of the video by approaching +it from the perspective of wanting encrypted partitions and it also provides an +English-language reference to the content of the video. + +### Procedure + +After downloading a Debian installation image and putting it on a CD/DVD/USB, +boot it and choose `Advanced options > Expert install` (or `Graphical expert +install` if you want). + +Run through the installation as normal until you reach the section on +partitioning: + +<figure> + <a href="/img/debian-with-btrfs/partition-screen.png"><img + src="/img/debian-with-btrfs/partition-screen.png" alt="The Debian installer + disk partitioning menu"/></a> +</figure> + +On this screen, if you want an encrypted root file system then you probably want +to choose the option `Guided - use entire disk and set up encrypted LVM`. If you +are working with a disk that already has an operating system on it which you +wish to keep or if you have more complicated partitioning needs, you will have +to choose `Manual` and create the partitions necessary for your configuration. + +Once you have run through the setup of the partitions you should now see a +screen similar to the one below: + +<figure> + <a href="/img/debian-with-btrfs/partition-results.png"><img + src="/img/debian-with-btrfs/partition-results.png" alt="The screen showing + the overview of the currently configured partitions and mount points."/></a> +</figure> + +Select your root file system (the one with the `/` as the mount point), change +the `Use as:` field to `btrfs journaling file system` and select `Done setting +up the partition`. After this, select `Finish partitioning and write changes to +disk`, following the prompts until you arrive back in the installation menu. +This will apply the chosen partitioning scheme. + +After this and before continuing with the installation, type `Ctrl`+`Alt`+`F2` +to be put into a shell. Press `Enter` to activate this shell and follow the +following procedure to set up subvolumes: + +<figure> + <a href="/img/debian-with-btrfs/shell.png"><img + src="/img/debian-with-btrfs/shell.png" alt="The busybox terminal on + tty2."/></a> +</figure> + +Use the `df` command to view what the current mounted partitions are. In my case +there is `/dev/mapper/debianbtrfs--vg-root` mounted to `/target` and `/dev/vda1` +mounted to `/target/boot`. `/target` is the place where the Debian system files +will be installed. We need to change and set some things up so that it becomes a +btrfs subvolume. + +<figure> + <a href="/img/debian-with-btrfs/df.png"><img + src="/img/debian-with-btrfs/df.png" alt="The output of the df + command."/></a> +</figure> + +The first step is to unmount both `/target/boot` and then `/target` using the +`umount` command. + +Then, mount the btrfs root volume (i.e. the volume that used to be mounted to +`/target` hereby referred to as `BTRFS_VOLUME`) to `/mnt` and then `cd /mnt`. + +Create the desired subvolumes with `btrfs subvolume create SUBVOLUME_NAME`. I +have created `@`, `@home`, and `@snapshots`. + +Following this, mount the root subvolume to `/target` like so: `mount -o +noatime,compress=lzo,space_cache,subvol=@ BTRFS_VOLUME /target`. + +<p class="note">There are quite a few compression algorithms available for use +with btrfs now; learn more on [the btrfs +wiki](https://btrfs.wiki.kernel.org/index.php/Compression). I personally use +zstd.</p> + +Now we want to `mkdir -p /target/etc` and copy `/mnt/etc/fstab` (and +`/mnt/etc/crypttab` if you are using encrypted LVM volumes) into `/target/etc`. +Once this is done we can `rm -r /mnt/boot /mnt/etc /mnt/media` otherwise these +directories will remain in the final installation (which isn't a big deal but +this is done just for the sake of cleanliness). When this is done, unmount +`/mnt`. + +The next step is to make the necessary subdirectories in `/target` for your +subvolumes. I did: `mkdir -p /target/home /target/.snapshots`. Now, mount the +rest of the subvolumes the same way as before like we did for the root +subvolume. Also, mount the boot partition (which in my case resides on +`/dev/vda1` to `/target/boot/efi` (or just `/target/boot` for a legacy BIOS +system). The following screenshots show the exact commands that I ran: + +<figure> + <a href="/img/debian-with-btrfs/commands-before-boot-mount.png"><img + src="/img/debian-with-btrfs/commands-before-boot-mount.png" alt="All of the + commands run as described above (minus mounting boot)."/></a> +</figure> + +<figure> + <a href="/img/debian-with-btrfs/boot-mount.png"><img + src="/img/debian-with-btrfs/boot-mount.png" alt="The commands run to mount + the boot partition."/></a> +</figure> + +Now, edit `/target/etc/fstab` (you must use `nano` as unfortunately there is no +version of `vi` in this busybox configuration) and add the relevant +entries to mount your subvolumes on boot. These should look the same as the +entry that already exists but you will have to change the options from `default` +to the ones that we used above when mounting our subvolumes and you will have to +change the mount points. For example, the line for mounting the root filesystem +will go from: + +``` +/dev/mapper/debianbtrfs--vg-root / btrfs defaults 0 0 +``` + +to: + +``` +/dev/mapper/debianbtrfs--vg-root / btrfs noatime,compress=lzo,space_cache,subvol=@ 0 0 +``` + +Where the other lines will look similar: + +<figure> + <a href="/img/debian-with-btrfs/target-fstab.png"><img + src="/img/debian-with-btrfs/target-fstab.png" alt="The contents of the + /target/etc/fstab file after modification."/></a> +</figure> + +Once this is all done and you have saved your changes, you may exit out of this +terminal (`Ctrl`+`D`) and return to the installation (`Ctrl`+`Alt`+`F1`). +Proceed with the installation as normal and, when you boot, you should have a +btrfs filesystem working with subvolumes! + +If you get stuck somewhere, try asking in the many helpful areas of the Internet +such as the <a href="http://forums.debian.net/">Debian User Forums</a>, the +`#debian` IRC channel on the Freenode network, or the `debian-user` mailing +list. See this resource for <a href="https://www.debian.org/support">more +information on getting help with Debian.</a> + +_This is my seventy-first post for the +[#100DaysToOffload](https://social.paritybit.ca/tags/100DaysToOffload) +challenge. You can learn more about this challenge over at +[https://100daystooffload.com](https://100daystooffload.com)._ diff --git a/pages/home.md b/pages/home.md @@ -11,14 +11,15 @@ server](https://git.paritybit.ca) and a [file sharing server](https://ftp.paritybit.ca). You can also find me on <a rel="me" href="https://social.paritybit.ca/@jbauer">my Mastodon instance</a>. -This site will soon be available over Gopher and Gemini. +This site will soon™️ be available over Gopher and Gemini. <div class="feed-wrapper"> <h3 class="feed-title">What's New:</h3> <a class="rss-icon" href="/feeds/sitewide-feed.xml"> <img - src="/img/feed-icon.png" width="15" height="15" alt="Click for RSS Feed"/> - </a> + src="/img/feed-icon.png" width="15" height="15" alt="Click for RSS Feed"/> </a> </div> +2020-07-14 <a class="feed-item" href="blog/debian-with-btrfs">Installing Debian 10 Buster with Encrypted LVM and btrfs Subvolumes</a> + 2020-07-13 <a class="feed-item" href="blog/using-rm-with-trash">Using the "rm" Command with Trash</a> 2020-07-13 <a class="feed-item" href="blog/new-desktop-checklist">New Desktop Checklist</a> @@ -36,8 +37,6 @@ This site will soon be available over Gopher and Gemini. 2020-07-07 <a class="feed-item" href="blog/are-todo-applications-a-waste-of-time">Are TODO Applications a Waste of Time?</a> 2020-07-06 <a class="feed-item" href="blog/improving-blog-searching">Improving Blog Searching</a> - -2020-07-05 <a class="feed-item" href="blog/switching-to-cgit">Switching to cgit</a> ### What is a Parity Bit? It is a bit (in the 1's and 0's sense) used in checking for errors in digital diff --git a/public/feeds/sitewide-feed.xml b/public/feeds/sitewide-feed.xml @@ -7,6 +7,80 @@ <description>The feed that covers all notable additions, updates, announcements, and other changes for the entire paritybit.ca website.</description> <item> + <title>Installing Debian 10 Buster with Encrypted LVM and btrfs Subvolumes</title> + <link>https://www.paritybit.ca/blog/debian-with-btrfs</link> + <guid>https://www.paritybit.ca/blog/debian-with-btrfs</guid> + <pubDate>Tue, 14 Jul 2020 00:00:09 -0400</pubDate> + <description><![CDATA[<h2 id="installing-debian-10-buster-with-encrypted-lvm-and-btrfs-subvolumes">Installing Debian 10 Buster with Encrypted LVM and btrfs Subvolumes</h2> +<div class="byline"> +<p><b>Written By:</b> Jake Bauer | <b>Posted:</b> 2020-07-14 | <b>Last Updated:</b> 2020-07-14</p> +</div> +<h3 id="introduction">Introduction</h3> +<p>Debian currently supports formatting partitions with btrfs, but doesn’t support creating subvolumes from within the installer. Below I will detail the process of getting subvolumes on your root file system with optional LVM encryption, should you desire. Once you’re familiar with this procedure, you will find that it is actually a lot easier than it seemed at first!</p> +<p>This procedure has been adapted from this video found on YouTube: <a +href="https://www.youtube.com/watch?v=wtMj8KPRlws">Debian 9 | Installation mit Btrfs Subvolumes (Debian Wochen)</a> by YouTube user “unicks.eu”. This video is in German but you don’t need to understand the language to follow the steps on screen. This tutorial aims to expand on the content of the video by approaching it from the perspective of wanting encrypted partitions and it also provides an English-language reference to the content of the video.</p> +<h3 id="procedure">Procedure</h3> +<p>After downloading a Debian installation image and putting it on a CD/DVD/USB, boot it and choose <code>Advanced options &gt; Expert install</code> (or <code>Graphical expert install</code> if you want).</p> +<p>Run through the installation as normal until you reach the section on partitioning:</p> +<figure> +<a href="/img/debian-with-btrfs/partition-screen.png"><img + src="/img/debian-with-btrfs/partition-screen.png" alt="The Debian installer + disk partitioning menu"/></a> +</figure> +<p>On this screen, if you want an encrypted root file system then you probably want to choose the option <code>Guided - use entire disk and set up encrypted LVM</code>. If you are working with a disk that already has an operating system on it which you wish to keep or if you have more complicated partitioning needs, you will have to choose <code>Manual</code> and create the partitions necessary for your configuration.</p> +<p>Once you have run through the setup of the partitions you should now see a screen similar to the one below:</p> +<figure> +<a href="/img/debian-with-btrfs/partition-results.png"><img + src="/img/debian-with-btrfs/partition-results.png" alt="The screen showing + the overview of the currently configured partitions and mount points."/></a> +</figure> +<p>Select your root file system (the one with the <code>/</code> as the mount point), change the <code>Use as:</code> field to <code>btrfs journaling file system</code> and select <code>Done setting up the partition</code>. After this, select <code>Finish partitioning and write changes to disk</code>, following the prompts until you arrive back in the installation menu. This will apply the chosen partitioning scheme.</p> +<p>After this and before continuing with the installation, type <code>Ctrl</code>+<code>Alt</code>+<code>F2</code> to be put into a shell. Press <code>Enter</code> to activate this shell and follow the following procedure to set up subvolumes:</p> +<figure> +<a href="/img/debian-with-btrfs/shell.png"><img + src="/img/debian-with-btrfs/shell.png" alt="The busybox terminal on + tty2."/></a> +</figure> +<p>Use the <code>df</code> command to view what the current mounted partitions are. In my case there is <code>/dev/mapper/debianbtrfs--vg-root</code> mounted to <code>/target</code> and <code>/dev/vda1</code> mounted to <code>/target/boot</code>. <code>/target</code> is the place where the Debian system files will be installed. We need to change and set some things up so that it becomes a btrfs subvolume.</p> +<figure> +<a href="/img/debian-with-btrfs/df.png"><img + src="/img/debian-with-btrfs/df.png" alt="The output of the df + command."/></a> +</figure> +<p>The first step is to unmount both <code>/target/boot</code> and then <code>/target</code> using the <code>umount</code> command.</p> +<p>Then, mount the btrfs root volume (i.e. the volume that used to be mounted to <code>/target</code> hereby referred to as <code>BTRFS_VOLUME</code>) to <code>/mnt</code> and then <code>cd /mnt</code>.</p> +<p>Create the desired subvolumes with <code>btrfs subvolume create SUBVOLUME_NAME</code>. I have created <code>@</code>, <code>@home</code>, and <code>@snapshots</code>.</p> +<p>Following this, mount the root subvolume to <code>/target</code> like so: <code>mount -o noatime,compress=lzo,space_cache,subvol=@ BTRFS_VOLUME /target</code>.</p> +<p class="note"> +There are quite a few compression algorithms available for use with btrfs now; learn more on <a href="https://btrfs.wiki.kernel.org/index.php/Compression">the btrfs wiki</a>. I personally use zstd. +</p> +<p>Now we want to <code>mkdir -p /target/etc</code> and copy <code>/mnt/etc/fstab</code> (and <code>/mnt/etc/crypttab</code> if you are using encrypted LVM volumes) into <code>/target/etc</code>. Once this is done we can <code>rm -r /mnt/boot /mnt/etc /mnt/media</code> otherwise these directories will remain in the final installation (which isn’t a big deal but this is done just for the sake of cleanliness). When this is done, unmount <code>/mnt</code>.</p> +<p>The next step is to make the necessary subdirectories in <code>/target</code> for your subvolumes. I did: <code>mkdir -p /target/home /target/.snapshots</code>. Now, mount the rest of the subvolumes the same way as before like we did for the root subvolume. Also, mount the boot partition (which in my case resides on <code>/dev/vda1</code> to <code>/target/boot/efi</code> (or just <code>/target/boot</code> for a legacy BIOS system). The following screenshots show the exact commands that I ran:</p> +<figure> +<a href="/img/debian-with-btrfs/commands-before-boot-mount.png"><img + src="/img/debian-with-btrfs/commands-before-boot-mount.png" alt="All of the + commands run as described above (minus mounting boot)."/></a> +</figure> +<figure> +<a href="/img/debian-with-btrfs/boot-mount.png"><img + src="/img/debian-with-btrfs/boot-mount.png" alt="The commands run to mount + the boot partition."/></a> +</figure> +<p>Now, edit <code>/target/etc/fstab</code> (you must use <code>nano</code> as unfortunately there is no version of <code>vi</code> in this busybox configuration) and add the relevant entries to mount your subvolumes on boot. These should look the same as the entry that already exists but you will have to change the options from <code>default</code> to the ones that we used above when mounting our subvolumes and you will have to change the mount points. For example, the line for mounting the root filesystem will go from:</p> +<pre><code>/dev/mapper/debianbtrfs--vg-root / btrfs defaults 0 0</code></pre> +<p>to:</p> +<pre><code>/dev/mapper/debianbtrfs--vg-root / btrfs noatime,compress=lzo,space_cache,subvol=@ 0 0</code></pre> +<p>Where the other lines will look similar:</p> +<figure> +<a href="/img/debian-with-btrfs/target-fstab.png"><img + src="/img/debian-with-btrfs/target-fstab.png" alt="The contents of the + /target/etc/fstab file after modification."/></a> +</figure> +<p>Once this is all done and you have saved your changes, you may exit out of this terminal (<code>Ctrl</code>+<code>D</code>) and return to the installation (<code>Ctrl</code>+<code>Alt</code>+<code>F1</code>). Proceed with the installation as normal and, when you boot, you should have a btrfs filesystem working with subvolumes!</p> +<p>If you get stuck somewhere, try asking in the many helpful areas of the Internet such as the <a href="http://forums.debian.net/">Debian User Forums</a>, the <code>#debian</code> IRC channel on the Freenode network, or the <code>debian-user</code> mailing list. See this resource for <a href="https://www.debian.org/support">more information on getting help with Debian.</a></p> +<p><em>This is my seventy-first post for the <a href="https://social.paritybit.ca/tags/100DaysToOffload">#100DaysToOffload</a> challenge. You can learn more about this challenge over at <a href="https://100daystooffload.com">https://100daystooffload.com</a>.</em></p>]]></description> + </item> +<item> <title>Using the "rm" Command with Trash</title> <link>https://www.paritybit.ca/blog/using-rm-with-trash</link> <guid>https://www.paritybit.ca/blog/using-rm-with-trash</guid> diff --git a/public/sitemap.xml b/public/sitemap.xml @@ -3,6 +3,7 @@ <url><loc>https://www.paritybit.ca</loc></url> <url><loc>https://www.paritybit.ca/home</loc></url> <url><loc>https://www.paritybit.ca/blog</loc></url> + <url><loc>https://www.paritybit.ca/blog/debian-with-btrfs</loc></url> <url><loc>https://www.paritybit.ca/blog/using-rm-with-trash</loc></url> <url><loc>https://www.paritybit.ca/blog/new-desktop-checklist</loc></url> <url><loc>https://www.paritybit.ca/blog/new-server-checklist</loc></url>