Compiling Grub2

From Wikislax

Revision as of 21:21, 5 July 2012 by WikiSysop (Talk | contribs)
Jump to: navigation, search

Contents

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

GRUB_DEFAULT=0
GRUB_TIMEOUT="4"
GRUB_DISTRIBUTOR=`echo GNU Source`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

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

# 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`
#GRUB_GFXMODE=1280x1024x32
#GRUB_GFXPAYLOAD_LINUX=text 

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

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_LINUX_RECOVERY="true"

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-2.6.37.6 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
       }
EOF
#! /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
        }
EOF
#! /bin/sh -e
echo "Adding Slackware 13.37 (kernel 2.6.37.6)"
cat << EOF
menuentry "Slackware 13.37 (kernel 2.6.37.6)" {
       set root=(hd0,3)
       linux /boot/vmlinuz root=/dev/sda3 ro vga=773
       }
EOF

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

Adjusting rc.local*

Xen needs a couple of daemons to run to ensure VM management. Add these lines to rc.local and rc.local_shutdown :

# start xencommons
if [ -x /etc/init.d/xencommons ]; then
    /etc/init.d/xencommons start
fi

# start xend
if [ -x /etc/init.d/xend ]; then
    /etc/init.d/xend start
fi
# stop xend
if [ -x /etc/init.d/xend ]; then
    /etc/init.d/xend stop
fi

# stop xencommons
if [ -x /etc/init.d/xencommons ]; then
    /etc/init.d/xencommons stop
fi

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
Namespaces
Variants
Actions
Navigation
Toolbox