Favorite tricks to boot grub
Grub works for me and I have some favorite grub tips and tricks. If grub was installed on the host system then the possibility exists to get the new LFS system running. I'm not sure if you have to type the ESC key or not, but typing the letter c should go to the grub command mode.
In the notes below, suppose that it is in the grub command mode which displays a prompt that looks like this:
grub>
You don't type in "grub>", but the stuff after it.
Trick 1. The TAB KEY is often helpful with command completion.
The notation <TAB> means "hit the TAB KEY"
Sometimes hitting tab can help to complete a command, disk number, partition number, or filename.
Trick 2. Manually locate stuff and type stuff in.
On my LFS system, I know that I installed the kernel for linux-2.6.22.5 which came with linux from scratch version 6.3. I also know that LFS would give that kernel the name lfskernel-2.6.22.5 and that it would install it in the /boot directory. I could find out where this file is located (in grub notation) like this:
grub> find /boot/lfskernel-2.6.22.5
If it happens to display (hd0,1), then (hd0,1) would be the partition that could be used in grub's root command which would appear in the grub config file.
If that partition is in fstab as /dev/sda2 (remember, one less than 2 is 1?) then even without fiddling with the grub config file or doing a grub setup command, I might get LFS booted by typing:
grub> root (hd0,1)
grub> kernel /boot/lfskernel-2.6.22.5 root=/dev/sda2
grub> boot
It might even work if I try like this:
grub> kernel /boot/l<TAB>
... grub fills in fskernel-2.6.22.5
... then I continue the rest of the line
grub> kernel /boot/lfskernel-2.6.22.5 root=/dev/sda2
grub> boot
Trick 3. Start the system based only on the grub config file.
Suppose that I had created the config file called menu.lst and had placed it in the /boot/grub directory. I could find its location with:
grub> find /boot/grub/menu.lst
If it happens to display (hd0,1) and if the config file is correct then even without fiddling with the grub setup command. I might get it booted with:
grub> configfile (hd0,1)/boot/grub/menu.lst
It is possible to avoid the possibility of damaging a working grub by merely adding an entry for the new system that uses the configfile statement instead of doing a chainloader statement or performing a grub setup command. Such an entry could looklike this:
title My New LFS system
configfile (hd0,1)/boot/grub/menu.lst
Trick 4. Symbolic link to /boot/grub
On some systems the /boot directory is just a directory and on other systems a filesystem is mounted on the /boot directory. At the time that grub runs, the filesystem would not yet have been mounted on /boot and this can add to confusion. I've been confused enough times to pursuade me to create a symbolic link calle grub that points to the /boot/grub directory. That way, this command:
grub> configfile (hd0,1)/grub/menu.lst
would work whether the system uses /boot as a regular directory or as a mount point. Currently, I prefer using /boot as a regular directory.
Making such a link can be done with these commands:
cd /
ln -s /boot/grub grub
I might get the menu to pop up if I try like this:
grub> root (<TAB>
... grub fills in hd0 if there is 1 drive or lists the possibilities
grub> root (hd0,<TAB>
... grub lists the possible partitions
grub> root (hd0,1)
grub> configfile /grub/menu.lst
ABOUT GRUB
Grub stands for GRand Unified Bootloader. It is weird and causes many people problems. There are numerous posts on forums from people who can't get it to work right and replies from people who are trying to figure out how to explain it. One confusing thing about grub is that partition numbers are relative to zero which makes them one less than the same partition in fstab. So (hd0,2) would be the same partition as /dev/hda3. The number before the comma is the disk number and the number after the comma is the partition number. Since hda is the first disk, grub counts one less giving hd0. Nowadays, the hd is less often used than sd because of hardware migration from IDE drives to SATA drives. However, grub still uses hd in the disk specifier as (hd0,2) even if it is a SATA drive which would be /dev/sda3 in fstab. Just to make sure that we are confused, grub uses the same thing that would be specified in fstab on the kernel line in the config file. The standard name of the grub config file is menu.lst -- that is a lowercase letter L and not the numeral one. The RedHat variant distributions such as fedora and centos patch grub so that it uses a config fie named grub.conf. In such cases, menu.lst is made a symbolic link to grub.conf or vice versa.
In the notes below, suppose that it is in the grub command mode which displays a prompt that looks like this:
grub>
You don't type in "grub>", but the stuff after it.
Trick 1. The TAB KEY is often helpful with command completion.
The notation <TAB> means "hit the TAB KEY"
Sometimes hitting tab can help to complete a command, disk number, partition number, or filename.
Trick 2. Manually locate stuff and type stuff in.
On my LFS system, I know that I installed the kernel for linux-2.6.22.5 which came with linux from scratch version 6.3. I also know that LFS would give that kernel the name lfskernel-2.6.22.5 and that it would install it in the /boot directory. I could find out where this file is located (in grub notation) like this:
grub> find /boot/lfskernel-2.6.22.5
If it happens to display (hd0,1), then (hd0,1) would be the partition that could be used in grub's root command which would appear in the grub config file.
If that partition is in fstab as /dev/sda2 (remember, one less than 2 is 1?) then even without fiddling with the grub config file or doing a grub setup command, I might get LFS booted by typing:
grub> root (hd0,1)
grub> kernel /boot/lfskernel-2.6.22.5 root=/dev/sda2
grub> boot
It might even work if I try like this:
grub> kernel /boot/l<TAB>
... grub fills in fskernel-2.6.22.5
... then I continue the rest of the line
grub> kernel /boot/lfskernel-2.6.22.5 root=/dev/sda2
grub> boot
Trick 3. Start the system based only on the grub config file.
Suppose that I had created the config file called menu.lst and had placed it in the /boot/grub directory. I could find its location with:
grub> find /boot/grub/menu.lst
If it happens to display (hd0,1) and if the config file is correct then even without fiddling with the grub setup command. I might get it booted with:
grub> configfile (hd0,1)/boot/grub/menu.lst
It is possible to avoid the possibility of damaging a working grub by merely adding an entry for the new system that uses the configfile statement instead of doing a chainloader statement or performing a grub setup command. Such an entry could looklike this:
title My New LFS system
configfile (hd0,1)/boot/grub/menu.lst
Trick 4. Symbolic link to /boot/grub
On some systems the /boot directory is just a directory and on other systems a filesystem is mounted on the /boot directory. At the time that grub runs, the filesystem would not yet have been mounted on /boot and this can add to confusion. I've been confused enough times to pursuade me to create a symbolic link calle grub that points to the /boot/grub directory. That way, this command:
grub> configfile (hd0,1)/grub/menu.lst
would work whether the system uses /boot as a regular directory or as a mount point. Currently, I prefer using /boot as a regular directory.
Making such a link can be done with these commands:
cd /
ln -s /boot/grub grub
I might get the menu to pop up if I try like this:
grub> root (<TAB>
... grub fills in hd0 if there is 1 drive or lists the possibilities
grub> root (hd0,<TAB>
... grub lists the possible partitions
grub> root (hd0,1)
grub> configfile /grub/menu.lst
ABOUT GRUB
Grub stands for GRand Unified Bootloader. It is weird and causes many people problems. There are numerous posts on forums from people who can't get it to work right and replies from people who are trying to figure out how to explain it. One confusing thing about grub is that partition numbers are relative to zero which makes them one less than the same partition in fstab. So (hd0,2) would be the same partition as /dev/hda3. The number before the comma is the disk number and the number after the comma is the partition number. Since hda is the first disk, grub counts one less giving hd0. Nowadays, the hd is less often used than sd because of hardware migration from IDE drives to SATA drives. However, grub still uses hd in the disk specifier as (hd0,2) even if it is a SATA drive which would be /dev/sda3 in fstab. Just to make sure that we are confused, grub uses the same thing that would be specified in fstab on the kernel line in the config file. The standard name of the grub config file is menu.lst -- that is a lowercase letter L and not the numeral one. The RedHat variant distributions such as fedora and centos patch grub so that it uses a config fie named grub.conf. In such cases, menu.lst is made a symbolic link to grub.conf or vice versa.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
Click blog title for the latest post