How to Modify Red Hat Boot Disks and Driver Disks
Updated January 31, 2002
Created January 30, 2002

  1. Set up a workplace
  2. 
    mkdir /tmp/unpack
    cd /tmp/unpack
    
  3. Grab something to work with
  4. 
    cp /mnt/cdrom/images/boot.img .
    
  5. Dig into the disk (any of boot.img, bootnet.img, drivers.ing, etc...)
  6. 
    mkdir disk.dir
    mount boot.img disk.dir -o loop
    
  7. Grab a copy of the initrd and uncompress it
  8. 
    cp disk.dir/initrd.img initrd.img.gz
    gunzip initrd.img.gz
    
  9. Dig into the initrd
  10. 
    mkdir initrd.dir
    mount initrd.img initrd.dir -o loop
    
  11. What is important in the initrd


  12. Initrd calls /linuxrc which then loads drivers from the modules.cgz file which resides in the /modules directory (in the same initrd file). If all you are doing is adding in modules for different hardware into one of the default Red Hat boot disks, then you only need to modify the files that exist in the /modules directory. Files of interest in the /modules directory are module-info, modules.dep, pcitable, and modules.cgz.

  13. Dig into the modules.cgz file
  14. 
    cd /tmp/unpack
    mkdir modules
    cd modules
    zcat ../initrd.dir/modules/modules.cgz | cpio -idvm
    cd ..
    
  15. Modifying modules.cgz




  16. Modifying module-info


  17. Modifying modules.dep


  18. Modifying pcitable


  19. See if you have an existing entry for pcitable from wherever you copied the driver from. If you don't have an entry, don't worry, things may work without modifying this file.

  20. Repacking modules.cgz
  21. 
    cd /tmp/unpack/modules
    find 2.4.7-2BOOT/ | grep -v "BOOT/$" | cpio -o -H crc >modules.cpio
    gzip -9 -n modules.cpio
    mv modules.cpio.gz modules.cgz
    
  22. Repacking initrd.img


  23. Before moving modules.cgz back into the initrd, make sure that it is the same size or smaller than the original one.
    
    cd /tmp/unpack
    ls -ltr initrd.dir/modules/modules.cgz modules/modules.cgz
    
    If the new modules.cgz is bigger than the original modules.cgz, then you will most likely get the modules.cgz back into the initrd.img; however, the initrd.img, will then probably be too big for the boot floppy. Consider throwing drivers you don't need out of modules.cgz such as SCSI or Network Cards you don't have or don't plan on using. Even though there is plenty of space available in the initrd.img, there is only so much space available in the boot disk - and gzip is expecting much of the initrd.img file to be blank.

    Do the same kind of check on any of the other files you modified, such as modules.cgz, modules.dep, module-info, and pcitable, etc.
    
    cd /tmp/unpack
    for X in modules.dep, modules.cgz, module-info, pcitable; do \
    ls -ltr modules/$X initrd.dir/modules/$X; done
    
    Once you have compared the sizes of the various files then place them back into the initrd.dir.
    
    cd /tmp/unpack
    mv modules/modules.cgz initrd.dir/modules/modules.cgz
    mv modules/modules.dep initrd.dir/modules/modules.dep
    mv modules/module-info initrd.dir/modules/module-info
    mv modules/pcitable initrd.dir/modules/pcitable
    
    We need to blank out the unused portions of initrd - this is needed so gzip doesn't try to compress data that we have already deleted out.
    
    cd /tmp/unpack
    dd if=/dez/zero of=initrd.dir/zero
    rm initrd.dir/zero
    
    Unmount initrd.dir
    (This action finishes writing any cached information out to initrd.img, then it disconnects initrd.img from the initrd.dir directory. This behavior is just the same as working with a floppy under Linux - mount the floppy, work with it, unmount it - unmounting the floppy finishes writing any leftover information to the floppy, then returns to the prompt).
    
    cd /tmp/unpack
    umount initrd.dir
    
    Now gzip up initrd.img
    Note: The "file" utility can tell you if a file is compressed or not.
    
    cd /tmp/unpack
    gzip -9 -n initrd.img
    mv initrd.img.gz initrd.img
    
  24. Repacking the Disk


  25. Before moving the initrd.img back into the disk image, make sure that it is the same size or smaller than the original one.
    
    cd /tmp/unpack
    ls -ltr initrd.img disk.dir/initrd.img
    
    If you need more space in the disk image, you are able to remove all the disk.dir/*.msg files, but that is just about all the extra space you can get.

    Place the initrd.img back into the disk image
    
    cd /tmp/unpack
    mv initrd.img disk.dir/initrd.img
    
    Unmount the disk image - see note above on unmounting initrd.img for an understanding of why it is necessary to unmount the disk image.
    
    cd /tmp/unpack
    umount disk.dir
    
  26. Troubleshooting steps if initrd.img no longer fits on the boot disk


  27. Notes on initrd


  28. Important parts of an initrd are as follows:
    
    When initrd boots, it immediately runs /linuxrc
    
    SCSI modules are located in the /lib directory
    
    bin
     insmod
     sash
    dev
     console (5,1)
     null (1,3)
     ram (1,1)
     systty (4,0)
     tty1 (4,1)
     tty2 (4,2)
     tty3 (4,3)
     tty4 (4,4)
    etc
    lib
     ncr53c8xx.o
    linuxrc
    loopfs
    
    
    Contents of linuxrc
    
    #!/bin/sash aliasall echo "Loading ncr53c8xx module" insmod /lib/ncr53c8xx.o
    pcitable contains information similar to "lspci" and "lspci -n"

DATESORT
Search this site powered by FreeFind







1