Gregory Hildstrom Projects Publications Resume Links Contact About Google+ Facebook Youtube Donate




undev

undev is a combination of boot loader configuration, rc.sysinit modification, custom initrd, and the undev executable. Undev is designed to disable udev, which is now standard on many Linux distributions. Udev dynamically manages the special files in /dev, which is usually mounted as a tmpfs. This behavior is undesirable for certain applications. The aim of undev is to change /dev from an automatically generated tmpfs back to a standard directory on a persistent filesystem.
    Process for Disabling udev
  1. recreate /dev special files on persistent root filesystem
  2. disable mounting /dev as tmpfs with custom initrd
  3. disable udev from /etc/rc.sysinit
  4. update boot loader with custom initrd

undev executable

Here is the basic documentation from the code in undev.tar.gz:
undev 200706011020
This program is designed to aid the disabling of udev, which is now standard on
many linux distributions. Udev dynamically manages the special files in /dev,
which is usually mounted as a tmpfs. This behavior is undesirable for certain
applications.

Undev recursively parses the dev directory on a running udev system and creates
a script that can re-create all of the special files in /dev. The process works
as follows on my FC6 test system:
* cd /dev            (move to the desired folder)
* /undev ./          (create undev.sh script using relative paths)
* sync
* reboot
* boot Damn Small Linux from CD
* sudo su            (become root)
* mount /dev/hda2    (my root ext3 partition, must be RW)
* cd /mnt/hda2/dev   (move to the root partition's /dev folder)
* ls                 (should be an empty directory)
* pwd                (should print /mnt/hda2/dev)
* /undev.sh          (prints tons of output and error messages)
* ls -l              (should be full of special files)
* /undev.sh          (for links not created the first time, like cdrom -> hdc)

custom initrd

Extracting the contents of the default initrd.img will yield a bunch of basic Linux files and directories required for booting. One of these files, on my stock FC6, is called init. This is the first script to be called during the boot process and it is responsible for mounting /dev as a tmpfs. I simply commented out the 9th line responsible for mounting /dev as a tmpfs and recreated a custom initrd called undevrd.img.
#!/bin/nash

mount -t proc /proc /proc
setquiet
echo Mounting proc filesystem
echo Mounting sysfs filesystem
mount -t sysfs /sys /sys
echo Creating /dev
#mount -o mode=0755 -t tmpfs /dev /dev
mkdir /dev/pts
mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts
mkdir /dev/shm
mkdir /dev/mapper
echo Creating initial device nodes
mknod /dev/null c 1 3
mknod /dev/zero c 1 5
mknod /dev/systty c 4 0
mknod /dev/tty c 5 0
mknod /dev/console c 5 1
mknod /dev/ptmx c 5 2
mknod /dev/rtc c 10 135
mknod /dev/tty0 c 4 0
mknod /dev/tty1 c 4 1
mknod /dev/tty2 c 4 2
mknod /dev/tty3 c 4 3
mknod /dev/tty4 c 4 4
mknod /dev/tty5 c 4 5
mknod /dev/tty6 c 4 6
mknod /dev/tty7 c 4 7
mknod /dev/tty8 c 4 8
mknod /dev/tty9 c 4 9
mknod /dev/tty10 c 4 10
mknod /dev/tty11 c 4 11
mknod /dev/tty12 c 4 12
mknod /dev/ttyS0 c 4 64
mknod /dev/ttyS1 c 4 65
mknod /dev/ttyS2 c 4 66
mknod /dev/ttyS3 c 4 67
echo Setting up hotplug.
hotplug
echo Creating block device nodes.
mkblkdevs
echo "Loading uhci-hcd.ko module"
insmod /lib/uhci-hcd.ko
echo "Loading ohci-hcd.ko module"
insmod /lib/ohci-hcd.ko
echo "Loading ehci-hcd.ko module"
insmod /lib/ehci-hcd.ko
mount -t usbfs /proc/bus/usb /proc/bus/usb
echo "Loading jbd.ko module"
insmod /lib/jbd.ko
echo "Loading ext3.ko module"
insmod /lib/ext3.ko
mkblkdevs
resume LABEL=SWAP-hda3
echo Creating root device.
mkrootdev -t ext3 -o defaults,ro hda2
echo Mounting root filesystem.
mount /sysroot
echo Setting up other filesystems.
setuproot
echo Switching to new root and running init.
switchroot

rc.sysinit modification

Only one modification to /etc/rc.sysinit was required on my FC6 test system. I commented out line 333 that starts udev. Here is a segment of the modified /etc/rc.sysinit file.
nashpid=$(pidof nash 2>/dev/null)
[ -n "$nashpid" ] && kill $nashpid >/dev/null 2>&1
unset nashpid
#/sbin/start_udev

boot loader configuration

I created another entry in /boot/grub/grub.conf to allow booting the stock FC6 kernel with the stock initrd.img or booting the stock FC6 kernel with the modified undevrd.img. Here is my modified grub.conf.
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/sda2
#          initrd /initrd-version.img
#boot=/dev/sda
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Fedora Core (2.6.18-1.2798.fc6)
	root (hd0,0)
	kernel /vmlinuz-2.6.18-1.2798.fc6 ro root=LABEL=/1 rhgb quiet
	initrd /initrd-2.6.18-1.2798.fc6.img
title FC6 stk krnl custom undevrd.img
	root (hd0,0)
	kernel /vmlinuz-2.6.18-1.2798.fc6 ro root=LABEL=/1 rhgb quiet
	initrd /undevrd.img