Penguin

How to eliminate the need for initrd in red hat enterprise linux 4 or Centos 4.

Background

Initrd is normally reserved for modules used to bring up the root filesystem that cannot be linked into the kernel, such as a propriety SCSI or RAID drivers. Once the root filesystem is readable any number of modules can be loaded from disk instead of initrd.

Red Hat Enterprise Linux uses initrd to create temporary device nodes '/dev/console' and '/dev/null' on a ram disk which is used to handle console IO when the kernel hands control to init, at which point udev kicks in and creates its own virtual device nodes.

The trouble is, the console and null devices never exist as real file objects inside the /dev directory, and without them a non-initrd kernel will fail with the dreaded "Warning: no initial console found" message.

The Solution

Create the 'console' and 'null' devices as real files inside /dev.

Boot using the default initrd-based kernel, for me this is:

title Centos-4 i386 (2.6.9-11.EL)
        root (hd0,1)
        kernel /vmlinuz-2.6.9-11.EL ro root=LABEL=/ rhgb quiet
        initrd /initrd-2.6.9-11.EL.img

Log in as root, re-mount your root file-system to a new area (/mnt/root), and copy the console and null device nodes:

mkdir -p /mnt/root
mount /dev/hda3 /mnt/root
cd /dev
cp -a console null tty1 tty2 tty3 /mnt/root/dev

The 'console', 'null', and 'tty' devices are now real files inside the /dev directory and will survive a reboot - unlike the devices created by udev and initrd.

You can also do this by booting the install CD, mounting your root partition, and creating the device files.

etc files

If you created three TTY nodes in the above, edit /etc/inittab to match by removing all but one of the tty's. (the init scripts will launch an additional 2 tty's).

# Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1
# - remove the other 5

Kernel Settings

You can now create a lean and mean kernel without ram disk support, initrd, /dev/pts, or /dev. Details:

Device Drivers/Block Devices

    < > Normal floppy disk support
    < > Compaq SMART2 support
    < > Compaq Smart Array 5xxx support
    < > Mylex DAC960/DAC1100 PCI RAID Controller support
    < > Micro Memory MM5415 Battery Backed RAM support (EXPERIMENTAL)
    <*> Loopback device support
    < >   Cryptoloop Support (NEW)
    < > Network block device support
    < > Promise SATA SX8 support
    < > RAM disk support
    ()  Initramfs source file(s)
    [*] Support for Large Block Devices
    < > Packet writing on CD/DVD media
        IO Schedulers  ---> (only anticipatory)
    < > ATA over Ethernet support

Device Drivers/Character Devices

     [ ] Non-standard serial port support
         Serial drivers  --->
     [ ] Legacy (BSD) PTY support
         IPMI  --->
         Watchdog Cards  --->
     < > Intel/AMD/VIA HW Random Number Generator support
     < > /dev/nvram support
     < > Enhanced Real Time Clock Support
     < > Generic /dev/rtc emulation
     < > Double Talk PC internal speech card support
     < > Siemens R3964 line discipline
     < > Applicom intelligent fieldbus card support
     < > Sony Vaio Programmable I/O Control Device support (EXPERIMENTAL)
         Ftape, the floppy tape device driver  --->
     <*> /dev/agpgart (AGP Support)
     < >   ALI chipset support
     < >   ATI chipset support
     < >   AMD Irongate, 761, and 762 chipset support
     < >   AMD Opteron/Athlon64 on-CPU GART support
     < >   Intel 440LX/BX/GX, I8xx and E7x05 chipset support
     <*>   NVIDIA nForce/nForce2 chipset support
     < >   SiS chipset support
     < >   Serverworks LE/HE chipset support
     < >   VIA chipset support
     < >   Transmeta Efficeon support
     < > Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)
     < > ACP Modem (Mwave) support
     < > RAW driver (/dev/raw/rawN) (OBSOLETE)

Filesystems/Pseudo Filesystems

      [*] /proc file system support
      [ ]   /proc/kcore support
      [ ] /dev file system support (OBSOLETE)
      [ ] /dev/pts Extended Attributes
      [*] Virtual memory file system support (former shm fs)
      [ ]   tmpfs Extended Attributes
      [ ] HugeTLB file system support

Grub Config

remember grub's (hdx,y) syntax is zero based.

splashimage=(hd0,1)/grub/splash.xpm.gz
timeout 10
default 0
fallback 1

title RHEL-4 (2.6.12.3)
kernel (hd0,1)/bzImage-2.6.13 root=/dev/hda3

title Gentoo (2.6.12.13)
kernel (hd0,1)/bzImage-2.6.13 root=/dev/hda9

It's working, but udev fails

This is a false positive. Chances are you've built a static or mostly-static kernel but the '/sbin/startudev' script assumes a module-ladden kernel and fails to load scsi and ide modules (which you've probably builtin).

Edit the script and comment out some of the statements near the end:

kill_udevd

# scsi_replay ...   -\
# ret=$[$ret + $?]    \  comment out these 4 lines if you've builtin SCSI and IDE drivers.
# kill_udevd ...      /
# ide_scan ...      -/

/sbin/udevstart

Now reboot and you should see 'OK' in green letters.