Getting the ZFS "magic" on GNU Guix System #11453
Replies: 1 comment 4 replies
-
It's great to hear about OpenZFS being packaged for another Linux distribution! Let me try and field a few of your questions. You've definitely touched on most (maybe all) of the major integration issues required to get OpenZFS working as intended. What you're planning makes sense and we've tried our best to provide flexible mechanisms to tackles all of these integrations issues. But since each distribution has their own way of doing things you'll need to adapt as appropriate for a GNU Guix System. By all means leverage as much of the provided "magic" integration code as makes sense.
The cache file is optional but histroically preferred. It's primary purpose is to provide a quick way to determine which pools should be imported at boot time and by what paths. You can always run
We provide the
This may not be an issue for you. The sole purpose of this rule is to trigger loading the zfs kmod when a block device containing a pool is detected. If on a GNU Guix System the kmod will always be built in to the kernel then it'll always be available and there's nothing to load.
The only requirement on Linux is that this happens after the kernel modules are loaded. It can be started either before or after pools are imported.
It's recommended, but not because OpenZFS won't be able to import a pool if the paths change. The Hopefully, that helps answer some of your questions! |
Beta Was this translation helpful? Give feedback.
-
I've been doing some work recently to get ZFS into GNU Guix System. Guix System is a GNU/Linux distribution built around the Guix functional package manager. Think "Nix, but using Scheme and only-free-as-in-freedom-software". Guix is willing to package ZFS, on the basis of the fact that users are free to do what they want on hardware they own, so they can use the Guix build system to build ZFS locally and link it to their kernel and run the combined kernel+ZFS, users are just not allowed to redistribute the combined work (and the guix repositories don't contain the binaries, users have to compile it, but it's automated by the Guix package manager). However, support for actually using ZFS is nonexistent (and is what I am working on).
ZFS guides tout many things that ZFS can do automatically:
/dev/zvol/pool/dataset
.It turns out that many of the things that ZFS guides take for granted are really magic that is implemented, on Linux, by a variety of programs.
For example, the ZFS kernel module has to be loaded at some point, and that has to be done by the Linux
init
program. The ZFS release has a bunch of systemd services to do so. Guix does not use systemd, it uses GNU Shepherd. So I have to go understand the load-the-module and other things that the systemd services do and reimplement it in GNU Shepherd.And of course the ZFS automounting behavior turns out to be performed by a systemd service as well.
ZVOLs getting into
/dev/zvol/*
are actually implemented by udev. The ZFS release has a bunch of udev rules which implement this. Fortunately Guix uses udev also, but Guix is different enough that I need to add special support for installing the udev rules provided by ZFS into the appropriate place in the Guix system.And then there's ZED, which does a lot of the other magic, like emailing you when a scrub is finished, or replacing a failing device with a hotspare (if you enable the appropriate script).
So I have a bunch of things I need to ask about ZFS and the magic bits that have to be integrated into the distribution in order to make ZFS work the way guides say ZFS is supposed to work.
First, lemme know if the below set of things to make ZFS magic work on Linux is complete. For now I'm targeting
/home
on ZFS, not yet/
or/boot
on ZFS, because just targeting/home
seems to be enough of a challenge. So I'm going to skip overinitrd
parts, and start after the bootup has pivoted from theinitrd
filesystem to the "real"/
root filesystem.init
/etc/modprobe.d/zfs.conf
is traditional, but Guix developers want to make their own mechanism. Then there's the issue with/
on ZFS where you somehow have to pass in the parameters even earlier, possibly before/etc/modprobe.d
is accessible, but, sigh. It's why I don't want to think of/
on ZFS for Guix yet.zpool import -a -N
. However, traditionally it seems to be done byzpool -c /etc/zfs/zpool.cache -a -N
. How important is the cache file?? Also do I need to do anything at shutdown?zfs mount -a
. On shutdown, dozfs unmount -a
./dev/zvol/*
, must happen after pool importation. Done byzvol_wait
. Also need to have udev rules otherwisezvol_wait
will hang forever, because what the ZFS kernel module actually does is create a/dev/zd*
device.zed
, but I may need to explicitly pass in locations of PID file, zedlet dir, etc.zfs share -a
. Must also happen after samba or NFS services are loaded (?).udev
udev
rules refer to/sbin/modprobe
. Guix does not have a traditional/bin
or/sbin
directory, instead a tool that usesmodprobe
or any other tool should refer to it via an absolute path in/gnu/store
which contains the specific version that the tool is known to work with. So I have to modify the rules to change this external dependency and point it to the ZFS dependency on thekmod
package./etc/zfs/zed.d
. They are symlinks to zedlets that are built into ZFS. The sysad is supposed to remove or add symlinks, and can add custom zedlets as well./etc
, at all. Instead, you have an operating-system file that you process and then it spits out a new configuration that includes stuff in/etc
and so on. What I plan to do is that the configuration file can indicate whether a particular ZED trigger should be taken from the ZFS package (cmd/zed/zed.d/*
), should be disabled (if it is likescrub_finish-notify.sh
which is enabled by default), or should run custom Scheme code. And for zedlets that come with ZFS, what the various configurations that should go into thezed.rc
file.Does that make sense?
Now an issue I have is the cache file. For now I'm fine with doing an all-devices scan. For one,
/etc/zfs
does not get created by default and I have to write the code that does that when ZFS gets installed. Do I really need the cache file? The cache file is not created if/etc/zfs
directory does not exist and currently I don't have this path existing.Also, how important is using
/dev/disk/by-id
on Linux nowadays? I tried in a Guix VM with ZFS installed, and created a pool with SLOGs and L2ARCs in various disks, then shut down the VM and restarted it with the devices in jumbled order, and the plain, non-cache usingzpool import -a -N
semed to be able to import the pool with the jumbled devices correctly. My understanding is that the/dev/disk/by-id/*
paths are stored in the cache file since the motherboard could jumble up how devices are sent to the Linux kernel, so it seems to be working with ZFS 2.0.1 at least even without the cache file.Beta Was this translation helpful? Give feedback.
All reactions