migration from eudev to mdev

If you are using gentoo and have tracked notifications of upcoming changes, then back in July you might have seen that gentoo will no longer support eudev as of the new year. If you try to update the system now, you will see

!!! The following installed packages are masked:
- sys-fs/eudev-3.2.10-r1::gentoo (masked by: package.mask)
/var/db/repos/gentoo/profiles/package.mask:
# Mike Gilbert <floppym@gentoo.org> (2021-11-27)
# eudev will be removed on 2022-01-01.
# Please see the news item published on 2021-08-24 for more information.

Unfortunately, moving from eudev to alternatives has its own characteristics, which I want to highlight in this post while my memory is fresh. I have been interested in trying mdev for a long time, so the news of the end of support for eudev I took as a hint that it was time to do what we had planned. Important note: I have gentoo running on headless servers. If you need to update your desktop machine, things can be a little more complicated, read documentation

The first problem was that the system wanted to install sys-fs / static-dev, but could not do it with this error:

>>> Running pre-merge checks for sys-fs/static-dev-0.1-r2
 * We have detected that you currently use udev or devfs or devtmpfs
 * and this ebuild cannot install to the same mount-point.
 * ERROR: sys-fs/static-dev-0.1-r2::gentoo failed (pretend phase):
 *   Cannot install on udev/devfs tmpfs.

V https://bugs.gentoo.org/107875#c25 a solution is given to get out of this situation:

$ sudo mkdir /tmp/newroot
$ sudo mount -o bind / /tmp/newroot
$ sudo ROOT=/tmp/newroot/ emerge -av sys-fs/static-dev
$ sudo umount /tmp/newroot/

Now the package is delivered and you can start migrating to mdev. Let’s start by making sure we don’t have anything tied to udev, otherwise we won’t be able to switch to mdev.

Let’s check that there are no unexpected dependencies on udev. It looked like this to me:

$ equery d udev
 * These packages depend on udev:
sys-apps/hwids-20210613-r1 (virtual/udev)
sys-fs/udev-init-scripts-34 (>=virtual/udev-217)
virtual/dev-manager-0-r2 (virtual/udev)
virtual/libudev-232-r5 (!systemd ? >=sys-fs/udev-232:0/0[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_s390_32(-)?,abi_s390_64(-)?])
virtual/udev-217-r3 (>=sys-fs/udev-217)
$

Remove udev from use:

$ sudo euse -D udev

This will preserve the old version of /etc/portage/make.conf, so you can easily check that the change is exactly what you need and revert to the old config if necessary.

Now you can do a dummy rebuild run of the world:

$ sudo emerge -uDNvp @world

If there are no errors or unexpected packets in the output, then you can continue.

First, we need to mask sys-fs / udev

$ echo "sys-fs/udev"|sudo tee /etc/portage/package.mask/mdev

Now you can add static and mdev support to build busybox

$ echo "sys-apps/busybox static mdev"|sudo tee /etc/portage/package.use/mdev

Building busybox

$ sudo emerge --ask --oneshot busybox

We see:

The following USE changes are necessary to proceed:
 (see "package.use" in the portage(5) man page for more details)
# required by sys-apps/busybox-1.34.1::gentoo[static]
# required by @selected
# required by @world (argument)
>=virtual/libcrypt-2 static-libs
# required by virtual/libcrypt-2::gentoo
# required by sys-apps/busybox-1.34.1::gentoo[static]
# required by @selected
# required by @world (argument)
>=sys-libs/libxcrypt-4.4.25-r1 static-libs

It turns out that you need to slightly update the build settings of some libraries. We do this, run emerge again, in my case everything was assembled without problems.

After that, you need to add a script to mount devpts, which is not mounted automatically at boot or via mount -a. In the same script, you need to correct the access rights to / dev / shm, since by default only root has access.

$ echo -e '#!/bin/bashnmount devptsnchmod 1777 /dev/shm'|sudo tee /etc/local.d/000.start
#!/bin/bash
mount devpts
chmod 1777 /dev/shm
$ sudo chmod +x /etc/local.d/000.start

Now you can enable mdev to start at system initialization and disable udev and udev-trigger (the official documentation does not write anything about the latter).

$ sudo rc-update add mdev sysinit
 * service mdev added to runlevel sysinit
$ sudo rc-update del udev sysinit
 * service udev removed from runlevel sysinit
$ sudo rc-update del udev-trigger sysinit
 * service udev-trigger removed from runlevel sysinit
$

An important point: on one of the machines I used predictable interface names and the interface was called enp1s0. After switching to mdev, this interface became eth0. I didn’t rename the file to /etc/init.d or fix /etc/conf.d/net, so after rebooting I had to use the serial console to login and fix it. If you have predictable interface names, do not repeat my mistake.

Now you can reboot.

sudo reboot

If everything went well, then you can rebuild the system.

$ sudo emerge -uDNva @world

And remove packages that are no longer needed.

$ sudo emerge --ask --depclean --verbose sys-fs/udev sys-fs/eudev

Similar Posts

Leave a Reply

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