Next Previous Contents

9. Modifying the RedHat installer

If you want to mess around with the installation procedure itself, the source code can be found on the RedHat CD-ROM or your local RedHat mirror site. It's in misc/src/install under the i386 distribution top level directory.

If you examine the RedHat boot disk you'll see that, in addition to the Linux kernel vmlinuz, there's a large file initrd.img:

- -rwxr-xr-x   1 root     root          559 May 11 15:48 boot.msg
- -rwxr-xr-x   1 root     root          668 May 11 15:48 expert.msg
- -rwxr-xr-x   1 root     root          986 May 11 15:48 general.msg
- -rwxr-xr-x   1 root     root       968842 May 11 15:48 initrd.img
- -rwxr-xr-x   1 root     root         1120 May 11 15:48 kickit.msg
- -r-xr-xr-x   1 root     root         5352 May 11 15:48 ldlinux.sys
- -rwxr-xr-x   1 root     root          875 May 11 15:48 param.msg
- -rwxr-xr-x   1 root     root         1239 May 11 15:48 rescue.msg
- -rwxr-xr-x   1 root     root          402 May 11 15:48 syslinux.cfg
- -rwxr-xr-x   1 root     root       444602 May 11 15:48 vmlinuz

You guessed it, this is another ext2 filesystem saved as a file - - but with a twist. It's actually compressed as well. You can uncompress it and then mount the result, e.g.

# gzip -dc /mnt/boot/initrd.img >/tmp/initrd.ext2
# mkdir /mnt/initrd
# mount -o loop /tmp/initrd.ext2 /mnt/initrd

Probably the most important part of this filesystem is the collection of loadable kernel modules which are included with the boot disk. If you need to merge in a new version of a driver, you'll need to either replace vmlinuz with a new kernel which has this statically linked, or replace it in the modules collection. What's more, you may need to throw other modules away to make room.

The modules collection is the file modules/modules.cgz. Wondering what that might be ? It's actually a compressed cpio archive, believe it or not! And you thought nobody used cpio any more... Actually RPM itself uses cpio internally, too. Here's how to hack around with it:

# gzip -dc /mnt/initrd/modules/modules.cgz >/tmp/modules.cpio
# cpio -itv <modules.cpio >modules.listing
# mkdir modules
# cpio -idumv <../modules.cpio

I don't believe that there is currently a way under Linux (at least in mainstream distributions) to transparently access compressed filesystems. Let me know if you know better!

If you change anything, remember to:

  1. Use cpio to recreate the archive. How to do this is left as an exercise for the reader...
  2. Use gzip to compress the resulting archive.
  3. Copy it to /mnt/initrd, or wherever you put the uncompressed initrd.img archive.
  4. Unmount /mnt/initrd (or whatever you called it).
  5. Compress the new initrd.img using gzip again.
  6. Copy the resulting archive onto the boot disk image - /mnt/boot/initrd.img in our example.
  7. Unmount the boot disk image, e.g. /mnt/boot.

Finally, you can now create new boot floppies using this modified boot disk setup, e.g.

# cat boot.img >/dev/fd0


Next Previous Contents

Hosting by: Hurra Communications Ltd.
Generated: 2007-01-26 17:58:10