Difference between revisions of "Using Grub2"

From Wikislax
Jump to: navigation, search
(Created page with "{{RightTOC}} == What is Grub2 ? == [http://www.gnu.org/software/grub/ GNU Grub2] is a bootloader. A bootloader is the first software program that runs when a computer starts...")
 
(No difference)

Latest revision as of 22:26, 6 December 2017

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 ?

Compiling Grub2 is usually unnecessary as it is included with the Slackware distribution. However the grub-2.00 version included with Slackware 14.2 does not afford booting Xen so we'll compile grub-2.02 from source instead :

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

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

Configuring Grub2

The Grub2 configuration is described in the Grub2 documentation. As it is quite massive we will just edit what we need.

Note : if using the Grub2 included with the Slackware distribution, the configuration files are /etc/default/grub and the files in /etc/grub.d. If using a Grub2 compiled by yourself then the configuration files are /usr/local/etc/default/grub and the files in /usr/local/etc/grub.d.

Let's go to the actual config now. Let's start with general options in file default/grub that we create.

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

GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=false
GRUB_TIMEOUT=4
GRUB_DISTRIBUTOR=$( sed 's/Slackware /Slackware-/' /etc/slackware-version )
GRUB_CMDLINE_LINUX_DEFAULT=""
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=640x480
#GRUB_GFXMODE=1024x768x32

# Font used on the graphical terminal:
#GRUB_FONT=/usr/share/grub/dejavusansmono.pf2

# 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 grub.d. Keep only 00_header untouched, rename and make all the other files not executable, then add menu entries as executable files 11_xen-4.9.0-kernel-4.4.88-dom0 and 12_kernel-4.4.88-dom0. It will be wise to add yet another entry 13_slack-4.4.88 as a backup kernel. set root=(hd0,2) means the second 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.9.0 / Slackware 14.2 (kernel 4.4.88-dom0)"
cat << EOF
menuentry "Xen 4.9.0 / Slackware 14.2 (kernel 4.4.88-dom0)" {
       set root=(hd0,2)
       multiboot /boot/xen-4.9.0.gz dom0_mem=max:16GB console=vga vga=gfx-1024x768x8 noreboot
       module /boot/vmlinuz-4.4.88-dom0 console=vga earlyprintk=xen root=/dev/sda2 ro vga=gfx-1024x768x8
       }
EOF
#! /bin/sh -e
echo "Adding Slackware 14.2 (kernel 4.4.88-dom0)"
cat << EOF
menuentry "Slackware 14.2 (kernel 4.4.88-dom0)" {
        set root=(hd0,2)
        linux /boot/vmlinuz-4.4.88-dom0 root=/dev/sda2 ro vga=773
        }
EOF
#! /bin/sh -e
echo "Adding Slackware 14.2 (kernel 4.4.88)"
cat << EOF
menuentry "Slackware 14.2 (kernel 4.4.88)" {
       set root=(hd0,2)
       linux /boot/vmlinuz root=/dev/sda2 ro vga=773
       }
EOF

Update /boot/grub/grub.cfg accordingly :

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

Installing the bootloader

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/sda2
# dd if=/dev/sda2 of=/mnt/win7/Boot/Slack14.mbr bs=512 count=1

You can now cross fingers and reboot ! If everything goes right you should be able to see the xl 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