paritybit.ca

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

commit fe7e6c6ffa53105cc183368b383658a1787d8979
parent 6fb7956f8c86137951123b7ebb74d2dc00b56670
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Wed, 17 Jul 2019 20:30:57 -0400

Add article about installing debian with btrfs

Diffstat:
M.gitignore | 1+
Mbuild/base.css | 22+++++++++++++++++++---
Mpages/guides.md | 18++++++++----------
Apages/guides/debian-with-btrfs.md | 154+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpages/home.md | 6+++++-
5 files changed, 187 insertions(+), 14 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -3,4 +3,5 @@ build/*/ public/html/** public/css/** public/share/** +public/img/** *.swp diff --git a/build/base.css b/build/base.css @@ -43,9 +43,10 @@ pre { } code { - font-size: 15px; - background-color: #b2b2b2; - color: #3a3a3a; + font-size: 14px; + padding: 1px 4px; + background-color: #424242; + color: #eaeaea; } input { @@ -83,6 +84,21 @@ ul.inline { margin: 0; } +kbd { + background-color: #b4b4b4; + border-radius: 3px; + border: 1px solid #b4b4b4; + box-shadow: 0 1px 1px rgba(0, 0, 0, .2), 0 2px 0 0 rgba(180, 180, 180, .7) inset; + color: #333; + display: inline-block; + font-size: 1em; + font-weight: 700; + line-height: 1; + padding: 2px 4px; + text-indent: 0px; + white-space: nowrap; +} + .center { text-align: center; } diff --git a/pages/guides.md b/pages/guides.md @@ -1,17 +1,15 @@ ## Guides -[//]: # "Guides on configuring various services and programs, little tips and tricks, and more." +[//]: # "Guides on configuring various services and programs, little tips and tricks, and more!" [//]: # "base.min.css" -There aren't any guides posted here yet but they are coming soon! +Below you can find guides on configuring various services and programs, little +tips and tricks I've learned, and more! -I am planning to post: +<ul> + <li><a href="guides/debian-with-btrfs">Installing Debian 10 Buster with + Encrypted LVM and btrfs Subvolumes</a></li> +</ul> -* A guide to configuring a fresh Debian installation the way I have done. -* A guide to generating SSH Keys. -* An outline of the steps I took to secure my online life. -* A (hopefully simple) guide to managing GPG Keys. -* A guide to my server configurations, realistic hardening steps, and other - similar topics. -* And more! +More guides are coming soon! diff --git a/pages/guides/debian-with-btrfs.md b/pages/guides/debian-with-btrfs.md @@ -0,0 +1,154 @@ +## Installing Debian 10 Buster with Encrypted LVM and btrfs Subvolumes + +[//]: # "One thing that some people may want to try is installing Debian using btrfs as their primary file system. Debian currently supports formatting partitions with btrfs, but doesn't support creating subvolumes from within the installer. This tutorial will tell you how to set up a Debian 10 Buster system with btrfs using subvolumes on your root filesystem from within the installer. I will also cover how to do this with LVM encrypted volumes." + +[//]: # "base.min.css" + +<b>Written By:</b> Jake Bauer | + <b>Posted:</b> 2019-07-16 | + <b>Last Updated:</b> 2019-07-16 + +### Introduction + +<b>Difficulty:</b> Intermediate + +With the arrival of Debian Buster, many people will be re-installing their +systems to try out some of the new features and configurations. One thing that +some people may want to try is installing Debian using btrfs as their primary +file system. Debian currently supports formatting partitions with btrfs, but +doesn't support creating subvolumes from within the installer. This tutorial +will tell you how to set up a Debian 10 Buster system with btrfs using +subvolumes on your root filesystem from within the installer. I will also cover +how to do this with LVM encrypted volumes. + +Once you've got the hang of this procedure, you will find that it is actually a +lot easier than it seems (assuming some stuff doesn't break)! + +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 + +The first step is to get a copy of <a href="https://www.debian.org/distrib/">the +Debian operating system</a>. Get any of the images that aren't a "live" image +since these live images don't let you enter into Expert install mode. I prefer +the netinstall image since it is a small initial download and I can pull in +whichever packages I need using the internet (my connection is reliable and fast +enough to support this). + +After downloading the image and putting it on a CD/DVD/USB, boot this image 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: + +<img src="/img/debian-with-btrfs/partition-screen.png" alt="The Debian installer +partition menu showing 3 guided options and 1 manual option"/> + +On this screen, if you want an encrypted root file system (recommended) then +choose the option `Guided - use entire disk and set up encrypted LVM`. Otherwise +choose the first option. 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: + +<img src="/img/debian-with-btrfs/partition-results.png" alt="The screen showing +the overview of your currently configured partitions and mount points step."/> + +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 <kbd>Ctrl</kbd> + +<kbd>Alt</kbd> + <kbd>F2</kbd> to be put into a shell. Press <kbd>Enter</kbd> +to activate this shell and follow the following procedure to set up subvolumes: + +<img src="/img/debian-with-btrfs/shell.png" alt="The busybox terminal on tty2."/> + +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 thing up so that it becomes a +btrfs subvolume. + +<img src="/img/debian-with-btrfs/df.png" alt="The output of the df command."/> + +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 your desired subvolumes with `btrfs subvolume create SUBVOLUME_NAME`. I +have created `@`, `@home`, and `@snapshots`. + +Following this, `cd` back out of `/mnt` and unmount it. Then mount the root +subvolume to `/target` like so: `mount -o +noatime,compress=lzo,space_cache,subvol=@ BTRFS_VOLUME /target`. Then remount +this `BTRFS_VOLUME` to `/mnt` and `cd` into it again. + +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 your final installation (which isn't a big deal but +this is done just for the sake of cleanliness). When this is done, unmount +`/mnt` again. + +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: + +<img src="/img/debian-with-btrfs/commands-before-boot-mount.png" alt="All of the commands run as described above (minus mounting boot)."/> + +<img src="/img/debian-with-btrfs/boot-mount.png" alt="The commands run to mount +the boot partition."/> + +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: + +<img src="/img/debian-with-btrfs/target-fstab.png" alt="The contents of the +/target/etc/fstab file after modification."/> + +Once this is all done and you have saved your changes, you may exit out of this +terminal (<kbd>Ctrl</kbd> + <kbd>d</kbd>) and return to the installation +(<kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>F1</kbd>). Proceed with the +installation as normal and, when you boot, you should have a btrfs filesystem +working with subvolumes! + +As always, you can leave me feedback—positive or negative—using the feedback +email listed down below. Let me know if this procedure worked for you and if you +have any ways that it can be optimized or if I've made any mistakes. Just +remember that I cannot be available to act as tech support so if you do 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> diff --git a/pages/home.md b/pages/home.md @@ -15,10 +15,14 @@ be something that interests you! ### Recently Updated +<a href="guides/debian-with-btrfs">New Guide: Installing Debian 10 Buster with +Encrypted LVM and btrfs Subvolumes</a> + <a href="blog/qutebrowser-to-firefox">New Blog Post: Why I Switched Back to Firefox from Qutebrowser</a> -<a href="projects/dnd/initiative">The D&D Initiative Tracker has just been released!</a> +<a href="projects/dnd/initiative">The D&D Initiative Tracker has just been +released!</a> <a href="projects/dnd/roll">The D&D Dice Roller has been updated!</a>