udevadm trigger is not permitted while udev is unconfigured (workaround)

Today I fixed an unbootable ubuntu installation: it said:

lvmetad is not active yet

It then dumped to an initramfs shell, in which lvm pvs reported nothing but errors.  /proc/partitions showed nothing that looked like the root filesystem. Running udevadm trigger produced the following response:

udevadm trigger is not permitted while udev is unconfigured

However, nothing explained why udev was unconfigured.

The cause of this is that the udev package contains a wrapper script for udevadm which is supposed to exist only during the installation of udev.  This script is not actually capable of doing anything, but stops udevadm messing things up during an upgrade.

When udev remains unconfigured at the time that update-initrd is run, then the generated initrd image contains a copy of a non-working udevadm command.  This command cannot be used to activate user devices, and so things like hard disks, partitions, filesystem and LVM partitions fail to exist.  The boot loader could not find its LVM, because it couldn’t find the device that the LVM is on, because it didn’t load the driver for the controller for that device.

The fix is to help the udevadm upgrade to complete (or at least not be totally broken), and then re-generate the initramfs with working code:

root@urk:/bin# cp udevadm.upgrade udevadm

root@urk:/bin# update-initramfs -k all -c
update-initramfs: Generating /boot/initrd.img-3.13.0-32-generic

root@urk:/bin# apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 162 not upgraded.
8 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up udisks2 (2.1.7-1ubuntu1) ...
// etc

When udev is unconfigured, the udevadm script is just a wrapper that says to refuse to run the actions trigger (look for new devices) and settle (wait for existing devices):

#!/bin/sh

if [ "$1" = "trigger" ]; then
    echo "udevadm trigger is not permitted while udev is unconfigured." 1>&2
    exit 1
fi

if [ "$1" = "settle" ]; then
    echo "udevadm settle is not permitted while udev is unconfigured." 1>&2
    exit 1
fi

exec /bin/bash -c "exec -a \"\$0\" /bin/udevadm.upgrade \"\$@\"" "$0" "$@"

The fact that the script uses both /bin/sh and /bin/bash says that it was done without certain types of required forethought.

This entry was posted in Stuff and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *