ORC Owl Logo 2  

Owl River Company

 
  Your IP is: 54.80.227.189


   http://www.owlriver.com/tips/mkinitrd_discussion/

Adding required modules for a Linux kernel initrd (Initial Ram Disk)

Some people cannot resist buying bleeding edge, or hardware without explicit support in the then current Linux kernel's modules set. This outline and discussion is for them, to help get the needed modules in place in the initrd (Initial Ram Disk), and to gently point that this pain is unnecessary, if one supports only vendors who support Free Software.

  1. Find that file (or files) for the needed additional required modules -- these are very customarily the SCSI and raid controller drivers. If a given module was previously properly inserted, it will probably already be in the filesystem tree somewhere:
    	find /lib/modules/  -name whatever.ko
    
  2. If they are not on a running local system already, one has a game of 'hide and go seek' ahead, on the vendor's website and materials. New installs involve a 'driver disk' when using the Anaconda installer; good practice dictates cacheing a copy of the modules image in a prominent location on every newly built box needing such matter.
  3. Make the required '`uname -r`/updates/' directories (one for each kernel variant found at /lib/modules )
    for i in `find /lib/modules  -maxdepth 1  -type d | grep "modules/2."`; do
    	echo $i
    	[ ! -d $i/updates/ ] && mkdir -p $i/updates/
    done
    
  4. Position a copy of those modules for each kernel, to the extent not already there:
                    /lib/modules/2.6.whatever/updates/whatever.ko
    
  5. The adjunct modules also need to be able to be loaded, for the mkinitrd script to work properly. That script inventories the modules present as it runs.
  6. Place copies at the same relative place for the CURRENTLY RUNNING kernel, for the next step to work -- this is a better prectice (the next level 0 backup will catch an archival copy as part of regular operations so it is less likely to be permamently lost even if the hardware vendor drops off the face of the earth), and to my thinking constitutes: "previously properly inserted" as mentioned in para. 1
  7. Rebuild the modules dependency table. Run: depmod
    	/sbin/depmod -a
    
  8. Get the needed modules loaded. Run:
    modprobe whatever
    
    (we drop the .ko)
  9. Build a custom initrd. Run: mkinitrd
    	mkinitrd -v image kernel-version
    

    where:
    
    	(image) is something like: initrd-custom-2.6.9-42.0.10.EL.img
    	(kernel-version) [in this instance] 2.6.9-42.0.10.EL
    
    We place the distinctive .img at the end to remind us of its type, a gzip compressed data initial ram disk ;) grub, and the kernel know to deal with this.
  10. As a matter of local practice, I use the notation 'custom' in the name, so that then I am sorting through images in /boot/, I do not accidentially munge one which the system tools expects to be present.
  11. This makes a clean initrd if all goes well, with all needed modules present -- position it:
    	cp initrd-custom-2.6.9-42.0.10.EL.img /boot/
    
  12. edit: /boot/grub/grub.conf I usually copy the top vmlinuz stanza and make the edits so that looks like this;
    [herrold@centos-4 ~]$ sudo cat  /boot/grub/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/hda6
    #          initrd /initrd-version.img
    #boot=/dev/hda
    #
    #       060316 - fall back to 2.6.9-22.0.2.EL kernel
    default=0
    fallback 2
    timeout=10
    # splashimage=(hd0,0)/grub/splash.xpm.gz
    # hiddenmenu
    title CentOS (2.6.9-42.0.10.EL)
            root (hd0,0)
            kernel /vmlinuz-2.6.9-42.0.10.EL ro root=/dev/hda9 selinux=0
            initrd /initrd-2.6.9-42.0.10.EL.img
    title CentOS (2.6.9-42.0.10.EL) custom
            root (hd0,0)
            kernel /vmlinuz-2.6.9-42.0.10.EL ro root=/dev/hda9 selinux=0
            initrd /initrd-custom-2.6.9-42.0.10.EL.img
    title CentOS (2.6.9-42.0.2.EL) custom
            root (hd0,0)
            kernel /vmlinuz-2.6.9-42.0.2.EL ro root=/dev/hda9 selinux=0
            initrd /initrd-custom-2.6.9-42.0.2.EL.img
    title Memtest86+ (1.26)
            root (hd0,0)
            kernel /memtest86+-1.26 ro root=/dev/hda9
    
  13. Notice here that we have the following changes fro the stock upstream:
    1. We have a fallback kernel, which is known to work, from a prior update
    2. We have set the 'fallback' option up, in case things are unhappy, as a reminder to ourself that it is there
    3. We have lengthened the boot timeout to ten seconds, and gotten rid of the splash, as the LCD panels we use seem to take a few seconds to stabilize and synchronize to the refresh intervals
    4. We happen to have a local copy of memtest86+ so that we can boot into the ram tester if any question on the hardware arises.
  14. NOTICE -- We let the updater place what it thinks should work, and do its updating, unmolested. We come in afterward, and then inserted the amended stanza at position 1 (counting starts at zero in the grub.conf as to stanza's to use). We DO NOT to LEAVE it pointing at stanza 0 -- we will catch and start stanza 1, and do our testing. Once we are confident that it is never going to be needed, we DELETE the old stanza 0, and then amend the fallback line.

===============================================
adding-required-modules.txt
rev 070303 RPH
http://www.owlriver.com/tips/mkinitrd_discussion//

Up More Tips
       

Back to Top Page
[legal] [ no spam policy ] [ Copyright] © 2008 Owl River Company
All rights reserved.

Last modified: Sat, 03 Mar 2007 17:52:58 -0500
http://www.owlriver.com/tips/mkinitrd_discussion/index.php