kernel presentation at ILUG on Sat.

Charles Steinkuehler charles at steinkuehler.net
Mon May 5 16:48:48 CDT 2003


James Sissel wrote:
> Thank you, Charles.  It was an excellent presentation.
> 
> One part I missed.  How did you uncompress and mount the initrd?  I'd like
> to take a look at my current one.  If I modified it how would I recompress
> it back into an .img?

The initial ramdisk images are simply gzipped filesystem images, so you 
can gzip or gunzip as appropriate to go between the .img format used to 
boot and the "raw" format you can mount with the loopback option.

Other notes:

The .img extension for an initial ramdisk is simply a convention used by 
some distributions...the initial ramdisk filename can be anything 
allowed by your file system and boot-loader.

The kernel attempts to automatically recognize the file system type of 
the initial ramdisk image.  Support for the file system type used for 
the initial ramdisk (typically ext2 or minix) must be compiled into the 
kernel.  The kernel can also recognize a gzipped image, which will be 
uncompressed before the kernel tries to identify the file system type.

IIRC, you do not have to compress the ramdisk image if you don't want 
to, which would allow for easier "tweaks" if you're experimenting.  By 
convention, initial ramdisk images are usually compressed to save space, 
much like the kernel itself (which can also be stored in uncompressed 
form, if desired).

To uncompress and mount an initial ramdisk file, then re-create a new 
initial ramdisk image (from a handy RH7.2 system):

[root at falcon boot]# cd /boot
[root at falcon boot]# gunzip <initrd-2.4.9-13.img >/tmp/image
[root at falcon boot]# mount -o loop /tmp/image /mnt

...<edit ramdisk image at /mnt as desired>...

[root at falcon boot]# gzip </tmp/image >initrd-2.4.9-13-new.img

...edit bootloader as desired (or manipulate filenames) to use new 
ramdisk image.  If you're using lilo, remember to run lilo at the 
command prompt to update the block-map file.  Grub users can simply reboot.

-- 
Charles Steinkuehler
charles at steinkuehler.net




More information about the Kclug mailing list