Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 692196 - genkernel: Missing zfs support for non-root filesystems including /usr
Summary: genkernel: Missing zfs support for non-root filesystems including /usr
Status: UNCONFIRMED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: genkernel (show other bugs)
Hardware: AMD64 Linux
: Normal major with 1 vote (vote)
Assignee: Gentoo Genkernel Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-08-15 09:21 UTC by fling
Modified: 2020-12-14 14:12 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
genkernel-9999-zfs-without-fstab.patch (genkernel-9999-zfs-without-fstab.patch,2.40 KB, patch)
2019-08-15 09:23 UTC, fling
Details | Diff
this one works for stable version (genkernel-3.5.3.3-zfs-without-fstab.patch,2.47 KB, patch)
2019-08-15 09:24 UTC, fling
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description fling 2019-08-15 09:21:04 UTC
The time has come!
2013-09-27-initramfs-required news item warned about separate /usr being unsupported without an initramfs.
I had no success getting genkernel to mount separate /usr on zfs for a long time.
Turned out genkernel can  mount /usr and other filesystems found in /etc/initramfs.mounts only if they also listed in /etc/fstab, which is usually not the case for zfs.
None of the udev or other breakages prevented my boxen from booting without /usr mounted by initramfs for years.
But sys-fs/zfs-0.8 release links against libssl sneakily effectively rendering userspace unusable without /usr mounted.

I finally tricked genkernel to mount my /usr by adding it to /etc/fstab.
Unfortunately this trick revealed another unrelated bug in openrc which tried to mount /usr over instead of remounting it readwrite.
Failed mount attempt prevented multiple services from starting. I decided to implement zfs support in genkernel.



Reproducible: Always
Comment 1 fling 2019-08-15 09:23:12 UTC
Created attachment 586812 [details, diff]
genkernel-9999-zfs-without-fstab.patch

This patch adds proper zfs support to genkernel allowing to mount filesystems /etc/fstab. It does not modify already existing functionality, fstab works the same way.
A friendly irc user helped with code deduplication by creating get_col_by_mount() using slightly modified code from the original get_mount_device().
Comment 2 fling 2019-08-15 09:24:35 UTC
Created attachment 586814 [details, diff]
this one works for stable version

Tested on multiple hosts.
Comment 3 fling 2019-08-15 09:30:53 UTC
The patch sets the default mount options for zfs to "rw,zfsutil".
But genkernel mounts /usr readonly which is probably fine.
Is not openrc supposed to remount /usr readwrite? Because it is not happening here, /usr stays mounted readonly until I remount it by hand.
Comment 4 fling 2019-08-15 10:16:41 UTC
Signed-off-by: Alexey Smirnoff fling@member.fsf.org
Comment 5 Thomas Deutschmann (RETIRED) gentoo-dev 2019-08-16 19:26:44 UTC
Adding ZFS maintainer for input.

I cannot reproduce the OpenRC rewrite problem you mentioned. I just implemented https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=271c330b15d16c318cfed654d029be4b026eb770 and when I check /var/log, it's mounted rw once the system takes control. Is this a ZFS-only problem?
Comment 6 fling 2019-08-17 02:01:50 UTC
(In reply to Thomas Deutschmann from comment #5)
> Adding ZFS maintainer for input.
> 
> I cannot reproduce the OpenRC rewrite problem you mentioned. I just
> implemented
> https://gitweb.gentoo.org/proj/genkernel.git/commit/
> ?id=271c330b15d16c318cfed654d029be4b026eb770 and when I check /var/log, it's
> mounted rw once the system takes control. Is this a ZFS-only problem?

Openrc only remounts filesystems found in /etc/fstab which is usually not the case for zfs. I'm working on adding this functionality to zfs-mount instead as it requires additional userspace to be used.
Comment 7 Georgy Yakovlev archtester gentoo-dev 2019-08-17 06:33:51 UTC
(In reply to fling from comment #6)
> (In reply to Thomas Deutschmann from comment #5)
> > Adding ZFS maintainer for input.
> > 
> > I cannot reproduce the OpenRC rewrite problem you mentioned. I just
> > implemented
> > https://gitweb.gentoo.org/proj/genkernel.git/commit/
> > ?id=271c330b15d16c318cfed654d029be4b026eb770 and when I check /var/log, it's
> > mounted rw once the system takes control. Is this a ZFS-only problem?
> 
> Openrc only remounts filesystems found in /etc/fstab which is usually not
> the case for zfs. I'm working on adding this functionality to zfs-mount
> instead as it requires additional userspace to be used.

that's incorrect.
zfs-mount service can handle fstab, first action it calls is:
 zfs mount -a

if your pool setup correctly (separate /usr is incorrect) this will mount everything using mountpoint property.

legacy mounts should be in fstab, and zfs-mount service will handle whose as well.

if rootfs is on zfs it's called before localmount and before all writes to FS should start.

having separate /usr is bad idea on linux nowadays. I understand it makes sense, but unfortunately many software pieces no longer consider this a valid usecase.
and like you mentioned your problem is that libssl is in /usr but zfs-0.8.x needs it for crypto support.

I don't think we need this patch, it's overly complicated and conceptually wrong. so nack from me.

upstream has an example how to handle that in contrib/initramfs: ZFS_INITRD_ADDITIONAL_DATASETS, it's used on debian. we even install it to filesystem as /usr/share/initramfs-tools, check it.
all what it does is "checks colon separated list, and calls mount function on each element with appropriate options"
users will need explicitly to opt-in and list extra datasets they want to mount at initrd stage.

please don't reinvent fstab generator.

another point: dracut does not handle separate usr or any extra datasets at all.


and to summarize it all: just use zfs[static-libs]. it will be able to handle missing libs from /usr.

currently zfs does not depend on any ssl (and it's a bug), 0.8.2 will be released shortly and it will include working static-libs useflag.
I just suggest using it and openrc+zfs-mount service should mount /usr for you, legacy or zfs-property one.

I'll print a warning during zfs installation that if users  have separate /usr they should use [static-libs]
Comment 8 Georgy Yakovlev archtester gentoo-dev 2019-08-17 07:42:12 UTC
I was wrong about static-libs, currently it does not do what's expected. I'll look at this.
Comment 9 Larry the Git Cow gentoo-dev 2019-08-17 20:43:52 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7d9504e58ffc04ce3d25892a39b2c414d31a0e3a

commit 7d9504e58ffc04ce3d25892a39b2c414d31a0e3a
Author:     Georgy Yakovlev <gyakovlev@gentoo.org>
AuthorDate: 2019-08-17 20:28:59 +0000
Commit:     Georgy Yakovlev <gyakovlev@gentoo.org>
CommitDate: 2019-08-17 20:43:14 +0000

    sys-fs/zfs: update live ebuild, fix static-libs
    
    static-libs useflag was a no-op since migration to EAPI=7, fix it
    
    Bug: https://bugs.gentoo.org/692196
    Package-Manager: Portage-2.3.71, Repoman-2.3.17
    Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>

 sys-fs/zfs/zfs-9999.ebuild | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Comment 10 Georgy Yakovlev archtester gentoo-dev 2020-10-03 22:08:47 UTC
after chatting yesterday with fling@ on IRC I looked at the patch and genkernel code again and I have to admit that I did not correctly understood patch.

I sincerely apologize, it was unintentional, I was a bit tired and was looking at old genkernel repo. This is unusual for me, but here we go.

patch looks good and actually improves things.


I'm still not a fan of separate /usr mounts though and not a fan of zfsutil mounts (except for rootfs), but not a lot can be done.

I defer to genkernel maintainers the rest. I believe code moved a bit in current versions and and patch may need a bump.


situation with libs still stays though.
I don't know if genkernel copies those libs automatically, but zfs may need libtirpc.so, libssl,so, libcrypto.so from /usr.
and I haven't tested initrd with static-libs.
Comment 11 asx 2020-12-14 14:12:20 UTC
(In reply to Georgy Yakovlev from comment #10)
> I don't know if genkernel copies those libs automatically, but zfs may need
> libtirpc.so, libssl,so, libcrypto.so from /usr.
> and I haven't tested initrd with static-libs.

My initramfs is created by genkernel-4.1.2-r3 and includes that libs:

-rwxr-xr-x   1 root     root       159616 Dec 11 21:03 lib/libtirpc.so.3
-rwxr-xr-x   1 root     root      2836344 Dec 11 21:03 usr/lib/libcrypto.so.1.1
-rwxr-xr-x   1 root     root       593080 Dec 11 21:03 usr/lib/libssl.so.1.1

Using zfs on root, but I don't use a separate /usr, nor encrypted datasets.

Not a fan of separate /usr either.