Share your knowledge at the LQ Wiki.
Go Back > Linux Answers > Applications / GUI / Multimedia
User Name


By runlevel0 at 2005-06-21 07:44
Grub is very powerful, but amazingly easy to use. It's indeed more difficult to understand the 'userfriendly' GUIs than doing things the good ol' way, as it was when men where men, women where women and DVD-ROMS where made of stone.

There's just some little concepts you need to know and with this knowledge and the fine man pages you will be able to adapt this tutorial to any situation, from an USB stick to SATA or SCSI disks. But to keep things simply I will only show how to do it on plain vanilla IDE drives.

Before we start: How Grub Calls Stuff

This is the only odd thing in grub: It doesn't call the disks as we are used to. But don't worry, is not as weird as with devfs (/dev/boo/lun/foo/bar/../../disk/stuff/.../.../and/so/on).
It's only a bit different:
  • Grub uses brackets to declare a device
  • The /dev/ part is not used
  • device numbers and partitions are defined with numbers starting from 0

This example will show you how it works (It's easier to understand as it is to explain):

Linux standard GRUB
/dev/hda1 (hd0,0)
/dev/hda2 (hd0,1)
/dev/hdd1 (hd3,0)

Even Easier : a=0 b=1 c=2 d=3 and the partition is N-1 ... hat's all.

Now let's do some serious work

After learning how grub calls stuff, we are going to set up grub from the command line.
This is very useful as you can use it to fix grub even from the boot sequence itself.
It's astonishingly simple:

You need a CD from where to run a shell, either a livecd or your favorite distro's install CD using the 'rescue' option (F2 will show you how to launch it). Sometimes Grub itself launches it's shell when it finds errors or can't stat where the heck the kernels are.

The steps are quite simple: If grub hasn't launched the shell for you, you just need to launch it:
Now, keeping in mind the above mentioned syntax rules we will set up grub. For this example we will set up grub to reside in the MBR of the first IDE's master and the kernel will be in the second partition of the second IDE's master.
In Linux tis would be /dev/hda for the first IDE's master and /dev/hdc2 for the place where our kernel lives.

Translating to Grub's syntax: /dev/hda = (hd0) and /dev/hdc2 = (hd2,1)
So what we need to do is telling grub first where to search for the kernel we want to boot and here to place the MBR:

grub> root (hd2,1)
grub> setup (hd0)
grub> quit
That's all. With this setup we will be able to boot into our chosen kernel. Once in the distro we can tweak things to our liking editing the files /boot/grub/boo.lst or /boot/grub/grub.conf (depending on your distro).

But I will cover this later in a later update of this little HOWTO.
Stay tuned as I will be editing this to add more grub stuff (and maybe changing it to the LQ-Wiki).

by sadiqdm on Sun, 2008-03-02 22:26
Had a disaster with XP which meant a re-install and lost GRUB. For some reason the Repair Installation on the Suse 10.3 install DVD would not start, so I used my PartedMagic 1.9 disk instead.

You can get it from here -

The latest version is 2.1 and it can be burned to CD or USB.

All I had to do was boot from the CD, and open the terminal, then use the commands from above. This is a laptop with one drive, and Suse is on hda4 (hd0,3)
root@partedmagic ~# grub
grub > root (hd0,3)
grub > setup (hd0)
grub > quit
root@partedmagic ~# reboot
Got an error 22 the first time because I typed (hdo,3) with letter O instead of figure zero!

by JZL240I-U on Wed, 2010-06-30 04:54
Just a brief correction: It is /boot/grub/menu.lst not boo.lst. After adjusting this you are welcome to delete this comment. HTH.

by 'Gator on Fri, 2010-08-20 04:21
You should check the accuracy of your record-keeping system. I've started two threads and received multiple replies from dvacet, bcbc, and snowpine. What else must I do to "unlock the full benefits of your LQ account"?

--'Gator sends


All times are GMT -5. The time now is 11:49 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration