Skip to content

Creating Debian ZFS Rescue USB Image

Creating Debian Live Rescue Image with ZFS

Debian have tool named live-build 1. The easies way to get is just

sudo apt-get install live-build

Once installed:

Create a (temporary) working directory where it all happens:

mkdir /tmp/debian-streatch-live+zfs
cd /tmp/debian-streatch-live+zfs

Generate initial configuration:

lb config \
  --distribution stretch \
  --architectures=amd64 \
  --binary-images iso-hybrid \
  --iso-volume "Debian Stretch ZFS Rescue Live" \
       --archive-areas "main contrib" \
       --linux-packages "linux-image linux-headers"

We should include contrib in archives since thats where ZFS packages are. You may want to pass --backports if you want to include backports repositories. The --linux-packages is to include kernel headers necessary to compile ZFS kernel modules.

Configure additional packages to be installed, most importantly the ZFS packages:

echo "
zfs-dkms
less
curl
wget
openssh-client
openssh-server
openssh-sftp-server
" >> config/package-lists/my.list.chroot

Build the live root filesystem:

sudo lb bootstrap
sudo lb chroot

Build the hybrid ISO binary:

sudo lb binary

After this step, you should find the resulting ISO image in live-image-amd64.hybrid.iso.

Profit!

Using the Rescue Image

By default, ZFS kernel module is not loaded, so:

sudo modprobe zfs Then you need to import pools:

sudo zpool import

It may happen that pools were not cleanly exported. Then you’d have to import them with -f flag (a.k.a. force):

sudo zpoool import -f tank You may check status of pools by:

sudo zpool status

Only do so if you’re absolutely sure no other system is accessing the pool at the time. But if you run ZFS normal PC with couple SATA disks attached like me and the PC is currently running the live rescue image than you should be fine.

Mount host’s root filesystem to /tmp/host:

mkdir /tmp/host mount -t zfs tank/host/root /dev/host

Now you can chroot /dev/host /bin/bash and do what you want to create ZFS snapshot, whatever you wish. Just make sure that once you’re done you export pools so they can be cleanly imported by the host.

sudo zpool export tank

Some Comments

The configuration for lb command is stored in config directory. The lb config with various parameters just modifies (or creates if it does not exit) contents of the config. It may be a good idea to put the config into under version control such as Mercurial or git.

The live image produced as above is really minimal, theres not even a man. You may want to add more packages. To do so, simply add them to the config/package-lists/my.list.chroot. You may pull in a whole GNOME by adding gnome-desktop package (though I have not tried).

To wrap it up, the process of building live Debian image is surprisingly easy. Kudos to Debian people!