Compiling Grub2

From Wikislax

Revision as of 21:36, 26 September 2013 by WikiSysop (Talk | contribs)
Jump to: navigation, search


What is Grub2 ?

GNU Grub2 is a bootloader. A bootloader is the first software program that runs when a computer starts. It is responsible for loading and transferring control to the operating system kernel software. For Xen we'll use Grub2 over Lilo. The reason is that Grub2 affords booting Xen alongside Domain-0, which Slackware's default Lilo cannot do. Last, we'll use Grub2 over Grub legacy, because the latter is not 64-bits compatible.

Compiling Grub2

Download from the GNU page then untar to /usr/local and install as below :

# tar -C /usr/local -xvf grub-1.99.tar.gz
# cd /usr/local/
# chown -R root:root grub-1.99.tar.gz
# cd grub-1.99.tar.gz
# ./configure --libdir=/usr/local/lib64
# make
# make install
# make clean

Configuring Grub2

Grub2 configuration is described in the Grub2 documentation. As it is quite complex we will just edit what we need. Let's start with the general options in /usr/local/etc/default/grub.

# If you change this file, run 'grub-mkconfig -o /boot/grub/grub.cfg'
# afterwards to update /boot/grub/grub.cfg


# Uncomment to disable graphical terminal (grub-pc only)

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo`

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux

# Uncomment to disable generation of recovery mode menu entries

We now need to organize the files under /usr/local/etc/grub.d. Keep only 00_header untouched, rename and make all the other files not executable, then add menu entries as executable files 10_xen-4.1.2-kernel-3.4.2 and 11_kernel-3.4.2. It will be wise to add yet another entry 12_slack- as a backup kernel. set root=(dh0,3) means the third partition on the disk. The other options is what we have kept after trying and failing many times to see anything on the console :

#! /bin/sh -e
echo "Adding Xen 4.1.2 / Slackware 13.37 (kernel 3.4.2)"
cat << EOF
menuentry "Xen 4.1.2 / Slackware 13.37 (kernel 3.4.2)" {
       set root=(hd0,3)
       multiboot /boot/xen-4.1.2.gz dom0_mem=max:2GB console=vga vga=gfx-1024x768x8 noreboot
       module /boot/vmlinuz-dom0 console=vga earlyprintk=xen root=/dev/sda3 ro vga=gfx-1024x768x8
#! /bin/sh -e
echo "Adding Slackware 13.37 (kernel 3.4.2)"
cat << EOF
menuentry "Slackware 13.37 (kernel 3.4.2)" {
        set root=(hd0,3)
        linux /boot/vmlinuz-dom0 root=/dev/sda3 ro vga=773
#! /bin/sh -e
echo "Adding Slackware 13.37 (kernel"
cat << EOF
menuentry "Slackware 13.37 (kernel" {
       set root=(hd0,3)
       linux /boot/vmlinuz root=/dev/sda3 ro vga=773

Update /boot/grub/grub.cfg accordingly :

# grub-mkconfig -o /boot/grub/grub.cfg

Installing Grub2

Last step is to create boot record in first sector of disk partition. If not using Master Boot Record in /dev/sda, then the --force option must be used :

# grub-install --force /dev/sda3
# dd if=/dev/sda3 of=/mnt/win7/Boot/Slack1337.mbr

You can now cross fingers and reboot ! If everything goes right you should be able to see the xm dmesg log being displayed during Xen bootup, then the screen will be cleared and Xen will proceed with Linux (dom0) bootup as usual.

Compiling Xen Main Page Creating VMs
Personal tools