grub-internals: rescue-disk
 

The grub rescue disk (old version)

note:
 grub_svn has moved to bazaar_repo ; refer to more recent grub2 (oct 2011) to :
          
                 https://sites.google.com/site/wjhowto/ext2-diskfile-for-grub2

grub comes with 2 choices : floppy and cdrom rescue-disk.It is interesting to use a locally_build svn_grub under qemu without installing to the host PC avoiding system screw-up by unintentional typing !

svn co [-r2172] svn://svn.savannah.gnu.org/grub/trunk/grub2

option [-r2172] means svn revision #2172 ; absence of -r option gives the latest svn_tree.


"cd grub2 && ./autogen.sh && ./configure && make" builds "standard compilation" .

mkdir ovl
./grub-mkrescue --pkglibdir=. --overlay=ovl --grub-mkimage=./grub-mkimage --image-type=cdrom cdrescue.iso

Populate the ovl_dir with what ever you want,more modules , scripts in order to play with grub ; they will comeup with your booting cdrescue !
Replace "cdrom cdrescue.iso" by "floppy rescue.floppy " and you get the ancestral floppy rescuer.

rescue internal



grub-mkrescue is a script ,so very easy to follow ; however the two fd/cd images are quite different in spirit even though generated from the same script.

The floppy-rescue_img consists of diskboot.img ,an embedded memdisk_img ,and 2 modules "memdisk and tar"
The modules allow memdisk operations as a tar_filesystem .(Something very similar to ramdisk,or initramfs in the standard linux booting process ).The memdisk includes all modules compiled ,so under floppy-rescue no modules need be inserted ,they are all loaded in ram .The memdisk_img itself is just a tar/cpio_like wrapping. The diskboot.img operates as a loader ,whereas "memdisk_img+modules" as core.img .

The cdrom-rescue_img consists of cdboot.img an eltorito_like loader ,and a core.img comprising a kernel.img and two modules " biosdisk iso9660" . A directory grub_tree /boot/grub/[all_modules ,some.lst,grub.cfg] is wrapped up as iso9660_filesystem .
The grub.cfg has "insmod acorn apple pc ..." partition drivers to allow biosdisk to regcognise the media. and the iso9660 module as iso9660_filesystem driver.

ex : cat cdboot.img core.img > grub_eltorito gives something similar to stage1.5_eltorito in grub_legacy.

Testing with grub rescue-disk



qemu -cdrom cdrescue.iso


or
qemu -fda rescue.floppy


Once inside grub shell "ls" or "ls -l" display grub devices seen in the virtual pc under qemu
Had you plugin a usb stick - suppose at /dev/sdf - then

qemu -hda /dev/sdf -cdrom cdrescue.iso -boot d

would allow to examine your stick !
Just ls to see its drivename ,then ls (hdx,1)/ where hdx supposed to be the usb stick under grub !