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
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:
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).
grub> root (hd2,1)
grub> setup (hd0)
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).