1

I'm looking to create an (internal, for legal reasons) preseeded debian (stretch) installer that will automatically create a root zpool from all available HDs instead of going through (whether automated or not) the usual partition setup.

Most advice I've seen for a ZFS root (or perhaps, a more authoritative guide) requires installing debian then manually booting into a LiveCD, installing ZFS on that LiveCD, setting up ZFS, then chrooting into the new ZFS root to essentially reinstall everything. This seems very error prone and tedious. Although, I understand that for legal reasons the debian installer may never include ZFS as a builtin option.

In my research, I came across some mailing list threads where several people asked maintainers about something approximating this, but they always devolved into legal explanations and the question never was answered (I'd share if I could find them again, but reading them is largely a waste of time!).

Taking a look at an example preseed file for stable, we see the following interesting lines:

### Apt setup
# You can choose to install non-free and contrib software.
#d-i apt-setup/non-free boolean true
#d-i apt-setup/contrib boolean true

And a little further down:

# Individual additional packages to install
#d-i pkgsel/include string openssh-server build-essential

This seems promising, because you could indeed just ask for ZFS to be installed:

d-i apt-setup/contrib boolean true
d-i pkgsel/include string zfs-dkms zfsutils-linux zfs-initramfs

But, since apt setup and package installation is done after the partitioning step, this is probably too late.

I did find this guide which explains another way of adding non-free packages to the install process (tl;dr download the deb, dpkg-deb -x'd it into initrd, and remake the iso). This has the advantage (I think) of being available before the partitioning step. It seems like something similar could be done for installing ZFS (although, you'd first need to compile it before stuffing it into initrd). The tricky bit here is we need a hook to replace the partition step with a script that creates the ZFS pool. This comment by @FerencWágner from a SE Unix thread about changing some LVM things in partman seems promising, but no details were given as to specifically how this was achieved (and the accepted answer suggests partman can't do custom things like this).

So with that all in mind:

  1. Is the d-i apt-setup/contrib/d-i pkgsel/include indeed too late to use ZFS when creating the root fs?
  2. If the above is correct, is including the packages in initrd a correct approach to making ZFS available at the partitioning step?
  3. And regardless of whether (1) is correct, how do I replace the partman step with my custom ZFS root pool creation?
0

Since you want ZFS root, ZFS support must be added to Debian-Installer, pkgsel/include won't help you. The proper way was described on debian-boot by Frans Pop:

You'll have to create a custom udeb that is included in the menu just before partman (i.e. menu item number between 3500 and 4000), performs all the basic functions of partman and provides the same pseudo packages as partman.

The basic functions of partman are:

  • creating the /target directory
  • creating the partitions
  • creating the /target/etc/fstab
  • mounting the partitions in /target

For basic info on creating a custom udeb, see the Debian Installer internals.

(I replaced the stale link with a current one.)

For experimentation, I recommend preseeding anna/choose_modules to network-console, logging in to a shell when partman appears, downloading the necessary files/scripts via wget and testing them in the installer environment, doing partman's work by hand (you may still use partman for setting up the /root mount point). After this, you can build udebs or just simply put your extra files into the initrd or into an initrd overlay (an additional initrd image also loaded by ext/sys/iso/pxelinux).

Proper partman integration would be a wonderful achievement, but I can't really guide you there. The old documentation is probably still very much relevant, and you can use existing modules like for example partman-btrfs for inspiration. But you'd better ask on debian-boot first to avoid duplicating effort or going down the wrong path.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.