Before trying to mount a filesystem, check if it's already mounted first.
This way we can call ensure_initramfs_mounts multiple times during
the pivot root initialization.
Commit 3a054014e8 replaced our modprobe
with busybox's modprobe. Unfortunately, busybox's modprobe appears to be
unable to properly load modules with more than 1 level of dependencies.
The zfs and zpool commands will invoke modprobe if /dev/zvol is missing,
which concealed this problem. However, this caused problems because some
invocations would fail and under certain circumstances, init would be
killed, causing a kernel panic. This issue was made clear by commit
c812c35100771bb527f6b03853fa6d8ef66a48fe, which ensured that the zpool
and zfs commands were not run until the ZFS module was loaded.
busybox modprobe's failure to load module dependencies correctly appears
to occur because busybox modprobe does not wait until until a module is
loaded before loading a module that depends on it, which is a race. It
would be best to correct this race by waiting until the module has
properly loaded, but it is not clear that the race is the only thing
going wrong and developer time is a premium.
We implement a workaround by modifying the busy loop added in the
previous commit to explicit call `modprobe zfs` on each iteration. While
the first few calls fail due to bugs in busybox modprobe, it will
eventually work, after which each call is a noop. This lets us keep
looping until either the loop exit condition that /dev/zvol exist is
reached or the 5 second timeout is reached.
Once the busybox modprobe issue is fixed, this workaround should be safe
to revert.
Signed-off-by: Richard Yao <ryao@gentoo.org>
There is a race between ZFS module initialization and our attempt to
import pools. We address this by doing a busy wait for the /dev/zfs
device to appear. We wait a maximum of 5 seconds for the device to
appear.
We also slightly alter output messages to be more readable.
Signed-off-by: Richard Yao <ryao@gentoo.org>
Conflicts:
defaults/initrd.scripts
call_func_timeout permits us to call a helper function and kill it
should it exceed some timeout. This is derived from example code posted
on Stack Overflow:
http://stackoverflow.com/a/11056286
Signed-off-by: Richard Yao <ryao@gentoo.org>
Conflicts:
defaults/initrd.scripts
At least one kernel configuration generates an addition module that we
need to load for USB 3.0 support, so lets load it.
Reported-by: Robin Johnson <robbat2@gentoo.org>
Signed-off-by: Richard Yao <ryao@gentoo.org>
udev may still be processing rules and this can cause very bad
things. For instance, modules_load may have loaded an usb host
controller driver and we must wait for the udev rules to terminate.
However, this may lead to other race conditions, but we have
observed that adding scandelay=n where n >= 5 actually fixes the
issue of booting off USB under certain scenarios.
"quiet" is already used by the kernel to avoid printing messages on the
console unless they are errors or warnings. Genkernel should do the same
wrt its initramfs initialization code.
This has also the advantage of improving the boot speed.
scandelay=<secs> should be always preferred. Moreover, nowadays
automatically sleeping waiting for USB storage to come up in
the way we were used to do it doesn't work as one expects, because
USB is very common and USB storage devices are very likely to be
present on a system.
Furthermore, the initialization code after setup_slowusb is already
waiting for devices to come up.
While this makes out of the box booting a bit harder on some ancient CD/DVD
drives, it really speeds up the common use case by not sleeping for 3 seconds.
Our modprobe is an ancient heritage from the past, probably dating to
a time where busybox's modprobe features were limited. There is no reason
at all to keep using our own version instead of the busybox one.
This commit also makes modules_scan 15% faster.
Nearly every general documentation including the one in the
kernel tree and the scripts for GRUB2 all expects this flag
to work.
Signed-off-by: Peter Hjalmarsson <xake@rymdraket.net>
If INIT_OPTS='' is not specified before the argument loop, scoping rules
will prevent it from being seen by the switch_root invocation.
Signed-off-by: Toralf Förster <toralf.foerster@gmx.de>
Signed-off-by: Richard Yao <ryao@gentoo.org>
Clean up documentation and functionality of "part" argument to
initramfs. It is meant to imitate the same option to the kernel.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
The default value of ${ZPOOL_USAGE} is unset, quoting it would result into
a "" argument passed to zpool. The workaround to this is to use "dozfs=force"
boot argument.
Signed-off-by: Richard Yao <ryao@gentoo.org>
LUKS keydevs now support mount by UUID/LABEL.
X-Gentoo-Bug: 378105
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=378105
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
We do not support ramdisk, only initramfs nowdays.
So init= is a dead command, and we may as well have it do the same as
it does for dracut and in the Linux kernel documentation.
(Use rdinit to choose the initramfs init file)
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
Somewhere in the mists of time we lost part of the multipath patch, so
we were bundling the userspace, but not the kernel modules, or ever
using it.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
The old driver is problematic, as even with the pata_amd module loaded,
it will not release the device. Disable the old driver on remaining
platforms, add pata_amd where missing & needed (not alpha).
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
Running `mdev -s` will ensure that device nodes are properly initialized.
It does not function as a netlink hotplug daemon. We must run it after
the modules are loaded to ensure that /dev/zfs has been created before
userland programs attempt to use it.
Effective for genkernel's modprobe script or busybox "not small"
modprobe.
Signed-off-by: Dzianis Kahanovich <mahatma@eu.by>
Updated-by: Richard Yao <ryao@cs.stonybrook.edu>
Make ZFS only import the specified pool
Set zfsutil when mounting non-legacy rootfs
Check for /sbin/zpool in addition to /sbin/zfs
Print information messages when ZFS pools are imported
Prompt user when mounting a ZFS filesystem without ZFS support
Verify that <dataset> in real_root=ZFS=<dataset> is a filesystem
Dogfooding of the /usr mount code with the matching OpenRC change to
make the mounts RW revealed some bugs and gotchas in our prior code, now
fixed and verified to work.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
This implements customizable initramfs compression, based on the Pentoo
genkernel fork (SVN revs r2142, r2145, by Jens Pranaitis
<jens@chaox.net>).
New configuration option COMPRESS_INITRD_TYPE to allow manual selection,
whereas the Pentoo fork provided auto-selection based on what was
available in the kernel configuration. Auto-selection is used by
default, and is available with the argument of 'best' to the new option.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
Hello,
Due to the changes in glibc-2.14 busybox no longer compiles when NFS
support is enabled. This breaks genkernel. The following is a very
crude patch to just make things work on glibc-2.14 systems. A better
patch would be to detect glibc-2.14 and then make a config decision.
The best patch would be to port libtirpc to openssl, make busybox link
against libtirpc, restore NFS support, and put an end to this whole
mess. But in the meantime:
commit 80d1e89995f055a37f07f9f7f4c7e21660abd527
Author: Borg Onion <borg.onion@gmail.com>
Date: Sat Dec 3 18:02:48 2011 -0800
Disable NFS support to enable glibc-2.14 compatibility
instead. At the same time, mount cdrom into /mnt/cdrom instead of
/newroot/mnt/cdrom (which is now just a bind mount), this avoids
losetup to expose unavailable paths inside the live system, breaking
mkfs.btrfs (next upstream version, which does silly things with
/proc/mounts).
Set DO_slowusb as default, and make setup_slowusb unset it if it cannot find
a usb-storage attached. This makes genkernel ramdisk adhere to "noslowusb",
makes the ramdisk only wait if there is a usb-storage attached and should fix
gentoo bug #359619.
By adding the kernelcmd options "dokeymap" to MY_HWOPTS instead of
the HWOPTS version, "keymap" this typo broke the handling of keymaps
if you only had "keymap=<...>" in kernelcmd and did not specify "dokeymap"
too (which according to documentation should not be needed).
Only reason for this logic is to limit what entries in /proc/partitions
mdadm scans for arrays.
However this seems to break raids in containers (example Intel fakeraids)
as those containers are never scanned for arrays.
(On my system it activates /dev/md/imsm0, but never /dev/md/Gentoo_0 which
is the real RAID with the removed logic)
If someone has something dead-slow they do not want scanned for raids,
it is better if they specify their own mdadm.conf.
If someone finds an example of something that mdadm scans for arrays that
is not supposed to be scanned, we may handle that then.
This makes the ramdisk always mount some kind of /dev,
and then try to move it to the new root.
This unbreaks handling of nodes created pre-udev likefor example lvm does.
This can be considered good practice, likely less chance that nodes
created in the ramdisk disapperes when switching root.
Some applications (mostly debugging/benchmarking) also needs this to
survive the switch_root.