Sometimes, it is handy to figure out what is going wrong in your initrd file. This can be tricky, as it’s a single script that if it’s breaking, usually results in a kernel panic. I needed to figure out today why the call to mdadm to assemble the raid was not working, so I could add something of value to bug #48844. To debug an initrd.img, here is what I do:
- Boot rescue mode from a Mandriva CD.
- Go to the console, mount your /boot partition into /mnt, unpack your initrd
mount /dev/sda1 /mnt mkdir /mnt/initrd ; cd /mnt/initrd cat ../initrd.img | gzip -d | cpio -i
- copy in bash and necessary libraries to run a shell
cp /lib/* lib/ cp /bin/* bin/ cp /lib64/* lib64/
- edit init and add in /bin/bash at the point you would like a shell
- rebuild your new initrd
find . | cpio -H newc -o | gzip -9 > ../initrd-new.img
- edit ../grub/menu.1st to use your the new initrd-new.img file. Also turn off graphical boot.
- umount /mnt
If you want to run some of the actions in /init from the command line manually, they are nash builtin’s, so cannot be run directly from bash. I run them by creating an file with vi containing
then running the file.