Note: if you are upgrading udev or udev-init-scripts beware that (from udev-204 on), the ebuild silently adds udev to the sysinit runlevel. So before you reboot, make sure to run rc-update del udev sysinit or you will get what looks like dependency errors, with fsck (and udev) starting before lvm/localmount.
Same for udev-trigger.
Note to self: always check: rc-update show and scan across ;) Neither udev nor udev-trigger should be in sysinit; udev-trigger should be in boot (if we're not using an initramfs.)
Warning: If you are on lvm see the notes below.
As many of you will be aware, udev upstream has moved to requiring /usr mounted before it starts. Upstream (including kernel developers) advocates an initramfs across the board for Linux distributions, but definitely in the case where /usr is on a separate partition. This is not down to udev itself, but helper scripts for devices which often live in /usr or sometimes /var, and aiui the hardware database is also on /usr (i guess that bit is down to udev itself;)
This has caused some controversy on the gentoo-user and gentoo-dev mailing lists, as many of us are used to keeping /usr on a separate partition for security and backup purposes (other use-cases for a separate partition include mounting /usr over NFS, or a common partition for virtual machines) and don't want an initramfs, both for startup times and the additional maintenance task of recompiling it at every kernel upgrade/recompile (yes this could be scripted, but we don't see the need.) I've read several times that you can't use LVM on /usr etc without an initramfs, but this has never been an issue for several of us. (I don't have root on LVM, just most other partitions.)
Anyhow, leaving aside the arguments, Gentoo is about choice and in that spirit, I'd like to share the setup I've been using for the last 2 years (so I know it works;) to make udev start after localmount.
NB: Do not use this if you don't know what this is about, don't have /usr or /var on a separate partition, or need some device started by udev in order to mount local filesystems, or start your system (eg a bluetooth keyboard was given as an example on the dev mailing list.)
Having said that, it is simple enough to revert (comment line in /etc/rc.conf, and move udev-trigger to sysinit runlevel again,) so that could be done from a rescue shell (boot with init=/bin/sh and then edit file and run rc-update) or live disk [at worst-- if you can't get a shell] for setups that need udev to mount local drives.
As usual, you are responsible for your own system. This works for me and is easy enough to revert, but don't complain if you have an unusual setup and find you need to boot a live disk and chroot in to fix it (although you're welcome to ask for help, or share the experience. :) This is for people who know they have all the modules built-in the kernel to mount local filesystems, have a separate /usr and/or /var, and are happy with their current setups, apart from possible future issues with udev starting before localmount, and find the requirement for an initramfs sufficiently annoying to tweak their setups, and are willing to deal with keeping the lines in the initscripts during etc-updates.
Basically it consists of patches to 3 initscripts to support a new option initramfs which defaults to no/0.
We need a cross-initscript variable, which goes in /etc/rc.conf so it is active during dependency generation. cf: /lib/rc/sh/gendepends.sh
Config: /etc/rc.conf
Note: There is only one line with any content:
Code: Select all
+#initramfs="YES"Code: Select all
--- /etc/rc.conf
+++ /etc/rc.conf
@@ -104,6 +104,11 @@
# own fstypes to the following variable.
#extra_net_fs_list=""
+# UNSUPPORTED: Allow people with a separate /usr and /var to live without an
+# initramfs. NOTE you MUST use rc-update when changing this variable.
+# See EOF for explanation and rc-update setup. Default="YES"
+#initramfs=YES
+
##############################################################################
# SERVICE CONFIGURATION VARIABLES
# These variables are documented here, but should be configured in
@@ -248,3 +253,38 @@
# execute cgroup_cleanup with /etc/init.d/<service> cgroup_cleanup or
# rc-service <service> cgroup_cleanup.
# rc_cgroup_cleanup="NO"
+
+##############################################################################
+# SPLIT PARTITIONING WITHOUT INITRAMFS (UNSUPPORTED by systemd-udev)
+# Allow people with a separate /usr and /var to live without an initramfs.
+# The problem here is that udev helpers live in /usr and /var, so udev has
+# to start after they have been mounted.
+# To use udev, you MUST have CONFIG_DEVTMPFS set in kernel
+# If you are not using an initramfs (and are *sure* that you don't need one
+# NOR udev to mount /usr and /var) you can set initramfs="NO" to make
+# udev wait for localmount.
+# This also means localmount will umount /usr when it stops.
+# NB: you MUST first have applied the patches from:
+# http://forums.gentoo.org/viewtopic-t-901206.html
+
+## NOTE: to make this work you MUST:
+# rc-update del udev sysinit
+# rc-update del udev-trigger sysinit
+# rc-update add udev-trigger boot
+
+# If you are using LVM, you MUST use: /dev/mapper/vg-lv
+# in /etc/fstab, and not: /dev/vg/lv
+# - dash/hyphen/minus-sign '-' separates, not underscore '_'
+# CONFIG_DEVTMPFS_MOUNT is recommended for LVM.
+
+# If switching initramfs, you MUST also move udev-trigger
+# - udev will be started in the same level via 'need'
+
+# To reset to default (initramfs=YES):
+# rc-update del udev-trigger boot
+# rc-update add udev-trigger sysinit
+
+# To run without an initramfs(=NO) again:
+# rc-update del udev-trigger sysinit
+# rc-update add udev-trigger bootCode: Select all
+#initramfs="YES"Basically all you are doing is moving udev-trigger to boot, not sysinit, so it can start when udev has started, after localmount.
We remove udev from sysinit, so it gets pulled into whichever runlevel udev-trigger is in.
The other changes are to the init scripts for udev and udev-trigger, to support the new option, and to opentmpfiles-dev, to keep the sysinit dependencies correct. The only changes needed are to depend() functions.
/etc/init.d/udev:
Code: Select all
--- /etc/init.d/udev
+++ /etc/init.d/udev
depend()
{
need sysfs dev-mount
- before checkfs fsck
+ if yesno "${initramfs:-YES}";then
+ before checkfs fsck
+ else
+ need localmount
+ fi
keyword -lxc -systemd-nspawn -vserver
}/etc/init.d/udev-trigger:
Code: Select all
--- /etc/init.d/udev-trigger
+++ /etc/init.d/udev-trigger
@@ -10,7 +10,11 @@
depend()
{
need udev
- provide dev
+ if yesno "${initramfs:-YES}"; then
+ provide dev
+ else
+ before sysctl bootmisc net procfs logger termencoding urandom opentmpfiles-setup
+ fi
keyword -lxc -systemd-nspawn -vserver
}
/etc/init.d/opentmpfiles-dev (always in sysinit):
Code: Select all
--- /etc/init.d/opentmpfiles-dev
+++ /etc/init.d/opentmpfiles-dev
@@ -7,8 +7,13 @@
depend()
{
provide tmpfiles-dev tmpfiles.dev
- use dev-mount
- before dev
+ if yesno "${initramfs:-YES}"; then
+ use dev-mount
+ before dev
+ else
+ need sysfs dev-mount
+ provide dev
+ fi
keyword -prefix -vserver
}
dev is usually provided by udev-trigger (which is no longer in sysinit) and used by fsck.
(We cannot patch devfs, as it provides dev-mount, and there are at least two "in-between" services, the other being kmod-static-nodes, also in sysinit, which does the setup for opentmpfiles-dev.)
We also need another, very minor, patch to /lib/rc/sh/init.sh to deal with the red error messages at startup:
Code: Select all
--- /lib/rc/sh/init.sh
+++ /lib/rc/sh/init.sh
@@ -12,13 +12,13 @@
fi
# check for md5sum, and probably /usr too
+got_md5sum=false
if command -v md5sum >/dev/null; then
got_md5sum=true
-else
+elif yesno "${initramfs:-YES}"; then
eerror "md5sum is missing, which suggests /usr is not mounted"
eerror "If you have separate /usr, it must be mounted by initramfs"
eerror "If not, you should check coreutils is installed correctly"
- got_md5sum=false
fi
# By default VServer already has /proc mounted, but OpenVZ does not!Note:
Code: Select all
/dev/vg/lv => vg-lv under: /dev/mapperFor >=sys-fs/lvm2-2.02.100 you'll need these set in /etc/lvm/lvm.conf:
Code: Select all
sysfs_scan = 1
obtain_device_list_from_udev = 0
udev_sync = 1
udev_rules = 0[Thanks to saellaven for working these out.]
CONFIG_DEVTMPFS_MOUNT is also useful, should you ever need to boot into a rescue shell. It means /dev will automatically be mounted by the kernel, which means the /dev/mapper links will be available however you start your machine, IME. While I've seen the links unavailable in sysinit (for 204 upgrade, when udev had been added back to sysinit by the ebuild) whenever I've booted into a rescue shell they have been present (presumably from the dm kernel module.) So you can usually get mount -a to work: if it's a dependency ordering issue, lvm will have already have activated the volumes, albeit too late for fsck; otherwise run:
Code: Select all
pvscan; vgscan --mknodes; vgchange --sysinit -a ly--
So, if you're sure you don't need udev to mount your local drives, you can simply add the new option and change a couple of runlevels via rc-update to get udev to start after they've been mounted. This means full correct udev support, wherever the helper scripts or the hardware database live.
Note: you won't be able to use an encrypted rootfs, or rootfs on LVM, without an initramfs using this, but then you can't do either of those without an initramfs at all. Also, bear in mind that udev-181+ is not supposed to support booting without an initramfs, so be careful upgrading! Remember the note at the top about udev being added to sysinit, without notice.
Effectively, this is not so much a technical requirement as a distribution packaging issue, since all this happens in an initramfs in any case (or how else can it support lvm on /usr?) That's why the original technical specification given, was that "/usr and all file-systems where supporting scripts, binaries, plugins or libraries might live, be mounted and available before udev starts" (to summarise Greg K-H, in case I've not got the words exact.)
HTH,
steveL.





