Tuesday, 15 January 2013

Understanding GRUB

Grub naming methods:

1) All hard disks are designated by hd or sd.

2) All partitions are designated with numbers stating with 0 and 1.

3) Extended partitions are counted from 4 whether or not the primary partitions are present.

4) The first number is related to disk and second number is related to partition in that disk.


It means first hard disk, usually is /dev/sda or /dev/hda.

 It means second hard disk, usually it is /dev/sdb or /dev/hdb

It means first hard disk, first partition. That is /dev/sda1 or /dev/hda1

It means first hard disk, second partition. That is /dev/sda2 or /dev/hda2

Second hard disk, second partition. That is /dev/sdb2 or /dev/sdb2

If you open and view /etc/grub/grub.conf you can view the following details:

Note: the below case is where there is no separate partition for /boot.
1 default=0
2 timeout=10
3 splashimage=(hd0,5)/boot/grub/splash.xpm.gz

4 title CentOS 5.6 i686
5   root (hd0,5)
6   kernel /boot/vmlinuz-2.6.18-238.19.1.el5.centos.plusPAE ro root=/dev/sda6 rhgb noquiet
7   initrd /boot/initrd-2.6.18-238.19.1.el5.centos.plusPAE.img

8 title Linux Mint 11
9   root (hd0,9)
10  kernel /boot/vmlinuz-2.6.32-26-generic-pae ro root=/dev/sda10
11  initrd /boot/initrd.img-2.6.32-26-generic-pae
All these entries has got some meaning. I will explain here what are those.

1)  Default=0:  By default boot the first partition listed below:
2)  timeout=10 : wait for 10 seconds before the user input.
3)  splashimage : Show splash image while waiting for user input.
4) Name of the first possible boot partition.
5) Location of grub as per grub naming convention( actual partition /dev/sda6).
6)  The 6th line consist of 5 parts as follows:

/boot/vmlinuz-2.6.18-238.19.1.el5.centos.plusPAE ==> The location of kernel.
Mount the partition as read only and run fsck if necessary.

Location of root partition.  The can be also UUID(universally unique identifier)
Use graphical boot

Be more verbose

7) Location of intird or initramfs.


Now, if we have a separate partition for /boot then the changes in /etc/grub/grub.conf, will be as follows:

1) The line beginning with root should indicate the partition for /boot and not partition of /.

2) The line starting with kernel must assume that the kernel (vmlinuz) is in /, not in /boot. However, the command root in that line must indicate the partition for /, not the partition for /boot

3) The line starting with initrd must assume that the initial ramdisk (initrd or initramfs) is in /, not in /boot.

The /boot partition is /dev/sda1, or hd(0,0). The / partition is /dev/sda2, or hd(0,1). The file /boot/grub/grub.conf must indicate the following:

title CentOS 5.6 i686
  root (hd0,0)
  kernel /vmlinuz-2.6.18-238.19.1.el5.centos.plusPAE ro root=/dev/sda2
  initrd /initrd-2.6.18-238.19.1.el5.centos.plusPAE.img

No comments:

Post a Comment

Note: only a member of this blog may post a comment.