Skip to content

Instantly share code, notes, and snippets.

@Nikongen
Last active August 1, 2025 22:38
Show Gist options
  • Select an option

  • Save Nikongen/c094f8fcb959f92b221de4665101f6a7 to your computer and use it in GitHub Desktop.

Select an option

Save Nikongen/c094f8fcb959f92b221de4665101f6a7 to your computer and use it in GitHub Desktop.
Multiboot using Btrfs + luks

General Notes

Prerequisites

Planing a Dual boot setup on luks encrypted btrfs partition

  • subvolume for data @data
  • subvolume for each distro
  • 100Gb spare to use for installing new distros, e.g. temp root, and boot partiotions

Enabling btrfs featuers

  • sudo systemctl enable fstrim.timer
  • Use apt snapshotting (is there a tui for this?)
  • Shedule snapshots of @home and @currentRoot

Just sharing my notes on how to install PopOS 22.04 on a luks encrypted btrfs subvolume

Resources

Prerequisites

  • Using UEFI + systemd boot
  • sudo -i
  • /dev/nvme1n1p3 is the encrypted btrfs partition
    • blkid -s UUID -o value /dev/nvme1n1p3 >> 9726cdf3-67e4-4abc-a36b-1f6291ee1c92
    • cryptsetup luksOpen /dev/nvme1n1p3 cryptdata
    • subvolumes: @, @popos, @data, ...
  • /dev/mapper/cryptdata after unlocking
    • blkid -s UUID -o value /dev/mapper/cryptdata >> 83884a40-c54e-4029-bd99-522e9e6bb0fe
  • Need some empty spave on disk or spare disk to install popos to

Install PopOs

  • Advanced install
  • Format -/dev/nvme1n1p1 as ext4 / -/dev/nvme1n1p4as fat32 /boot/efi -/dev/nvme1n1p2as swap
  • Do not reboot
  • Quit installer in dock

Move files to btrfs subvolume

  • mkdir /mnt-pop
  • mount /dev/nvme1n1p1 /mnt-pop
  • mount -o subvol=@popos,defaults,compress=zstd:1,discard=async /dev/mapper/cryptdata /mnt
  • rsync -aAXv /mnt-pop/ /mnt/

Adapt files to new root fs

Note

Work inside new root fs, hence under /mnt/

Caution

Only change lines belonging to root fs e.g. dont change boot, (crypt)swap or else

Tip

Remove lines "quiet", "splash", and set loglevel=7, for debugging.

Note

Changed systemd.show_status=auto to only suppress successful messages, as in case of errors you can still see them (see ArchWiki).

/etc/fstab resp. /mnt/etc/fstab

  • Use UUID of /dev/mapper/cryptdata
  • Prepare to mount data subvol, configure this after confirmed system boots
# <file system>                                <mount point>  <type>  <options>                                         <dump> <pass>
UUID=118bdd09-4160-4d90-a733-8bcb4f388950      /              ext4    noatime,errors=remount-ro                            0     1
/dev/mapper/cryptswap                          none           swap    defaults                                             0     0
PARTUUID=77b720ea-b60a-4577-9845-d4164fc12bd7  /boot/efi      vfat    umask=0077                                           0     0
UUID=83884a40-c54e-4029-bd99-522e9e6bb0fe      /              btrfs   defaults,subvol=@popos,compress=zstd:1,discard=async 0     0
# UUID=83884a40-c54e-4029-bd99-522e9e6bb0fe    /home/.../data btrfs   defaults,subvol=@data,compress=zstd:1,discard=async    0     0

/etc/crypttab resp. /mnt/etc/crypttab

Use UUID of /dev/nvme1n1p3

cryptdata UUID=9726cdf3-67e4-4abc-a36b-1f6291ee1c92 none luks,discard
cryptswap UUID=3a10b48b-1bb4-407d-bb18-baaf9dceb3d7 /dev/urandom swap,plain,offset=1024,cipher=aes-xts-plain64,size=512

/etc/kernelstub/configuration resp.

Important

Mind commas, e.g. after "splash",.

{
  "default": {
    "kernel_options": [
      "quiet",
      "splash"
    ],
    "esp_path": "/boot/efi",
    "setup_loader": false,
    "manage_mode": false,
    "force_update": false,
    "live_mode": false,
    "config_rev": 3
  },
  "user": {
    "kernel_options": [
      "quiet",
      "loglevel=0",
      "systemd.show_status=auto",
      "splash",
      "rootflags=subvol=@popos"
    ],
    "esp_path": "/boot/efi",
    "setup_loader": true,
    "manage_mode": true,
    "force_update": false,
    "live_mode": false,
    "config_rev": 3
  }
}

Adjust configuration of systemd bootloader

  • mount /dev/nvme1n1p4 /mnt/boot/efi/

/boot/efi/loader/entries/Pop_OS-current.conf resp. /mnt/boot/efi/loader/entries/Pop_OS-current.conf

  • Use UUID of /dev/mapper/cryptdata
title Pop!_OS 22.04
linux /EFI/Pop_OS-83884a40-c54e-4029-bd99-522e9e6bb0fe/vmlinuz.efi
initrd /EFI/Pop_OS-83884a40-c54e-4029-bd99-522e9e6bb0fe/initrd.img
options root=UUID=83884a40-c54e-4029-bd99-522e9e6bb0fe ro quiet loglevel=0 systemd.show_status=auto splash rootflags=subvol=@popos
  • Optional: Add timeout to boot menu
echo "timeout 3" >> /mnt/boot/efi/loader/loader.conf
cat /mnt/boot/efi/loader/loader.conf 
>>>default Pop_OS-current
>>>timeout 3

Chroot and update initramfs

  • From Pop OS repair bootloader manual
  • Adapted to my paths and added creation of missing folders
  • As I installed pop os without disk encryption first some modules are missing. Fixing this with package upgrade rn
for i in dev dev/pts proc sys run; do mkdir -p /mnt/$i && mount -R /$i /mnt/$i; done
chroot /mnt
apt install --reinstall linux-image-generic linux-headers-generic cryptsetup-initramfs btrfs-progs
apt update && apt upgrade -y
update-initramfs -c -k all
  • Output looks like
update-initramfs: Generating /boot/initrd.img-6.12.10-76061203-generic
W: /sbin/fsck.btrfs doesn't exist, can't install to initramfs
kernelstub.Config    : INFO     Looking for configuration...
kernelstub           : INFO     System information: 

    OS:..................Pop!_OS 22.04
    Root partition:....../dev/dm-1
    Root FS UUID:........83884a40-c54e-4029-bd99-522e9e6bb0fe
    ESP Path:............/boot/efi
    ESP Partition:......./dev/nvme1n1p4
    ESP Partition #:.....4
    NVRAM entry #:.......-1
    Boot Variable #:.....0000
    Kernel Boot Options:.quiet loglevel=0 systemd.show_status=false splash rootflags=subvol=@popos
    Kernel Image Path:.../boot/vmlinuz-6.12.10-76061203-generic
    Initrd Image Path:.../boot/initrd.img-6.12.10-76061203-generic
    Force-overwrite:.....False

kernelstub.Installer : INFO     Copying Kernel into ESP
kernelstub.Installer : INFO     Copying initrd.img into ESP
kernelstub.Installer : INFO     Setting up loader.conf configuration
kernelstub.Installer : INFO     Making entry file for Pop!_OS
kernelstub.Installer : INFO     Backing up old kernel
kernelstub.Installer : INFO     No old kernel found, skipping
  • exit chroot enviroment Ctrl+D or exit
  • Only if not done already: Install bootloader bootctl --path=/mnt/boot/efi install
bootctl --path=/mnt/boot/efi install
>>>Copied "/usr/lib/systemd/boot/efi/systemd-bootx64.efi" to "/mnt/boot/efi/EFI/systemd/systemd-bootx64.efi".
>>>Copied "/usr/lib/systemd/boot/efi/systemd-bootx64.efi" to "/mnt/boot/efi/EFI/BOOT/BOOTX64.EFI".
>>>Created "/mnt/boot/efi/06cb15fbd23d0aadd477e941686590a9".
>>>Random seed file /mnt/boot/efi/loader/random-seed successfully written (512 bytes).
>>>Created EFI boot entry "Linux Boot Manager".
  • unmount umount -l /mnt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment