7374756666

Optional home mount on Debian 11 bullseye

This is one of those weird edge cases that probably few people will ever encounter.

The Problem

In a probably over complicated attempt at simplifying my working life I wanted to have a laptop that:

  1. Can be used as a thin client to my main machine.
  2. Contains very little important data (in case of loss/theft).
  3. Can replace my main machine if it craps out.

This would reduce my setup from a 3 machine setup to a 2 machine, and since the machine I use as a backup to my primary is ageing it's probably a good idea.

The solution

The laptop is already configured as a thin client, but has only a small hard drive and the data needs to not be on the laptop anyway.

So I decided to see if I can have an optional /home/user directory which is on an encrypted external drive. Note this drive is a SSD external drive mounted using USB 3.1 (Gen 1) so up to 5Gbps. Though initial testing was done with a USB 3 HDD which performed admirably, the SSD will be more compact, performant and less prone to failure due to dropping it.

The answer is yes you can but it requires some tweaking.

The process

Step 1

Create a luks encrypted drive

Step 2

Edit /etc/crypttab make sure to add the nofail option so it doesn't kill the boot process if it's not attached like this:

crypt_user UUID=da0c26e9-78d8-4e21-9664-54037bab45c3 none luks,discard,initramfs,nofail,x-systemd.device-timeout=1s

Step 3

Format the drive and configure it in /etc/fstab something like this /dev/mapper/crypt_user /home/user ext4 nofail,x-systemd.device-timeout=1s 0 2

Step 4

Install dbus-x11 this wasn't installed for some reason and would cause the KDE login to hang without it.

With the above in place I can have my cake and eat it. I now have a portable thin client that can also act as an emergency replacement for my main machine.

References:

https://wiki.archlinux.org/title/Fstab#Automount_with_systemd