Skip to content

Old images single kernel initrd

gregdek edited this page Mar 21, 2013 · 1 revision

(Note: this content is from the old projects.eucalyptus.com site and may be outdated.)

h1. Modifying Initrd

As mentioned previously, one way to deal with the root device been different depending on the hypervisor and the hypervisor configuration, is to modify the initrd to allow for this variety. This is what we did to modify the initrd:

  • get the initrd.gz to be modified: it should be a compressed file (gzip);
  • uncompress it
zcat initrd.gz > /tmp/initrd
  • the end result should be a cpio archive: using the command file note the typo of cpio archive for example
initrd: ASCII cpio archive (SVR4 with no CRC)
  • extract the archive:
mkdir /tmp/test
cd /tmp/test
cat /tmp/initrd |cpio -id
  • modify it! In our case we modify the local scrips in scripts/local. Using an initrd from Debian, we modified the function pre_mountroot() we added the following:
                 # nasty hack for instances: let's force known roots
                 for z in $(/bin/ls /dev/vd[a-z]1 2> /dev/null) ; do
                         ROOT="${z}"
                         if [ -e "${ROOT}" ]; then
                                 return
                         fi
                 done
                 for z in $(/bin/ls /dev/xvd[a-z]1 2> /dev/null) ; do
                         ROOT="${z}"
                         if [ -e "${ROOT}" ]; then
                                 return
                         fi
                 done
                 for z in $(/bin/ls /dev/hd[a-z]1 2> /dev/null) ; do
                         ROOT="${z}"
                         if [ -e "${ROOT}" ]; then
                                 return
                         fi
                 done
 

and we added just before giving up:

        # We've given up, but we'll let the user fix matters if they can
        while [ ! -e "${ROOT}" ]; do

The modification simply look for the known root devices (sda, xvda, vda etc ...) and try to blindly mount it

  • repackage the archive using
find ./ | cpio -oH  > /tmp/initrd.new

using the format you discovered previously. In our case it is newc;

  • compress the archive
gzip initrd.new
Clone this wiki locally