udev in initrd

Thomas Woerner twoerner at redhat.com
Fri May 28 16:05:13 UTC 2004


There are test packages in http://people.redhat.com/twoerner/UDEV/ for using 
udev in initrd with persistent devices.

Usage
-----

- If you want to enable udev in initrd, then install the test packages and
   create an initrd with mkinitrd.
- If you want to turn off udev, set USE_UDEV="no" in /etc/sysconfig/udev.
- For another udev root directory (not /dev) set udev_root="/some dir/" in
   /etc/udev/udev.conf - This will not disable udev in initrd. The result is an
   unusable initrd
- For disabling persistent /dev filesystem set UDEV_KEEP_DEV="no" in
   /etc/sysconfig/udev. Your /dev filesystem will not be the same in inird and
   the running system.
- You have to recreate the initrd after changing any of these options.


Warnings
--------

- The new mkinitrd is not tested heavily (especially lvm support).
- It will not work with devfs.
- Make a backup copy of the original initrd (best is to make an additional
   boot entry in grub with the new initrd)


Information about udev and the new mkinitrd
-------------------------------------------

The benefit of udev is that there are only those device nodes which are bound 
to devices in your computer and that you can have additional device naming 
schemes like 'by label' or 'by id'.
However there is a small problem with dynamic device nodes: For all devices, 
which are not recognized before a specific module is loaded, there will be no 
device node until the driver is loaded either by hand of by a program. kudzu 
would be a good candidate for this, but it has to be started earlier, then.

udev is using helpers for additional device naming schemes, which are c 
programs or shell scripts. Therefore it is necessary to put tools like sed, 
awk, grep and so on in the initrd. These programs are not small and the initrd 
would be very big. The solution for this is to use a static compiled busybox, 
which combines tiny versions of many utilities into a single executable.

Thus the new mkinitrd is using busybox for the initrd with udev support. 
Disabling udev results in a normal initrd with nash. It is easy to modify 
mkinitrd to build the normal initrd with busybox.


Here are the flowcharts for the standard initrd of fc2 (without lvm support) 
and the udev version:

Standard initrd - using nash
----------------------------
1) mount /proc and /sys in initrd
2) load modules (eg: controller, filesystem)
3) umount /sys
4) locate root device
5) create block devices
6) mount system root on /sysroot
7) change root to /sysroot and initrd to /sysroot/initrd
8) umount /initrd/proc


udev initrd - using busybox and ramfs
-------------------------------------
1) mount /proc and /sys
2) mount /dev as ramfs
3) create initial devices (eg: console, null, zero, loopX) and links for std
    files
4) start udev, use udevsend as hotplug
5) load modules (eg. controller, filesystem)
6) umount /sys
7) locate root device
8) mount system root on /sysroot
9) bind /dev to /sysroot [UDEV_KEEP_DEV="yes"]
10) change root to /sysroot and initrd to /sysroot/initrd
11) umount /initrd/proc
12) umount /initrd/dev [UDEV_KEEP_DEV="yes"]



Have fun,
Thomas

-- 
Thomas Woerner, Software Developer     Phone: +49-711-96437-0
Red Hat GmbH                           Fax  : +49-711-96437-111
Hauptstaetterstr. 58                   Email: twoerner at redhat.com
D-70178 Stuttgart                      Web  : http://www.redhat.de/





More information about the fedora-devel-list mailing list