dasJ / sd-zfs

Compatibility between systemd and ZFS roots
MIT License
43 stars 13 forks source link

Allow mounting of a rootfs dataset with mountpoint=legacy (or anything else besides none) #29

Open mlow opened 5 years ago

mlow commented 5 years ago

This is my first effort to do anything in C, so please bear with me... I tried to understand the logic behind the construction of the mountpoint that gets passed to the zfs mount command, and I believe it to be as follows:

Since sd-zfs handles mounting of descendent filesystems as well, the zfs mountpoint option of the dataset (and its descendents) given to mount.initrd_zfs is appended to the mountpoint given to mount.initrd_zfs. This however breaks mounting the root dataset when its zfs mountpoint is set to anything other than "/", since that path doesn't exist in /new_root inside the initramfs.

This makes it so the dataset given to mount.initrd_zfs is mounted directly to the mountpoint given to mount.initrd_zfs, and treats descendant datasets the same way as they were before.

This helps my dual-boot scenario allowing me to mount the root dataset of Archlinux inside of another distribution (whose rootfs is another dataset in the same pool) without needing to change the zfs mountpoint of the Archlinux dataset from '/' to avoid conflicts with the currently booted dataset. Instead, I just set the Archlinux dataset mountpoint to legacy.