Setting up PVGRUB

tested on a Slackware dom0 against an RHEL7 guest

Install

Build the PVGRUB binary for the XEN host

#--recursive or sub-modules?
git clone --recursive git://git.savannah.gnu.org/grub.git
cd grub/
./bootstrap
#./autogen.sh
./configure --target=amd64 --with-platform=xen
echo $MAKEFLAGS
make > ../grub.log && echo BUILT

# slackware
ls -lF /var/log/packages/ | grep grub # empty
removepkg grub

make install
ls -lF /usr/lib/xen/bin/pygrub

Prep

Check what’s inside the guest

losetup --find --partscan --read-only --show centos.disk
fdisk -l /dev/loop1*
mount -o ro /dev/loop1p1 /mnt/

Setup

RHEL has /boot/grub2/ not /boot/grub/

ls -lF /mnt/boot/grub2/
mv -i /mnt/boot/grub2/grub.cfg /mnt/boot/grub2/grub.cfg.dist
vi /mnt/boot/grub2/grub.cfg

assuming an overall / partition

cat > grub.cfg <<EOF
normal (xen/xvda,msdos1)/boot/grub2/grub.cfg
EOF
ls -lF /usr/local/lib/grub/x86_64-xen/
grub-mkimage --prefix=/boot/grub2 -o /data/kernels/pvgrub \
    -O x86_64-xen -c grub.cfg /usr/local/lib/grub/x86_64-xen/*.mod

assuming a dedicated /boot/ partition

cat > grub.cfg <<EOF
normal (xen/xvda,msdos1)/grub2/grub.cfg
EOF
ls -lF /usr/local/lib/grub/x86_64-xen/
grub-mkimage --prefix=/grub2 -o /data/kernels/pvgrub \
    -O x86_64-xen -c grub.cfg /usr/local/lib/grub/x86_64-xen/*.mod

#grub-x86_64-xen.bin

Ready to go

kernel = "/data/kernels/pvgrub"

xl create centos -c

e
linux ...
initrd ...
^x

cp -a /etc/grub.d/10_linux /root/etc-grub2-10_linux.original
sed -i -e 's/sixteenbit="16"/sixteenbit=""/' /etc/grub.d/10_linux
grub2-mkconfig -o /boot/grub2/grub.cfg
sync
reboot

Resources

PvGrub2 https://wiki.xenproject.org/wiki/PvGrub2

15.1.36 prefix https://www.gnu.org/software/grub/manual/grub/html_node/prefix.html

Bug 1173993 - grub2: linux16 and initrd16 instead linux and initrd https://bugzilla.redhat.com/show_bug.cgi?id=1173993


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Copyright © 2024 Pierre-Philipp Braun