July 29, 2014
 
 
RSSRSS feed

Getting Some GRUB For Linux - page 3

Preparation

  • April 26, 2004
  • By Carla Schroder
Now install GRUB to the MBR. This is the point of no return. Well, not really, because you can always restore the MBR from your backup. Isn't Linux cool?
grub> setup (hd0)

This installs it to the first sector of the first drive.

Now we must finish booting. If you already know the location of your kernel, now is the time to use it:
grub> root (hd0,0)
grub> kernel /boot/vmlinuz-2.4.21 root=/dev/hda1 ro
grub> boot

Let's dissect the kernel line, as it is a source of confusion and woe for GRUB newbies. /boot/vmlinuz-2.4.21 is simply the location of the kernel you want to boot. You can have as many different kernels in /boot as you want, and select the one you want to use at boot time.

root=/dev/hda1 Now GRUB wants to use the /dev name, I don't know why. Just give it what it wants.

ro is read-only- always append this to any Linux kernel line.

Then type the boot command, and away you go.

The Dog Ate lilo.conf

You can discover the kernel and root information from the GRUB command line, with tab-completion. Type
grub>  root (hd0,    

and hit the tab key. Stuff will appear:

�Possible partitions are:
� �Partition num: 0, Filesystem type is ext2fs, partition type 0x83
� �Partition num: 1, Filesystem type is ext2fs, partition type 0x83

Well, which one is it? It's trivial to try both. Type

grub> root (hd0,1)
Filesystem type is ext2fs, partition type 0x83

Then search for the kernel image, type:

grub> kernel /boot/vmlinuz root=/dev/hda1 ro

and hit the tab key. If there is no /boot directory, GRUB will tell you:

Error 15: File not found

So, just do it over:

grub> root (hd0,0)
Filesystem type is ext2fs, partition type 0x83
grub> kernel /boot/vmlinuz
possible files are: vmlinuz vmlinuz-2.4.21

Type:

grub> kernel /boot/vmlinuz-2.4.21
grub> boot

and away you go.

Weirdo Kernel Names

vmlinuz is the traditional name for Linux kernels, but they can be named anything at all- fred, kernel-mustard, my-frikken-kewl-kernel, anything at all. To be sure of catching all possible kernels in /boot, widen your search:
grub> kernel /boot/

and hit the tab key. This will list all the files in /boot.

Making The Changes Permanent

You probably don't want to do this every time you boot up, so find your GRUB configuration file, and make all this stuff happen automatically. In Debian, /boot/grub/menu.lst. In Red Hat, /boot/grub/grub.conf. Our entry looks like this:
title	�� ��	Libranet GNU/Linux, kernel 2.4.21
root �� �� (hd0,0)
kernel �� �� /boot/vmlinuz-2.4.21 root=/dev/hda1 ro
boot

The title is anything you want.

But What About LILO?

You can leave LILO on your system, or remove it, as you like. GRUB owns the MBR now, so LILO is in retirement. Later in this article you'll learn how to restore LILO, should you wish.
Sitemap | Contact Us