Gentoo Wiki


This article is part of the Tips & Tricks series.
Terminals / Shells Network X Window System Portage System Filesystems Kernel Other



Sometimes you need a way to test your dualboot setup without hosing your Windows 98/ME/XP install by installing grub. Making a floppy with the GRUB on it will let you use the disk whenever you need to test a grub.conf.

If you've emerged grub already, but not set it up to run on your hard disk, its easy to make a bootloader floppy. I used mine to test the commands for booting XP.



Get a floppy, and put it in your drive. Now we're going to format the disk with ext2:

Code: Shell
fdformat /dev/fd0
mkfs.ext2 /dev/fd0

First, with fdformat, we actually formatted the floppy and afterwards we initialised an ext2 filesystem on it with mk2fs.ext2 (If we would want to use another filesystem type we could use one of mk2fs.* programs - e.g. mk2fs.ext3, etc.)

Copy files

Now we can mount the disk, and the boot partition, and copy some files to it that grub needs.

Code: Shell
mount /boot 
mkdir /mnt/floppy 
mount /dev/fd0 /mnt/floppy
mkdir -p /mnt/floppy/boot/grub
cp /boot/grub/stage* /mnt/floppy/boot/grub # see optional note below
umount /mnt/floppy

Optionally, if you would like a boot menu, AND you will always be using the floppy on the same system copy over the menu.lst file (aka grub.conf)

Code: Shell
cp /boot/grub/menu.lst /mnt/floppy/boot/grub

If you don't have a handy menu.lst file, follow the procedures in the Gentoo install guide to make one.

IMPORTANT NOTE: The menu.lst file does NOT generate or correct itself! It only contains what you put there, and if that does not match the system you are using it on, the menu will NOT work properly! Only do this if you are going to be using the floppy on a system you know matches the menu.

If you do need to change the boot menu for any reason, simply mount the floppy and edit menu.lst with your favorite editor. You do NOT need to repeat the setup procedure below.

Install GRUB

Now we run grub, and use its console to install it on the floppy. Now you should have a console up with the prompt "grub>". To install grub onto the floppy:

Code: GRUB console
root (fd0) 
setup (fd0) 



Right, now you've got a working grub floppy. When you reboot with it, you'll see a console that looks like the one you installed grub onto the floppy with. Now you can run commands that will let you boot linux. If you followed the tutorial, then your root partition is hda3, and your boot partition is hda1. Type the following in the grub console to boot Linux:

root (hd0,0) 
kernel /<name of kernel> root=/dev/hda3 

Replace <name of kernel> with your kernel name. You can use tab-complete to find it.


If you want to boot Windows, you'll need to specify the partition its on. GRUB uses a naming system for disks and partitions that starts from zero, so the first partition of the first disk (/dev/hda1) is (hd0,0), then second disk, fourth partition (/dev/hdb4) is (hd1,3), etc. In my configuration, I have XP on /dev/hda1. We use rootnoverify as GRUB can't understand the NTFS filesystem.

Code: GRUB console
rootnoverify (hd0,0)
chainloader +1

See Also


Concerns or Compliments? Please use the Discussion section.

Retrieved from ""

Last modified: Thu, 04 Sep 2008 06:25:00 +0000 Hits: 28,142