View Single Post
  #10  
Old 26th October 2005, 05:46
themachine themachine is offline
Senior Member
 
Join Date: Oct 2005
Location: Texas, USA
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Default

NOTE BEFORE ANYTHING: The bigest confusion is between what GRUB calls 'root' and what linux mounts as 'root' or '/'.

GRUB => root(hd0,0) specifies the 'root of where grub is installed', or in other words '/boot'.

LINUX => 'root' refers to the '/' partition.

now...

I'm assuming this:

/dev/hda => the primary disk
(hd0,0) => /dev/hda1 => /boot
(hd0,1) => /dev/hda2 => swap
(hd0,2) => /dev/hda3 => /tmp
(hd0,3) => /dev/hda4 => /

/boot/vmlinuz-2.6.12-9 => kernel
/boot/initrd-2.6.12-9.img => initrd image file


If your first partition (/dev/hda1) is '/boot' then the following is what you would want to do in order to setup grub.


I first run the grub-install util to install to the Master Boot Record:

Code:
grub-install /dev/hda

Then, setup grub by executing the 'grub' command:

Code:
# grub

grub> root (hd0,0)

grub> setup (hd0)

grub> quit

Again, as stated above, in this section 'root' refers to the 'root directory that grub is installed' which is the first partition on our hda disk (/dev/hda1 => /boot). If you do *not* have a separate '/boot' partition... then this will be the '/' partition.

After this you should have the folder '/boot/grub' with associated files. Assuming your kernel is something like '/boot/vmlinuz-2.6.12-9' then you would need, at the least, the following in '/boot/grub/grub.conf':

(Please note that some distros recognize '/boot/grub/menu.lst' rather than '/boot/grub/grub.conf'... and most link them one way or the other so that both work.)

Code:
timeout 5
default 0

title Linux Kernel (vmlinuz-2.6.12-9)
	 root (hd0,0)
	 kernel /vmlinuz-2.6.12-9 root=/dev/hda4
	 # if using initial ramdisk, uncomment the following line
	 # initrd /initrd-2.6.12-9.img
line 1) Title line (obvious)

line 2) root(hd0,0) specifies the partition that holds grub ('/boot')

line 3) specifies where the kernel is on (hd0,0)... i.e '(hd0,0)/vmlinuz-2.6.12-9' is the same as '/boot/vmlinuz-2.6.12-9' and since you have specified 'root (hd0,0)' then the same thing is written as '/vmlinuz-2.6.12-9'. The second part to this is the 'root=' line. This directive specifies where your ROOT partition is... i.e '/'. So if '/dev/hda4' is the partition that is mounted as '/'... then you would want 'root=/dev/hda4'.

line 4) Specify where the initrd is found. This depends on how your kernel was compiled. To see, grep your kernel .config file (usually found as '/boot/config-[kernel version]') or wherever you compiled the kernel ('/usr/src/linux-2.6.12-9/.config' ... etc). Typing the following will show whether it was compiled:

Code:
cat /boot/config-2.6.12-9 | grep -i initrd

CONFIG_BLK_DEV_INITRD=y

for 'yes', or 

CONFIG_BLK_DEV_INITRD=m

for 'module', or

CONFIG_BLK_DEV_INITRD=n

for 'no'


SAVING YOURSELF.... FROM A BROKEN GRUB INSTALL...


If you gotten yourself in a pickle, don't fret. Basically, when the system boots to the GRUB boot loader you can manually execute what *should* be in your /boot/grub/grub.conf.

So, you boot to GRUB and it does nothing.... do the following:

type 'c' for a grub> command prompt.
type 'root(hd0,0)' or whatever your 'grub root partition is'.

you should see something like:

Code:
grub> root (hd0,0)
Filesystem type is ext2fs, partition type 0x83
if not, you might see
Code:
grub> root(hd0,2)
Filesystem type unkown
or something like that. Then type your kernel line (note that you can use TAB COMPLETION just like in bash... very nice!)

Code:
grub> kernel (hd0,0)/vmlinuz-2.6.12-9 root=/dev/hda4
	 [Linux-bzImage, setup=0x1400, size=0x124587]
if you type it wrong

Code:
grub> kernel (hd0,0)/vmlinuz2.6.12-9 root=/dev/hda4
	 Error 15: File not found
If you need to specify an initrd... just type that line too:

Code:
initrd (hd0,0)/initrd-2.6.12-9
Once your done, just type 'boot' and you should be good to go.
__________________
themachine
5dollarwhitebox.org
Reply With Quote