This install method is not only usefull for this case but also when you need to install a remote system where the person running the install physically is not well versed in linux system installs.
First of all we need to download a Debian Live ISO. I prefer the amd64-standard.iso, the one with graphical GUI might go into stand-by when nobody touches the actual physical machine.
The next step is to boot the ISO, either like me in a virtual machine or write it down to a physical medium and boot a real PC/Server. What we also want in this step is to enable remote SSH access.
apt update
apt install openssh-server net-tools
curl https://ssh.cheriches.eu -o .ssh/authorized_keys
Once we have the IP address using ifconfig we can remotely connect to the machine and start by installing some basic tools:
apt install dosfstools btrfs-progs gdisk debootstrap
Next we need to partition the disk. In my case I don’t need swap but you might. You can use some other tool to achieve the same result. The important part of the layout is to have a EFI partition and at least one partition for the rest of the system marked as Linux File System.
export DISK=/dev/vda
sgdisk --zap-all $DISK
sgdisk -n1:1M:+512M -t1:EF00 $DISK
sgdisk -n2:0:0 -t2:8300 $DISK
Format the newly created partitions, the EFI one with FAT32 and the other one as BTRFS.
mkfs.vfat -F32 /dev/vda1
mkfs.btrfs /dev/vda2
First mount of the BTRFS partition in order to create the subvolumes.
mount /dev/vda2 /mnt/
cd /mnt/
btrfs subvolume create @
btrfs subvolume create @home
btrfs subvolume create @var
cd /
umount /mnt/
And a remount for the final layout:
mount /dev/vda2 /mnt -o subvol=@
cd /mnt/
mkdir boot var home
mount /dev/vda1 boot/
mount /dev/vda2 home/ -o subvol=@home
mount /dev/vda2 var/ -o subvol=@var
Install the base filesystem:
debootstrap stable /mnt https://deb.debian.org/debian/
Chroot and mount the pseudo-filesystems:
chroot /mnt /bin/bash
mount -t proc proc /proc
mount -t devtmpfs udev /dev
mount -t sysfs sysfs /sys
mount -t devpts devpts /dev/pts
mount -t efivarfs efivarfs /sys/firmware/efi/efivars
Some basic tools installation:
apt update
apt install vim-nox wget btrfs-progs dosfstools openssh-server net-tools
Create the fstab, get the partition IDs and replace the entries in the fstab. You can do this by hand or with sed, don’t forget to use your actual ID.
cp /etc/mtab /etc/fstab
blkid
sed -i 's#/dev/vda1#UUID="A06A-6D17"#' /etc/fstab
sed -i 's#/dev/vda2#UUID="3cb21173-e298-4704-a3e2-f6a9561acdec"#' /etc/fstab
Install the boot loader. Debian usually uses grub, in this case I use Systemd-Boot. The choice is yours!
apt install systemd-boot
apt install linux-image-amd64
cd /boot/loader/entries
ls
If you do like me you’ll find in /boot/loader/entries a file, mine is called 595ff83ce3e34be4bb3456a6b2ee6213-6.1.0-27-amd64.conf that you need to edit, something like this:
title Debian GNU/Linux 12 (bookworm)
version 6.1.0-27-amd64
options root=UUID="1e22d882-bf0b-4039-8c52-df38e0c6d43b" rootflags=subvol=@ rw rootfstype=btrfs quiet splash
linux /595ff83ce3e34be4bb3456a6b2ee6213/6.1.0-27-amd64/linux
initrd /595ff83ce3e34be4bb3456a6b2ee6213/6.1.0-27-amd64/initrd.img-6.1.0-27-amd64
Network configuration. The simplest way in Debian is to edit /etc/network/interfaces to have something like:
source /etc/network/interfaces.d/*
auto lo
iface lo inet loopback
allow-hotplug enp1s0
iface enp1s0 inet dhcp
Change the root password and add your SSH key
passwd
curl https://ssh.cheriches.eu -o /root/.ssh/authorized_keys
Exit form the chroot and reboot the system
exit
reboot
Login back via SSH and add make some further configurations. Edit /etc/apt/sources.list to have something like:
deb http://deb.debian.org/debian/ bookworm main non-free-firmware
deb-src http://deb.debian.org/debian/ bookworm main non-free-firmware
deb http://security.debian.org/debian-security bookworm-security main non-free-firmware
deb-src http://security.debian.org/debian-security bookworm-security main non-free-firmware
deb http://deb.debian.org/debian/ bookworm-updates main non-free-firmware
deb-src http://deb.debian.org/debian/ bookworm-updates main non-free-firmware
apt update && apt dist-upgrade
Now check /boot/loader/entries for a new file reflecting your newly installed kernel if it generates correctly.
Optional
apt install sudo chrony bash-completion
hostnamectl hostname debian12
Optional: Docker install:
apt-get install ca-certificates curl
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin