-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make better use of dracut functions when building initramfs #13010
Make better use of dracut functions when building initramfs #13010
Conversation
I realised I hadn't separated the systemd binaries out and they would be pulled in regardless of whether the systemd module was being used by dracut or not. I've separated them out. |
Changed commit message because one line was over 72 characters resulting in it failing the style check. |
Is it within the scope of this PR to also start checking the return code of the Dracut helper functions, in certain situations? Installation failures of 'required' kernel modules, binaries, etc are simply ignored. If everything works as expected, Dracut will produce a working initramfs. If something does go wrong - say, Ideally, |
If the creation of an initramfs is blocked for whatever reason after, say, a kernel upgrade, and the user happens to ignore that warning, then you end up having to boot with a new kernel without a functional initramfs anyway. Imo, in practically all situations, the initramfs is built after a kernel upgrade or a zfs upgrade. There is no practical difference between the initramfs not getting created and a faulty initramfs being created. Both of them will log errors onto the command line during creation time, neither of them will produce a functional initramfs. In the binaries/modules we install, the only command which does not log errors is the kernel module installer, and a simple |
This is not true. Failing to produce an initramfs tends to trigger a bunch of error output. Many times, this is probably even noticed by the package manager, which will complain in addition to dracut. The dracut module makes a covenant with the user to provide functional ZFS support in the initramfs. If it can't honor that, the right thing to do is fail early and loudly, not say "LOL, fuck you" and swallow the failures. People have been bitten by this in the wild. User reports are the reason that we are aggressive about these failures in ZFSBootMenu. Maybe not everything is strictly necessary, but much of what is currently installed unchecked is a hard requirement and should properly trigger an initramfs failure when it can't be installed. |
Note also that it isn't uncommon for post-installation hooks that would automate the initramfs generation tend to use (Dracut upstream also does a horrible job at this; even |
@ahesford I've made most of the changes you suggest (I've kept absolute paths until I get confirmation to remove them). I've added |
Force pushed a change which resolved a non-fatal error I had missed in previous testing. |
I think the latest changes definitely reduce the likelihood that users will be caught by surprise with a faulty initramfs image. Thanks! |
Force pushed a change to resolve issue detected by a test on gentoo. |
@nabijaczleweli @ahesford Apologies for bothering the two of you, but what other changes would you recommend here? Should the absolute paths be kept or not? |
I think the |
The hard-coded paths never should have existed, period. Dracut knows how to find exectuables, and its install program even respects a DRACUT_INSTALL_PATH environment variable to override the default PATH search for non-standard paths. Hard-coding the paths in the module setup at installatiton time completely breaks the Yes, there will be some user out there who will be adversely affected by dropping the paths. However:
|
I was not aware of |
Since we're using The best way of doing this would be to use # udev rules always get installed in the same place, so
# create a function to install them to make life simpler.
inst_rules() {
local _target=/etc/udev/rules.d _rule _found
inst_dir "${udevdir}/rules.d"
inst_dir "$_target"
for _rule in "$@"; do
if [ "${_rule#/}" = "$_rule" ]; then
for r in "$dracutsysrootdir${udevdir}/rules.d" ${hostonly:+"$dracutsysrootdir"/etc/udev/rules.d}; do
[[ -e $r/$_rule ]] || continue
_found="$r/$_rule"
inst_rule_programs "$_found"
inst_rule_group_owner "$_found"
inst_rule_initqueue "$_found"
inst_simple "$_found"
done
fi
for r in '' "$dracutsysrootdir$dracutbasedir/rules.d/"; do
# skip rules without an absolute path
[[ "${r}$_rule" != /* ]] && continue
[[ -f ${r}$_rule ]] || continue
_found="${r}$_rule"
inst_rule_programs "$_found"
inst_rule_group_owner "$_found"
inst_rule_initqueue "$_found"
inst_simple "$_found" "$_target/${_found##*/}"
done
[[ $_found ]] || dinfo "Skipping udev rule: $_rule"
done
} |
Unfortunately, both alternatives for rule installation seem kind of lousy at this point. The function
I guess if we really cared about confirming that the udev rules made it in but still wanted to let ${initdir}/etc/udev/rules.d/90-zfs.rules
${initdir}/${udevdir}/rules.d/90-zfs.rules However, this would be an ugly hack that is probably no better than just hard-coding the rule paths and manually satisfying the helper dependencies. Either drop the paths and use |
Removed absolute paths as far as possible (I've left in a couple of |
Setting up the module involves multiple redundant calls to a bunch of dracut functions wheich can be combined into one. Additionally, the mass of code required to load libgcc_s.so* can be replaced with one dracut function. This has the additional effect of removing errors involving the non-installation of libgcc_s.so* which are seen on debian bullseye when using version 2.1.2-1~bpo11+1 from the backports repository. The systemd binaries are separated out into their own `dracut_install` function call so they do not get pulled in when dracut does not load the systemd module. Signed-off-by: Savyasachee Jha <[email protected]>
Dracut will now fail in initramfs generation if essential files cannot be installed.
Since dracut functions can locate both udev rules and binaries, there is no point in keeping absolute paths in the module setup script. It also breaks the --sysroot option in dracut. This commit removes mentions to absolute paths for binaries and udev rules.
@nabijaczleweli @ahesford It is done from my side. I don't think there's anything else left to change in this. Do have a look at the new changes and see if they work for you. I've tested the patch on an Arch, Debian and Fedora machine. Seems to work well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. This is a nice improvement over the current state.
Made the requested changes. |
That question was asked tongue in cheek, I'm going to test with the file inclusion removed and submit a patch if it works. |
Setting up the module involves multiple redundant calls to a bunch of dracut functions wheich can be combined into one. Additionally, the mass of code required to load libgcc_s.so* can be replaced with one dracut function. This has the additional effect of removing errors involving the non-installation of libgcc_s.so* which are seen on debian bullseye when using version 2.1.2-1~bpo11+1 from the backports repository. The systemd binaries are separated out into their own `dracut_install` function call so they do not get pulled in when dracut does not load the systemd module. Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
Dracut will now fail in initramfs generation if essential files cannot be installed. Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
Since dracut functions can locate both udev rules and binaries, there is no point in keeping absolute paths in the module setup script. It also breaks the --sysroot option in dracut. This commit removes mentions to absolute paths for binaries and udev rules. Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
- Replaced intances of `dracut_install` with `inst_simple` - Removed calls to `test -x mark_hostonly` because the function is an inbuilt dracut function - Removed redundant installation of `systemd-ask-password` and `systemd-tty-ask-password-agent` because they are already installed by the systemd module. There is no need to install them again - Removed multiple calls to the `mark_hostonly` function because the `inst_simple` has a command-line switch for it - Cleaned up the installation of the `zpool.cache`, `vdev_id.conf` and `hostid` files to make the logic easier to follow - Cleaned up and simplified the systemd service installation logic by invoking systemctl instead of creating symlinks manually - Replaced various hard-coded paths with dracut equivalents to better conform with expected dracut behaviour - Removed redundant call to `mkdir` (`inst_simple` creates the parent directory if it does not exist on the destination initrd) Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
Setting up the module involves multiple redundant calls to a bunch of dracut functions wheich can be combined into one. Additionally, the mass of code required to load libgcc_s.so* can be replaced with one dracut function. This has the additional effect of removing errors involving the non-installation of libgcc_s.so* which are seen on debian bullseye when using version 2.1.2-1~bpo11+1 from the backports repository. The systemd binaries are separated out into their own `dracut_install` function call so they do not get pulled in when dracut does not load the systemd module. Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
Dracut will now fail in initramfs generation if essential files cannot be installed. Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
Since dracut functions can locate both udev rules and binaries, there is no point in keeping absolute paths in the module setup script. It also breaks the --sysroot option in dracut. This commit removes mentions to absolute paths for binaries and udev rules. Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
- Replaced intances of `dracut_install` with `inst_simple` - Removed calls to `test -x mark_hostonly` because the function is an inbuilt dracut function - Removed redundant installation of `systemd-ask-password` and `systemd-tty-ask-password-agent` because they are already installed by the systemd module. There is no need to install them again - Removed multiple calls to the `mark_hostonly` function because the `inst_simple` has a command-line switch for it - Cleaned up the installation of the `zpool.cache`, `vdev_id.conf` and `hostid` files to make the logic easier to follow - Cleaned up and simplified the systemd service installation logic by invoking systemctl instead of creating symlinks manually - Replaced various hard-coded paths with dracut equivalents to better conform with expected dracut behaviour - Removed redundant call to `mkdir` (`inst_simple` creates the parent directory if it does not exist on the destination initrd) Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
Setting up the module involves multiple redundant calls to a bunch of dracut functions wheich can be combined into one. Additionally, the mass of code required to load libgcc_s.so* can be replaced with one dracut function. This has the additional effect of removing errors involving the non-installation of libgcc_s.so* which are seen on debian bullseye when using version 2.1.2-1~bpo11+1 from the backports repository. The systemd binaries are separated out into their own `dracut_install` function call so they do not get pulled in when dracut does not load the systemd module. Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
Dracut will now fail in initramfs generation if essential files cannot be installed. Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
Since dracut functions can locate both udev rules and binaries, there is no point in keeping absolute paths in the module setup script. It also breaks the --sysroot option in dracut. This commit removes mentions to absolute paths for binaries and udev rules. Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
- Replaced intances of `dracut_install` with `inst_simple` - Removed calls to `test -x mark_hostonly` because the function is an inbuilt dracut function - Removed redundant installation of `systemd-ask-password` and `systemd-tty-ask-password-agent` because they are already installed by the systemd module. There is no need to install them again - Removed multiple calls to the `mark_hostonly` function because the `inst_simple` has a command-line switch for it - Cleaned up the installation of the `zpool.cache`, `vdev_id.conf` and `hostid` files to make the logic easier to follow - Cleaned up and simplified the systemd service installation logic by invoking systemctl instead of creating symlinks manually - Replaced various hard-coded paths with dracut equivalents to better conform with expected dracut behaviour - Removed redundant call to `mkdir` (`inst_simple` creates the parent directory if it does not exist on the destination initrd) Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
Setting up the module involves multiple redundant calls to a bunch of dracut functions wheich can be combined into one. Additionally, the mass of code required to load libgcc_s.so* can be replaced with one dracut function. This has the additional effect of removing errors involving the non-installation of libgcc_s.so* which are seen on debian bullseye when using version 2.1.2-1~bpo11+1 from the backports repository. The systemd binaries are separated out into their own `dracut_install` function call so they do not get pulled in when dracut does not load the systemd module. Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
Dracut will now fail in initramfs generation if essential files cannot be installed. Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
Since dracut functions can locate both udev rules and binaries, there is no point in keeping absolute paths in the module setup script. It also breaks the --sysroot option in dracut. This commit removes mentions to absolute paths for binaries and udev rules. Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
- Replaced intances of `dracut_install` with `inst_simple` - Removed calls to `test -x mark_hostonly` because the function is an inbuilt dracut function - Removed redundant installation of `systemd-ask-password` and `systemd-tty-ask-password-agent` because they are already installed by the systemd module. There is no need to install them again - Removed multiple calls to the `mark_hostonly` function because the `inst_simple` has a command-line switch for it - Cleaned up the installation of the `zpool.cache`, `vdev_id.conf` and `hostid` files to make the logic easier to follow - Cleaned up and simplified the systemd service installation logic by invoking systemctl instead of creating symlinks manually - Replaced various hard-coded paths with dracut equivalents to better conform with expected dracut behaviour - Removed redundant call to `mkdir` (`inst_simple` creates the parent directory if it does not exist on the destination initrd) Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
Setting up the module involves multiple redundant calls to a bunch of dracut functions wheich can be combined into one. Additionally, the mass of code required to load libgcc_s.so* can be replaced with one dracut function. This has the additional effect of removing errors involving the non-installation of libgcc_s.so* which are seen on debian bullseye when using version 2.1.2-1~bpo11+1 from the backports repository. The systemd binaries are separated out into their own `dracut_install` function call so they do not get pulled in when dracut does not load the systemd module. Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
Dracut will now fail in initramfs generation if essential files cannot be installed. Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
Since dracut functions can locate both udev rules and binaries, there is no point in keeping absolute paths in the module setup script. It also breaks the --sysroot option in dracut. This commit removes mentions to absolute paths for binaries and udev rules. Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
- Replaced intances of `dracut_install` with `inst_simple` - Removed calls to `test -x mark_hostonly` because the function is an inbuilt dracut function - Removed redundant installation of `systemd-ask-password` and `systemd-tty-ask-password-agent` because they are already installed by the systemd module. There is no need to install them again - Removed multiple calls to the `mark_hostonly` function because the `inst_simple` has a command-line switch for it - Cleaned up the installation of the `zpool.cache`, `vdev_id.conf` and `hostid` files to make the logic easier to follow - Cleaned up and simplified the systemd service installation logic by invoking systemctl instead of creating symlinks manually - Replaced various hard-coded paths with dracut equivalents to better conform with expected dracut behaviour - Removed redundant call to `mkdir` (`inst_simple` creates the parent directory if it does not exist on the destination initrd) Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
Setting up the module involves multiple redundant calls to a bunch of dracut functions wheich can be combined into one. Additionally, the mass of code required to load libgcc_s.so* can be replaced with one dracut function. This has the additional effect of removing errors involving the non-installation of libgcc_s.so* which are seen on debian bullseye when using version 2.1.2-1~bpo11+1 from the backports repository. The systemd binaries are separated out into their own `dracut_install` function call so they do not get pulled in when dracut does not load the systemd module. Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
Dracut will now fail in initramfs generation if essential files cannot be installed. Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
Since dracut functions can locate both udev rules and binaries, there is no point in keeping absolute paths in the module setup script. It also breaks the --sysroot option in dracut. This commit removes mentions to absolute paths for binaries and udev rules. Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
- Replaced intances of `dracut_install` with `inst_simple` - Removed calls to `test -x mark_hostonly` because the function is an inbuilt dracut function - Removed redundant installation of `systemd-ask-password` and `systemd-tty-ask-password-agent` because they are already installed by the systemd module. There is no need to install them again - Removed multiple calls to the `mark_hostonly` function because the `inst_simple` has a command-line switch for it - Cleaned up the installation of the `zpool.cache`, `vdev_id.conf` and `hostid` files to make the logic easier to follow - Cleaned up and simplified the systemd service installation logic by invoking systemctl instead of creating symlinks manually - Replaced various hard-coded paths with dracut equivalents to better conform with expected dracut behaviour - Removed redundant call to `mkdir` (`inst_simple` creates the parent directory if it does not exist on the destination initrd) Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
Setting up the module involves multiple redundant calls to a bunch of dracut functions wheich can be combined into one. Additionally, the mass of code required to load libgcc_s.so* can be replaced with one dracut function. This has the additional effect of removing errors involving the non-installation of libgcc_s.so* which are seen on debian bullseye when using version 2.1.2-1~bpo11+1 from the backports repository. The systemd binaries are separated out into their own `dracut_install` function call so they do not get pulled in when dracut does not load the systemd module. Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
Dracut will now fail in initramfs generation if essential files cannot be installed. Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
Since dracut functions can locate both udev rules and binaries, there is no point in keeping absolute paths in the module setup script. It also breaks the --sysroot option in dracut. This commit removes mentions to absolute paths for binaries and udev rules. Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
- Replaced intances of `dracut_install` with `inst_simple` - Removed calls to `test -x mark_hostonly` because the function is an inbuilt dracut function - Removed redundant installation of `systemd-ask-password` and `systemd-tty-ask-password-agent` because they are already installed by the systemd module. There is no need to install them again - Removed multiple calls to the `mark_hostonly` function because the `inst_simple` has a command-line switch for it - Cleaned up the installation of the `zpool.cache`, `vdev_id.conf` and `hostid` files to make the logic easier to follow - Cleaned up and simplified the systemd service installation logic by invoking systemctl instead of creating symlinks manually - Replaced various hard-coded paths with dracut equivalents to better conform with expected dracut behaviour - Removed redundant call to `mkdir` (`inst_simple` creates the parent directory if it does not exist on the destination initrd) Reviewed-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Andrew J. Hesford <[email protected]> Signed-off-by: Savyasachee Jha <[email protected]> Closes openzfs#13010
Setting up the module involves multiple redundant calls to a bunch of
dracut functions wheich can be combined into one. Additionally, the mass
of code required to load libgcc_s.so* can be replaced with one dracut
function. This has the additional effect of removing the error:
Which is seen on debian bullseye when using version 2.1.2-1~bpo11+1 from
the backports repository.
Signed-off-by: Savyasachee Jha [email protected]
Motivation and Context
I made this change because I kept getting the error (mostly cosmetic, but annoying):
whenever I could build a new initramfs on debian bullseye using
dracut
. This caused no issues in booting but seeing that error message all the time was jarring.Description
The
module-setup.sh.in
file defines how zfs modules are setup in the initramfs and pulls in all the required dependencies. The script (in master) calls theinstmods
,inst_rules
anddracut_install
functions once for each module, rule and binary which are to be added to the initramfs respectively. Since each function is capable of installing multiple files, I have reduced the number of function calls to just one each.In addition, there is a long if-else statement to find
libgcc_s.so*
on the filesystem and install it into the initramfs. Dracut has a functioninst_libdir_file
which does this quite well, so I replaced the if-else statements with one call toinst_libdir_file
.How Has This Been Tested?
I have tested this on Debian stable, Fedora 35, and Arch Linux using zfs 2.1.2 by building the initramfs using this change and booting into the system. No changes were observed in terms of booting - the systems booted perfectly well with no errors. The upside was that the cosmetic error seen in Debian described above went away.
This change should not affect any other areas of code.
Types of changes
Checklist:
Signed-off-by
.Since this does not touch the core zfs files, I did not run the test suite or add any tests. I also do not believe this change requires any addition to the documentation.