Mail archive

[alpine-user] Re: ZFS boot and root

From: David Davies <>
Date: Wed, 20 Mar 2019 02:53:39 +0000

OK, I've worked it out. Sorry if I missed a couple of steps, this is just an overview for someone already pretty familiar with doing this on other distros. It's a bit long, sorry.

The basic process for me is:

  1. Boot Alpine iso
     * At the moment use the extended iso, it comes with zfs. The standard iso used to work but if you use it now and install zfs in live environment you'll get issues because the vanilla kernel version from packages is different to what's on the iso. This is only since 3.9.2
  2. Run these commands so you can install packages
     * cp -pR /.modloop/modules /tmp
     * umount /.modloop
     * rm /lib/modules
     * mv /tmp/modules /lib
  3. Install some other stuff you need and run the following
     * apk add util-linux eudev
     * setup-udev (this will give you your /dev/disk/by-*)
  4. Now install zfs in live environment
     * apk add zfs zfs-libs zfs-vanilla
     * modprobe zfs
  5. Create your zpool and zfs file systems. I choose to use the following layout, see also guides on the web for more info
     * /dev/sda1 ------> 500 MB "boot bios" partition
     * /dev/sda2 ------> What's left, single unformatted partition
     * Have your / mounted to /mnt and /boot mounted to /mnt/boot when you create your zpool with the "-R" parameter
  6. Go through the "setup-alpine" wizard and keep typing "none" when you get to the point of installing to disk
  7. This is a total hack, but it works. Edit the file /sbin/setup-disk
     * Go to line 210 and add zfs to the supported filesystems (see below)
     * local supported="ext2 ext3 ext4 btrfs xfs vfat zfs"
     * Save and exit
  8. Run the following command
     * setup-disk -m sys -v /mnt
     * Install will work but will exit with an error. Just ignore it, it's done
  9. Now prepare to chroot
     * mount -t proc none /mnt/proc
     * mount --rbind /sys /mnt/sys
     * mount --rbind /dev /mnt/dev
     * chroot /mnt /bin/ash -l
  10. Inside the chroot run the following
     * apk del syslinux (we want to use grub)
     * export ZPOOL_VDEV_NAME_PATH=1 (this lets grub install with zfs on root)
     * apk add grub grub-bios
     * grub-install /dev/sda
     * grub-mkconfig -o /boot/grub/grub.cfg
  11. Add zfs to /etc/mkinitfs/mkinitfs.conf, to make it look something like
     * features="ata base ide scsi usb virtio zfs"
  12. Edit /etc/fstab and get rid of the ZFS entries at the top
  13. Now run mkinitfs
  14. Install anything else you need, create accounts etc
  15. Exit chroot and run the following
     * umount -R /mnt/dev
     * umount -R /mnt/proc
     * umount -R /mnt/sys
     * zpool export zroot
  16. Now reboot into your zfs root on alpine goodness!

A couple of things I have found so far

  * You DON'T need to enable zfs-import, zfs-mount services with rc-update IF you only have the zpool on the root file system. I haven't tested how this goes if you have other zpools. But, these services can be enabled easily enough if needed
  * On poweroff you may get the error: "Unable to save dependency cache". I managed to find an obscure reference to this on a gentoo forum, the file systems are unmounted before this service can complete. I could "fix" it by editing /etc/conf.d/zfs and changing the line
     * ZFS_UMOUNT="no"
     * Oddly enough, after re-enabling this (putting "yes" back) I don't get this error anymore
  * On boot you get the errors:
     * cannot import 'zroot' : pool already exists
     * cannot mount '/' directory not empty
     * No idea what to do about this. It sounds like initramfs has already mounted zroot (great) but for some reason something tries to mount it again? And this is with the zfs-import and zfs-mount services NOT enabled
  * Creating other zfs file systems for things like /usr /var /home etc. causes really strange errors and a broken system. Would love to know if someone else has got this working
  * Installing this to a USB drive gives you an unbootable USB as far as I can tell. I could only get it to work using vmware and booting with plop. I tried tinkering with ZFS_INITRD_PRE_MOUNTED_SLEEP and ZFS_INITRD_POST_MODPROBE_SLEEP in /etc/conf.d/zfs - but it made no difference for me

Would love to hear feedback and other people's experiences as well. Would REALLY love if ZFS could be a supported file system on install, it's just a matter of hacking the setup scripts properly, not like what I've done.

On 6 Feb 2019, at 11:18, David Davies <<>> wrote:


We've been trying to get ZFS on root working for some time. The best we can do at the moment is have /boot on an ext4 partition with ZFS on root. Is it possible to have alpine boot with ZFS on /boot and / - whole disk with no partitions necessary? I have tried every ZFS root guide for Gentoo, Arch, Ubuntu, Centos and a couple for Alpine but simply can't get this to work.

The best I can do is manually load initrd and linux-vanilla from grub but it crashes to an emergency shell on boot.

Any ideas on if this is currently possible? If not could this be support in a future release, even have ZFS as a possible default install option in the setup-alpine script?



Received on Wed Mar 20 2019 - 02:53:39 UTC