Script to bootstrap a zfs root based debian from a basic debian install (which will afterwards be used as rescue install)
- a basic Debian (at least v11,
bullseye
) install - the disk must be partitioned with either MBR or GPT partition types
- if the disk is MBR, then
- you may have at most two primary partitions (zfs root debian requires two primary partitions to install: one for the boot zpool and the other for the system zpool)
- no extended partitions and
- the Debian root must be on the last one
- if the disk is GPT, then
- the Debian root must be on the last partition
- you must have at least 4GB free space after the last partition
- your system must be configured to have passwordless ssh into root and the
authorized_keys
file must be in the .ssh subfolder of the root home folder
- Copy the three scripts in your root home folder.
- Change first section of
zroot-install
to set up the parameters for your zfs root system. - Run
zroot-install
- Reboot
- You may be unable to ssh into the new system after the first run (you will certainly be able to log on at the console). In this case just reboot a second time.
- Enjoy.
- In case you mess up later, you will be able to revert your zfs system to its pristine state by rolling back to the snapshots handily created by this script at installation time
- a dual boot system with
- a rescue system (the original install)
- your zfs root debian install
- the zfs root system will have a dedicated boot pool (grub only supports certain zfs pool flags so you want to keep it separate from the main system
- the zfs boot system will be passwordless ssh enabled with the same ssh keys as the original system
- it will be a standard basic debian without any desktop environment - up to you to use tasksel to install what you want.
- the zfs root system will occupy the entire (formerly) empty space after the rescue root partition.
if you need to boot into rescue to fix something, you have two handy scripts to mount / umount the zfs root so you can chroot into it:
zmount
will mount the zfs system and you can justchroot /tmp/target
into it to sort outzumount
will umount and export the zfs root system so you can reboot into it NB. Don't forget tozumount
or your zfs root system won't boot properly. To fix that if you forgot, you just reboot into the rescue andzmount
thenzumount
- if you run
update-grub
from non-chrooted rescue you will lose the zfs root boot entry. To fix that you need to chroot into zfs and runupdate-grub
from there. - ... more might come