debian-with-luks2-on-btrfs-with-grub
Differences
This shows you the differences between two versions of the page.
| debian-with-luks2-on-btrfs-with-grub [2026-02-23 07:57:29] – created hyperreal | debian-with-luks2-on-btrfs-with-grub [2026-03-14 20:20:43] (current) – removed hyperreal | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Debian with LUKS2 Btrfs and GRUB via Debootstrap ====== | ||
| - | Source: https:// | ||
| - | |||
| - | * Use a Debian Live ISO | ||
| - | * Single LUKS2 encrypted partition | ||
| - | * Single Btrfs filesystem with '' | ||
| - | * Encrypted swapfile in Btrfs subvolume | ||
| - | * Optional removal of crypto keys from RAM during laptop suspend | ||
| - | * Optional configurations for laptops | ||
| - | |||
| - | ===== Pre-installation setup ===== | ||
| - | |||
| - | Boot into the live ISO, open a terminal, and become root. Install the needed packages. | ||
| - | |||
| - | <code bash> | ||
| - | sudo -i | ||
| - | apt update | ||
| - | apt install -y debootstrap cryptsetup arch-install-scripts | ||
| - | </ | ||
| - | |||
| - | Create partitions. | ||
| - | |||
| - | <code bash> | ||
| - | cfdisk / | ||
| - | </ | ||
| - | |||
| - | * GPT partition table | ||
| - | * 512M ''/ | ||
| - | * 100%+ ''/ | ||
| - | |||
| - | <code bash> | ||
| - | mkfs.fat -F 32 -n EFI / | ||
| - | cryptsetup -y -v --type luks2 luksFormat --label Debian / | ||
| - | cryptsetup luksOpen / | ||
| - | mkfs.btrfs / | ||
| - | </ | ||
| - | |||
| - | Make Btrfs subvolume. | ||
| - | |||
| - | <code bash> | ||
| - | mount / | ||
| - | btrfs subvolume create /mnt/@ | ||
| - | btrfs subvolume create /mnt/@home | ||
| - | btrfs subvolume create /mnt/@swap | ||
| - | umount -lR /mnt | ||
| - | </ | ||
| - | |||
| - | Re-mount subvolumes as partitions. | ||
| - | |||
| - | <code bash> | ||
| - | mount -t btrfs -o defaults, | ||
| - | mkdir -p / | ||
| - | mkdir / | ||
| - | mount / | ||
| - | mount -t btrfs -o defaults, | ||
| - | </ | ||
| - | |||
| - | Setup swapfile. | ||
| - | |||
| - | <code bash> | ||
| - | mkdir -p /mnt/swap | ||
| - | mount -t btrfs -o subvol=@swap / | ||
| - | touch / | ||
| - | chmod 600 / | ||
| - | chattr +C / | ||
| - | btrfs property set ./swapfile compression none | ||
| - | dd if=/ | ||
| - | mkswap / | ||
| - | swapon / | ||
| - | </ | ||
| - | |||
| - | ===== Base installation ===== | ||
| - | |||
| - | Create a nested subvolume for ''/ | ||
| - | |||
| - | <code bash> | ||
| - | mkdir -p /mnt/var | ||
| - | btrfs subvolume create / | ||
| - | debootstrap --arch amd64 < | ||
| - | </ | ||
| - | |||
| - | Bind the pseudo-filesystems for chroot. | ||
| - | |||
| - | <code bash> | ||
| - | mount --rbind /dev /mnt/dev | ||
| - | mount --rbind /sys /mnt/sys | ||
| - | mount -t proc proc /mnt/proc | ||
| - | </ | ||
| - | |||
| - | Generate fstab. | ||
| - | |||
| - | <code bash> | ||
| - | genfstab -U /mnt >> / | ||
| - | </ | ||
| - | |||
| - | Chroot into the new system. | ||
| - | |||
| - | <code bash> | ||
| - | cp -v / | ||
| - | chroot /mnt | ||
| - | </ | ||
| - | |||
| - | ===== Configure the new installation ===== | ||
| - | |||
| - | Set the timezone, locale, keyboard configuration, | ||
| - | |||
| - | <code bash> | ||
| - | apt install -y locales | ||
| - | dpkg-reconfigure tzdata locales keyboard-configuration console-setup | ||
| - | </ | ||
| - | |||
| - | Set the hostname. | ||
| - | |||
| - | <code bash> | ||
| - | echo ' | ||
| - | echo ' | ||
| - | </ | ||
| - | |||
| - | Configure APT sources on ''/ | ||
| - | |||
| - | < | ||
| - | deb https:// | ||
| - | deb https:// | ||
| - | deb https:// | ||
| - | deb https:// | ||
| - | </ | ||
| - | |||
| - | Install essential packages. | ||
| - | |||
| - | <code bash> | ||
| - | apt update -t < | ||
| - | apt dist-upgrade -t < | ||
| - | apt install -t < | ||
| - | </ | ||
| - | |||
| - | Install desktop environment. | ||
| - | |||
| - | <code bash> | ||
| - | apt install task-gnome-desktop task-desktop task-ssh-server | ||
| - | </ | ||
| - | |||
| - | If installing on a laptop: | ||
| - | |||
| - | <code bash> | ||
| - | apt install -y task-laptop powertop | ||
| - | </ | ||
| - | |||
| - | Create users and groups. | ||
| - | |||
| - | <code bash> | ||
| - | passwd root | ||
| - | adduser jas | ||
| - | echo "jas ALL=(ALL) NOPASSWD: ALL" | tee -a / | ||
| - | chmod 440 / | ||
| - | usermod -aG systemd-journal jas | ||
| - | </ | ||
| - | |||
| - | ===== Setting up the bootloader ===== | ||
| - | |||
| - | Optional package for extra protection of suspended laptops. | ||
| - | |||
| - | <code bash> | ||
| - | apt install cryptsetup-suspend | ||
| - | </ | ||
| - | |||
| - | Setup encryption parameters. | ||
| - | |||
| - | <code bash> | ||
| - | blkid -s UUID -o value / | ||
| - | </ | ||
| - | |||
| - | Edit ''/ | ||
| - | |||
| - | <code bash> | ||
| - | cryptroot UUID=< | ||
| - | </ | ||
| - | |||
| - | Setup bootloader. | ||
| - | |||
| - | <code bash> | ||
| - | grub-install --target=x86_64-efi --efi-directory=/ | ||
| - | </ | ||
| - | |||
| - | Edit ''/ | ||
| - | |||
| - | <code bash> | ||
| - | GRUB_CMDLINE_LINUX_DEFAULT="" | ||
| - | GRUB_CMDLINE_LINUX="" | ||
| - | GRUB_ENABLE_CRYPTODISK=y | ||
| - | GRUB_TERMINAL=console | ||
| - | </ | ||
| - | |||
| - | Update grub. | ||
| - | |||
| - | <code bash> | ||
| - | update-grub | ||
| - | </ | ||
| - | |||
| - | Exit chroot and reboot. | ||
| - | |||
| - | <code bash> | ||
| - | exit | ||
| - | umount -lR /mnt | ||
| - | reboot | ||
| - | </ | ||
| - | |||
| - | ===== Emergency recovery from live ISO ===== | ||
| - | |||
| - | <code bash> | ||
| - | sudo -i | ||
| - | cryptsetup luksOpen / | ||
| - | mount -t btrfs -o defaults, | ||
| - | mount / | ||
| - | mount -t btrfs -o defaults, | ||
| - | mount -t btrfs -o subvol=@swap / | ||
| - | swapon / | ||
| - | mount --rbind /dev /mnt/dev | ||
| - | mount --rbind /sys /mnt/sys | ||
| - | mount -t proc proc /mnt/proc | ||
| - | chroot /mnt | ||
| - | </ | ||
debian-with-luks2-on-btrfs-with-grub.1771833449.txt.gz · Last modified: by hyperreal
