It appears Linux root-on-ZFS is a mess. No standard way to do it. Kernel updates require recompiling ZFS. Boot environments are a cornucopia of constantly evolving hacks.

If you're actually using #ZFS on root, on #Debian, what's your preferred hack to make that happen? #sysadmin

I suspect #openzfsmastery might need to assume root on extFS and data on ZFS, leaving root-on-ZFS for the advanced user or a terminal chapter. 

well, ⬆️ sparked discussion.

There are linuxes that integrate ZFS into the installer, like Alpine and Chimera, and support ZFS on root. Good for them!

In general, though, more most linuxes, ZFS on root is an edge case that requires above average expertise with the boot loader. (If you have that expertise you think it's not much, but for many folks it IS a big deal.) Properly covering ZFS on root on Linux would require I write a book on initrd, UEFI, and more. I don't want to write that book. The workarounds various folks use evolve constantly, and by the time the book comes out they would have changed.

Looks like Linux ZFS root with ZFSBootMenu will be relegated a final chapter for the advanced user. 

@mwl I wouldn't use zfs on root with most Linux distros. Because it is too easy mess it up, when updating the machine

@jens_d @mwl We discussed this on yesterday’s OpenZFS call and yeah, consensus was to keep your boot media simple and save ZFS for you storage array. I’m sure they have great disk mirroring.

Um, not expecting much.

@mwl ZBM is a handy recovery fallback as well. I do wish it could also load FreeBSD so there would be one all-around good solution.

@mwl Yeah, this was a deliberate licence incompatibility from Oracle designed to hurt Linux specifically. Take it up with Larry Ellison and the rest of Trump's cabinet.

Ubuntu decided to just Do It Anyway, so there's that avenue for pre-built kernels, but my experience with that a decade ago left me with a bad taste in my mouth. Maybe they got better?

@spacehobo

Yep, that's Oracle!  :flan_actually_bloody_evil:

Ubuntu is heavily deprioritizing ZFS. https://openzfs.github.io/openzfs-docs/Getting%20Started/Ubuntu/Ubuntu%2022.04%20Root%20on%20ZFS.html

Ubuntu 22.04 Root on ZFS — OpenZFS documentation

@mwl @spacehobo This was a Sun Microsystems licensing decision, way before Oracle bought them. Remember, Oracle don't open source. All the cool stuff like Illumos, dtrace, ZFS etc comes from Sun history, not Oracle history.

On the other hand, one could say that the #Linux #GPLv2 license is incompatible with a lot of things.
@spacehobo @mwl There is a reason Oracle stands for One Rich Asshole Called Larry Ellison.

@spacehobo This is exactly the reason why it's still not supported. Btrfs spawned more or less as a response and might actually be the better filesystem in many cases.

@mwl

@collectifission @mwl btrfs is run by an ai bro, so I won't touch it
@mwl I mean, that's to be expected when you compare one whole operating system (FreeBSD w/ a single kernel) to a whole slew of operating systems based on the Linux kernel. Anyway, my ZFS on root method is ZFSBootMenu -- https://docs.zfsbootmenu.org/en/v3.1.x/
Overview — ZFSBootMenu 3.1.0 documentation

@mwl I stole scripts from proxmox, which does a clever thing where they have the efi/boot partition on every disk in the vdev, and then they add a debian hook that installs the bootloader and copies the initrd to every single one of them whenever that changes, ensuring that any disk that survives an untimely death can boot the system correctly.

It also implies they have a lot of extra glue for all of these filesystems, and that in its absence, you have to deal with that yourself, which is annoyingly involved.

Which, I think, mostly reinforces your point

@mwl my advice for linux people is always root-on-something-else + zpools for everything else. hell, I don't do even do root-on-zfs on freebsd anymore.
@mwl ZFS built as a dkms module and copied to the initramfs should work. Main obstacles are "can a minimal initramfs build determine what modules are needed for the block devices?" and getting ZFS running in the installer.
@mwl I look forward to the book coming out so I can at least see how it's used on BSDs and in turn what/how the zfs support in U-Boot might be used in practice, maybe.

@mwl Or root-on-btrfs so you at least get CoW everywhere, even if they are managed in radically different ways.

But yes, root-on-ZFS on Linux is absolutely a mess. It’s the biggest reason I don’t consider Linux for anything I build and have to maintain.

@bob_zim @mwl That sounds a bit dismissive for containerized applications and cloud deployments.
@mrhamel @mwl I don’t do Linux on metal because it lacks ZFS (also for other reasons), so the only containers in which I run things are FreeBSD jails and illumos zones. Why would I build or deploy anything which depends on Linux syscall translation or userspace in either of those?
@bob_zim @mwl Lacks ZFS? You just said ZFS-on-root is a mess. Please be consistent with your argument.

I have functioning fully Debian installs with ZFS-on-root, in production for a non-profit, with ZFSBootMenu powering everything. I build it once, send the snapshot to storage, boot ZFSBootMenu on another system, and pull that snapshot down. It's very easy to deploy systems at scale.

I stay in the Linux container world because it simply works for my employers needs, and works in on-prem + cloud environments. Also, keeping applications in the Linux world makes hiring candidates far easier.

@mrhamel Okay, fine, I left the word “usable” out. Linux lacks *usable* ZFS. Which, to me, is *lacking ZFS*.

I don’t have the patience for the traditional Linux “Tamagotchi mode”.

@bob_zim How is it unusable? I don't understand what you mean by "Tamagotchi mode."
@bob_zim Judging by the lack of response, you know that is BS, and for insult to injury, Open ZFS works just as well on Windows. It is nice to have a universal file system that isn't FAT32.
@mrhamel @bob_zim point of order: I said zfs on root is a mess at the top of this thread, not bob.

@mwl Not Debian, but a downstream derivative: I run Mint with ZFS root on my primary work computer and have for years, zero problems with kernel updates, Mint upgrades, etc. It all "just works".

They removed it from the installer a few versions ago but if you install an older Mint and upgrade it still works fine.

@mwl Zorin linux used to have an experimental root on ZFS option, maybe they took it from upstream Ubuntu? not sure.

But it was gone the last time I checked.

Installing Void Linux on ZFS with Hibernation Support

A practical guide to installing Void Linux on an encrypted ZFS root with LUKS-encrypted swap and working hibernation support.

IT Notes

@mwl I’ve had success just following the OpenZFS Debian instructions: https://openzfs.github.io/openzfs-docs/Getting%20Started/Debian/Debian%20Trixie%20Root%20on%20ZFS.html .

Been running for multiple years across two distro updates with only minimal issues - ( and the worst ones were self inflicted).

It’s labor intensive to do the initial install but otherwise fine in my experience.

Debian Trixie Root on ZFS — OpenZFS documentation

@mwl one nice thing about proxmox is it does this for me (on top of Debian)
@mwl
I'm not sure if this fits your expected shape of a solution as it's a third-party tool outside the OS but I use zfsbootmenu with my root-on-zfs Debian systems.
@mwl I'm having that struggle with NixOS. I want root on ZFS but I don't want manual hacks!
@mwl zfsbootmenu has always worked for me.
@mwl I have always done root on ext (or FFS), and saved the fancy bulk storage tech for a data partition. If I make the base system a highly repeatable thing via config management, then it doesn't need backups and fancy filesystems. Just reinstall/reimage/run cms in some combo to recover it.
@mwl i know it's not what you're asking, but i did run zfs-on-root on a couple linux systems (ubuntu and manjaro) for a few years there.

it worked 98% of the time, but it's really the kind of thing that has to work closer to 99.9999% of the time. so i moved everything over to freebsd and will never go back. it's even worth having to use nfs.

even nfs4.
@mwl I just run zfs on home partition. I can't see a real advantage using it on root. Nuke and pave thde OS seems faster
@mwl Debian/Proxmox/ZBM. I wish ZBM were standard to Proxmox but they’re letting that feature request go stale.

@mwl I compile my own ZFS kernel module + userspace packages from source for every specific kernel, then I pin the kernel.

Yes, I've documented how to do this. Yes, it's online.

@xenotrope

This sent me looking to your blog, of course. After seeing your latest post I'd like to say: you saying you like my books is especially meaningful, because I know you'll say when you don't like a book. 

@mwl Oh dear. I don't know what you saw.

I have a number of ZFS-on-root tutorials for a few different Linux distributions on my old blog, at least one for Void Linux IIRC, but these days I have scripts to do it for me.

https://su.bze.ro/software/zfs-mxlinux/

A ZFS-on-root MX Linux Tutorial

Quick ZFS setup on MX Linux

@xenotrope

I followed your profile, xenotrope.blogspot.com. ;-)

thanks for the link, I like scripts!

@mwl Ah, OK. Paul Trembley review. Yeah, total shitshow.
@mwl the best root-on-ZFS I found in Linux was in NixOS. First party and well documented.

@mwl @gnomon My personal feeling as a long time user of ZFS and also of ZFS on Linux specifically, is that root on ZFS is definitely "danger, experts only" territory today unless you can find a distribution where it's officially fully supported so it's tested, and maintained by them.

My personal view is that ext4 root + ZFS homedir+etc pool is the best and easiest way to go (and how I do it on my desktops). You lose some space, but it's much easier to deal with.

@mwl @gnomon For typical Linux scenarios I'm not sure ZFS root gets you very much (and it does get you pain and worry). ZFS integrity checking is somewhat redundant with good package managers being able to verify checksums for most everything (and then you can reinstall anything broken). But maybe there are people out there who've really used rollback after upgrades.

(Having flexible space usage would be nice, but ... modern disks have gotten big.)

@cks @mwl @gnomon It isn't so much the packages issue (solved problem) it is regression in software that hoses your system and you need to roll back to known good state of your system.

An immutable future "might" be the solution to this, but that is very far away from a production system near you.

@Tubsta @mwl @gnomon My personal view is that rollbacks are such a blunt hammer and so badly or not supported by software¹ that it would have to be something massive to get me to do a system-wide rollback instead of reverting a package back. And if I don't catch it right away, a rollback will also probably roll back other things I want to keep, and etc.

¹ eg Firefox explicitly doesn't guarantee that you can use a slightly older version of Firefox on a profile that's been touched by a newer one.

@cks @Tubsta @gnomon

No matter your OS, rolling back gets ugly and has sharp edges.

I use a separate dataset for each user's home directory. Snapshot them at the upgrade. If you need something old, pull it out of the snapshot.

@mwl

Its tragic.

There is no SINGLE Linux distribution with installer that would allow you to install Linux with Root on ZFS - with ZFS Boot Environments - and with ZFSBootMenu integrated ... NONE. ZIP. Nada. Zero.

Not to even mention that it would also support LUKS encryption on Linux - no way.

On FreeBSD you have fully protected setup with ZFS Boot Environments supported in the loader and with GELI or not included.

The ZFS Boot Environments feature on Linux - the thing that is DESIGNED to PROTECT you from any disasters (that it works on FreeBSD and Illumos) is one that is most fragile and uncertain on Linux.

@mwl The forbidden appendix.
@raven I suspect you're correct
@mwl Yeah, my only linux ZFS system is static initramfs root, zfs pool (frood). I guess I could pivot-root from there.
@mwl I think it's a huge gamble. Once I've been in a situation when OpenSUSE updated to the kernel version that OpenZFS did not support yet and I was cut off from all my data. And downgrade was also impossible - no old enough kernel in repos. Thankfully, I had some old kernel in my /boot.
Would be funny if it happened with root-on-ZFS.
At least you have to pin kernel from updating.
@mwl #alpinelinux does zfs out of the box. No compliling required.

@EF that helps, ty!

looks like you still need to add some fit and polish for it, but not too bad: https://wiki.alpinelinux.org/wiki/ZFS

ZFS - Alpine Linux

@mwl you do but that applies to a lot of #alpinelinux. Not for newbies but it is reliable and fast even through updates. Run multiple machines with native ZFS encrypted roots.

Chimera (BSD userland) and Postmarket (mobile devices) both use Alpine as a base but never used them and not sure how integrated ZFS in them.

@mwl The boot environment for Linux has always been a mess of ugly and constantly evolving stop gap measures. If you want some fun of diving into this rabbit hole, check out the Linux from scratch stuff.

But yeah, that is far from the only disk related mess. Frankly everything disk related and booting basically is.

If you want to run screaming, check out the partial software RAID implementation md.

IMHO the whole disk subsystem needs re-writen from scratch to work akin to how GEOM does on FreeBSD.

@mwl
NixOS offered ZFS on root out of the box too.

In my case, as an opensuse user on non-servers (specifically its rolling Tumbleweed) - it's a fully manual non-standard install and then very careful upgrades (with locking the kernel version at times), but it's still better than not having ZFS, for the root FS screenshots included.

But yeah, it's a marginal "expert-ish" group within Linux users at all.

#openSuSE #ZFS #Linux

@mwl I’m sad for them.

zroot is the basis of Boot Environments.

BE allows upgrade in place with greatly reduced risk; there is a known good fallback position.

Hopefully, one day they can get their shit together.

@mwl fwiw my personal experience has been that initial installation is an unpleasant experience, but after that I have had pleasant experiences on Debian 11/12/13 (upgraded, never reinstalled) with ZFS root and /bot. This is using kernel & zfs packages from debian.org.

Initial installation: Run a very large series of commands in the terminal of a live CD to install, you can't use the interactive installer at all. It really is very daunting and I don't fault anyone for falling out of the funnel at this point!

grub compatibility: modern zfs has a set of compatibility flags for grub2. Use them.

kernel compatibility: zfs-dkms is automatically built when a new kernel is installed. In the rare case that the build fails for some reason, the previous kernel has remained bootable, allowing me to boot and fix the problem. If this had not been the case, things could have been rather difficult.

other problems:
*I made the pool containing /boot way too small, but that's life.

  • At one point, docker and zfs were interacting in some mutually destructive way but that was a Debian or two ago and now I use podman anyway.
  • possibly since the systemd transition there's something funky that tries to import all zfs pools, not just ones in the cache. If you boot with a zfs pool on a usb drive that mounts at "/" it'll mount the one over the other and then you have pain. This I last encountered in Debian 12 and have carefully avoided trying to check if it's been fixed since.

It's rather sad that at one point, Debian's installer had zfs support. I used it to install debian kfreebsd with all zfs filesystems. However, it has never been usable with the linux kernel since there's not a zfs kernel module udeb available and has likely been removed by maintainers (but I haven't gone checking anything about this)