[Courses][Linux commands] installing GRUB without a floppy disk

Carla Schroder carla at bratgrrl.com
Thu Apr 15 18:25:22 EST 2004

Akkana Peck, this one's for you. :)

Migrating from LILO to GRUB, or re-installing GRUB, is pretty easy. The snag 
is the GRUB manual, and info grub, which are the same, emphasize installing 
GRUB using a floppy disk. If you're on a system without a floppy drive, like 
a laptop, what are you to do? 

The first thing you do is ignore the instructions in the GRUB manual, that say 
to use 'grub-install.' I'm using GNU GRUB 0.94, and 'grub-install' just plain 
does not work. If it works for you, the way the GRUB manual says it's 
supposed to, please let me know.

Here is what works. First, install GRUB. Doesn't matter how, just install it 
on your system. Next, let's say you have Linux on /dev/hda6, with 
a /boot/grub directory, which should have been created by the GRUB 
installation. Open a root shell, and start up the GRUB shell:

# grub   
Probing devices to guess BIOS drives. This may take a long time.

GNU GRUB  version 0.94  (640K lower / 3072K upper memory)

 [ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the possible
   completions of a device/filename. ]


Now you will run 3 commands:

grub> root (hd0,5)
grub> setup (hd0)
grub> quit

'grub> root (hd0,5)' tells GRUB the partition where your /boot/grub directory 
is. (GRUB uses a different partition numbering scheme, hd0,5 = /dev/hda6)

'grub> setup (hd0)' installs GRUB to the MBR. You should see something like 
this output:

checking if "/boot/grub/stage1" exists...yes
checking if "/boot/grub/stage2" exists...yes
checking if "/boot/grub/e2fs_stage1_5" exists...yes
Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 15 sectors are embedded. 
Running "install /boot/grub/stage1 (hd0) (hd0)1+15 p 
(hd0,0)/boot/grub/stage2 /boot/grub/menu.lst"...Succeeded

'grub> quit' exits GRUB. Now when you reboot, it should boot to the GRUB 
command line, or a GRUB menu if you already configured menu.lst.

A slick trick is to create a /boot partition, I like to use the first 
partition of the first hard drive, /dev/hda1. This lets you wipe out and 
reinstall Linuxes all you want, without having to reinstall and reconfigure 
the bootloader every time. On a multiboot system, this is a real time-saver.

And again,' grub-install' did not work for me as advertised. Supposedly you 
can set the /boot directory with grub-install:

# grub-install --root-directory=/boot /dev/hda

Which you should do with a /boot partition, so that you still have 
a /boot/grub directory. If you don't, your filepaths will start with /grub, 
which will cause problems. But dumb ole 'grub-install' failed again, even 
though it reported success. (Note to coder geeks: it's just a shell script, 
perhaps some kind soul would like to debug it)

So this is what worked. I created the /boot partition, and copied /boot/grub 
into it from my Linux on /dev/hda6. Then I ran the above commands, and lo and 
behold it worked.

For more GRUB basics, see 
'Give LILO the Boot and Grab Some GRUB'

Carla Schroder
this message brought to you
by Libranet 2.8 and Kmail

More information about the Courses mailing list