Search:  
Gentoo Wiki

GRUB/Chainloaded_CD-ROM

This howto is for x86 based computers only

Tired of having to change your BIOS boot order just to boot from a CD and forgetting to revert the change in the BIOS?

Get GRUB to chainload your bootable CD-ROM from its convenient menu!

There are two methods to do it - the "Fast Method" which involves only downloading and the "Complete Method" which also involves compiling :)

Contents

Fast Method

Just download the following two files to your home directory and skip reading to the Create a GRUB entry chapter :)

$ cd
~/joe $ wget ftp://ftp.mcc.ac.uk/beta/local/teaching_cluster/disks/memdisk
~/joe $ wget ftp://ftp.mcc.ac.uk/beta/local/teaching_cluster/disks/sbm.bin

(files are password protected, and no passwod is given)

Or, if you're looking for an SBM image which doesn't hang at the menu while booting, try the following. Such an image is useful for those booting via serial console or when you don't have physical access to a KVM. Download the image pre-configured for such a task from the following sites:

* http://www.lrz-muenchen.de/~bernhard/grub-chain-cd.html
* http://www.lrz-muenchen.de/~bernhard/sbootmgr.dsk
  * make sure to rename or change your grub configs
* http://www.cs-club.org/~andrew/files/sbootmgr.dsk (mirror)

Complete (Do it yourself) Method

Get the necessary tools, prep the environment

You'll need some tools. Namely, SYSLINUX, by H. Peter Anvin, and the Smart Boot Manager(mirror) (SBM), by James Su, Lonius, and Christopher Li. SYSLINUX is a well-known Linux bootloader. SBM, on the other hand, seems to be orphaned, according to Bernhard Treutwein. So get your hands on a copy of SBM fast! It seems to be reanimated in August 2007. CVS on Sourceforge contains the older stuff, while SVN seems to hold the current version. The project page can be found here: btmgr at Sourceforge

You can do a very convenient emerge to get SYSLINUX, but you will have to work your way with SBM to get it working, since it is not in portage.

Let's take it easy. First, get SYSLINUX. If you haven't figured out how, this might help refresh your memory:

$ emerge syslinux

In my system, this last emerge also emerged mtools. I'll take note of this, since I will want to unmerge SYSLINUX after I create the "kernel" (I'll show you later) and if I do not remove mtools as well, it will just float around.

Copy /usr/lib/syslinux/memdisk to your home directory as we will need it later.

$ cp /usr/lib/syslinux/memdisk ~/

Now, get SBM here. For some reason, I cannot get the .tar.gz file to compile properly, so get the .src.rpm package instead and convert it into a .tar.gz using rpm2targz (emerge it if you do not have, it's on app-arch/rpm2targz). You're also free to do as follows, if you're really inclined to closely follow instructions:

$ cd ~
 
~/joe $ mkdir cdgrub
 
~/joe $ cd cdgrub
 
~/joe/cdgrub $ wget http://btmgr.sourceforge.net/3.7/btmgr-3.7-1.i386.rpm
 (...wget downloads the file...)
 
~/joe/cdgrub $ rpm2targz btmgr-3.7-1.i386.rpm
 (...now you have a file called btmgr-3.7-1.i386.tar.gz...)
 
~/joe/cdgrub $ tar -xzvf btmgr-3.7-1.i386.tar.gz
 (...file is untarred in a directory called usr...)
 
~/joe/cdgrub $ cd usr/sbin

Smart Boot Manager

Let's make a bootable floppy, using SBM. You should be root to do this. I assume that /dev/fd0 represents your floppy drive. Change it accordingly if it is not.

Yes, you read it right. We need a floppy. There's a way to do this without a floppy (via the loopback device), but, for the sake of simplicity, go get a floppy and issue the line:

~/joe/cdgrub/usr/sbin $ ./sbminst -d /dev/fd0

At this point, you have an SBM bootable floppy.

We won't need the full disk, though. You only need the first 18kb of the floppy, including its boot sector. Make an image of it and save to a file:

~/joe/cdgrub/usr/sbin $ dd if=/dev/fd0 of=~/sbm.bin bs=1k count=18

Now you've got a file called sbm.bin in your home directory.

Cleaning up

You won't need SBM again. Feel free to remove the cdgrub directory you just created.

~/joe/cdgrub/usr/sbin $ cd
~/joe $ rm -rf cdgrub

You also do not need SYSLINUX again. Unmerge it:

~/joe $ unmerge syslinux

If the first emerge also emerged mtools, feel free to unmerge it as well, since it seems that you do not really need it:

~/joe $ unmerge mtools

You might want to keep rpm2targz, though. It's a very convenient utility when it comes into handling those pesky .rpm package files.

Create a GRUB entry

Mount your boot directory and copy memdisk:

~/joe $ mount /boot
~/joe $ cp memdisk sbm.bin /boot

Fire up your editor and add an entry to your /boot/grub/grub.conf file:

title=SBM-Boot a CD
kernel /memdisk
initrd /sbm.bin

You may want to password-protect that entry.

That concludes it. Next time you boot, there will be a new entry on your GRUB menu. Select it and you'll be presented another menu. Look for your CD-ROM there and press ENTER. When asked to save configurations, just press ENTER (doesn't seem to matter at all). GRUB will try to chainload your bootable CD-ROM.

References

Retrieved from "http://www.gentoo-wiki.info/GRUB/Chainloaded_CD-ROM"

Last modified: Mon, 10 Mar 2008 20:29:00 +0000 Hits: 36,863