Friday 13 June 2014

GRUB Troubleshooting – 3

GRUB Troubleshooting – 3

--> How do I change the default kernel in GRUB that is loaded at startup?
Use the command grubby –bootloader-probe to find out which bootloader you have installed. Then, assuming it is GRUB, edit the file /etc/grub.conf as described below. First, an example GRUB configuration file:
default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Red Hat Enterprise Linux ES (kernel number zero)
root (hd0,0)
kernel /vmlinuz-zero ro root=/dev/hard_drive
initrd /initrd-zero.img
title Red Hat Enterprise Linux ES (kernel number one)
root (hd0,0)
kernel /vmlinuz-one ro root=/dev/hard_drive
initrd /initrd-one.img
title Red Hat Enterprise Linux ES (kernel number two)
root (hd0,0)
kernel /vmlinuz-two ro root=/dev/hard_drive
initrd /initrd-two.img
In this example file, notice the line at the top that reads default=0. The number 0 (zero) indicates which stanza to select by default. A stanza is the indented portion after the line starting with title. GRUB will then use this default stanza to boot, after a number of seconds has passed (specified in the line timeout=10). The 0 (zero) in this case is referring to the first stanza that starts with “title Red Hat Enterprise Linux ES (kernel number zero)”. It includes all of the indented lines up to but not including the next “title” line.
For example, if you instead wanted the second stanza, “title Red Hat Enterprise Linux ES (kernel number one)”, to be the default, then you would change the default line to:
default=1
Once you have made this change, save the grub.conf file. You do not need to reload GRUB for the changes to take effect. The next time you boot, your changes will take effect, but once the file is saved, the changes are effective.
--> How to install GRUB on a disk image file?
Image files are representations of block devices. Each image can be used as a hard disk for virtualized guests under Xen or KVM. During booting, if GRUB bootloader cannot recognize a boot partition installed a virtual machine for any reason, need to re-install GRUB on that image file. It will be especially useful when trying to migrate a physical machine to a virtual machine using a disk image file from scratch.
Assumptions: There is a disk image file, so-called virtual-disk.img, for virtual machines. The image has beed made well including a proper kernel version and other system packages. To build a disk image file, refer the How can I create sparse files under Red Hat Enterprise Linux?
Before installing GRUB, get partition information from the image.
# losetup /dev/loop1 /var/lib/libvirt/images/virtual-disk.img
# fdisk -ul /dev/loop1
Disk /dev/loop1: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x722fd0f4
Device Boot Start End Blocks Id System
/dev/loop1p1 63 1060289 530113+ 82 Linux swap
/dev/loop1p2 1060290 16771859 7855785 83 Linux
# losetup -d /dev/loop1
In this example, virtual-disk.img is consists of two partitions and is 8GiB in total size. Now install GRUB to the image file:
# grub –device-map=/dev/null
This will open up a GRUB prompt. Enter the following:
grub> device (hd0) /var/lib/libvirt/images/virtual-disk.img
grub> root (hd0,1)
grub> setup (hd0)
grub> quit
Note: do not use the loopback device to install GRUB bootloader because GRUB has a bug when given a loopback device.
--> How do I configure GRUB to see all of my physical memory?
You can specify the amount of memory on your system if your computer is not recognizing all of it. For example if your system says you only have 128 MB of RAM and you know for sure you have 256 MB, then you can specify that in your grub.conf file, located at /boot/grub/grub.conf.
This is what a normal grub.conf file looks like:
# cat /boot/grub/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/hda2
# initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Red Hat Enterprise Linux AS (2.4.21-15.EL)
root (hd0,0)
kernel /vmlinuz-2.4.21-15.EL ro root=LABEL=/
initrd /initrd-2.4.21-15.EL.img
title Red Hat Enterprise Linux AS (2.4.21-9.EL)
root (hd0,0)
kernel /vmlinuz-2.4.21-9.EL ro root=LABEL=/
initrd /initrd-2.4.21-9.EL.img
What you want to do is add the following syntax mem=<###>M to the kernel line of your grub.conf file. So for instance if you were specifying your system had 256 MB in the grub.conf file, it would look something like this:
# cat /boot/grub/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/hda2
# initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Red Hat Enterprise Linux AS (2.4.21-15.EL)
root (hd0,0)
kernel /vmlinuz-2.4.21-15.EL ro root=LABEL=/
mem=256M
initrd /initrd-2.4.21-15.EL.img
title Red Hat Enterprise Linux AS (2.4.21-9.EL)
root (hd0,0)
kernel /vmlinuz-2.4.21-9.EL ro root=LABEL=/
mem=256M
initrd /initrd-2.4.21-9.EL.img


No comments :

Post a Comment