PV Grub

RSS

PV Grub

Last updated May 9th, 2013

Introduction

PV-Grub allows you to boot your VPS with a locally installed kernel that supports pv_ops (stable in kernels 2.6.24 and greater). The flexibility of using a custom kernel can allow you to keep up-to-date with your distributions latest security patches, to test the latest kernels from kernel.org, and can help in situations where resources are limited or custom functionality is required.

How does PV-Grub work? Your VPS will first boot a custom "Mini-OS" kernel based on the Grub Bootloader. This will search the "/boot/grub/" directory for a "menu.lst" file, which defines where your installed kernels are located. The specified kernel is then loaded into memory and "kexec" is used to boot the specified kernel.

Note: Switching to PV-Grub can result in a non-bootable VPS if it is not configured correctly. If your VPS does not boot then please switch the VPS back to the default recommended kernel.

Requirements

  • Installed kernel with pv_ops.
  • Grub Legacy boot menu.

Setup

The following guides are for Ubuntu Precise, Debian Squeeze and CentOS 6.3. These procedures may be applicable to other versions of these distributions.

Note: If the VPS has recently been provisioned and the file '/boot/grub/menu.lst' exists, the VPS is already configured to use PV-Grub with the default kernel.



Ubuntu Precise (12.04) with default kernel.

To use PV-Grub, Grub 2 should be removed if it is installed:

root@host:~# apt-get purge grub2 grub-pc

Confirm that you want to remove Grub2 and the associated files.

Install Grub legacy1 and the virtual kernel metapackage:

root@host:~# apt-get install linux-virtual grub-legacy-ec2

1 grub-legacy-ec2 - The package provides a way to keep /boot/grub/menu.1st up to date, providing update-grub-legacy-ec2.

The Package configuration will ask to create a grub menu file and will also ask for the drive(s) to install grub on - do not select any devices.

Edit /boot/grub/menu.lst, and change the groot to (hd1):

# groot=(hd1)

(Re)generate the Grub menu:

root@host:~# update-grub-legacy-ec2



Debian Squeeze (6.0) with default kernel.

Create the grub directory.

root@host:~# mkdir -p /boot/grub
root@host:~# echo 0 > /boot/grub/default

Install Grub legacy and the kernel package3:

root@host:~# apt-get install grub-legacy linux-image-xen-amd64

3 Change your architecture as required.

Update the grub menu.

root@host:~# sed s@'# kopt=.*'@'# kopt=root=/dev/xvda2 console=hvc0 ro'@g \
                 --in-place /boot/grub/menu.lst
root@host:~# sed s@'# groot=.*'@'# groot=(hd1)'@g --in-place \
                 /boot/grub/menu.lst
root@host:~# update-grub



CentOS 6.3 with default kernel.

Install the latest EL Kernel :

[root@host ~]# yum install kernel.x86_64

(Re)create the grub menu /boot/grub/menu.lst 2

default=0
timeout=5

title PV Grub Kernel
   root (hd1)
   kernel /boot/vmlinuz-xxx.el6.x86_64 ro console=hvc0 root=/dev/xvda2
   initrd /boot/initramfs-xxx.el6.x86_64.img

2 Change the kernel and the initrd for the installed versions.



Enabling PV-Grub

From the control panel locate your VPS and enable PV-GRUB.

Can we improve this article? Suggest an improvement to this article.

Suggest an Improvement

Thank you for helping us to improve this Knowledge Base article. Please type your suggestions below:

Still need help? Get in touch with us.

If you aren't able to find the help you need then please send us a question and we can help you further.