Matt Nordhoff
Linode, pv-grub and Ubuntu 12.04

Linode’s pv-grub Library article covers Ubuntu 10.04 and 11.04, but not 12.04. Having recently used pv-grub on EC2, and for other reasons, I wanted to try it out. Putting together the Library article, Linode’s old wiki, EC2’s configuration, and the effects of sleep deprivation and caffeine, here’s what I came up with.

Doing this was, surprise surprise, more fun than writing about it, so this post will be as short and nonsweet as I can make it.

$ sudo aptitude install grub-legacy-ec2

$ sudoedit /boot/grub/menu.lst

Edit menu.lst roughly like this:

--- menu.lst~	2013-03-10 00:18:09.000000000 +0000
+++ menu.lst	2013-03-10 00:21:40.000000000 +0000
@@ -17,7 +17,7 @@
 # Set a timeout, in SEC seconds, before automatically booting the default entry
 # (normally the first entry defined).
 # on ec2, with no console access, there is no reason for a timeout.  set to 0.
-timeout                0
+timeout                10

 ## hiddenmenu
 # Hides the menu by default (press ESC to see the menu)
@@ -64,7 +64,7 @@
 ## e.g. kopt=root=/dev/hda1 ro
 ##      kopt_2_6_8=root=/dev/hdc1 ro
 ##      kopt_2_6_8_2_686=root=/dev/hdc2 ro
-# kopt=root=UUID=f63cf0b4-8c2b-4327-a213-e7f5b8634c27 ro
+# kopt=root=/dev/xvda ro
 
 ## default grub root device
 ## e.g. groot=(hd0)
@@ -83,7 +83,7 @@
 ## additional options to use with the default boot option, but not with the
 ## alternatives
 ## e.g. defoptions=vga=791 resume=/dev/hda5
-# defoptions=console=hvc0
+# defoptions=console=hvc0 rootflags=nobarrier
 
 ## should update-grub lock old automagic boot options
 ## e.g. lockold=false

Increasing timeout gives you 10 seconds to log into lish and choose which kernel you want while booting.

Changing the kopt line – your filesystem’s UUID will be different – is necessary because Linode might change the UUID (e.g. if you restore from a backup), so it’s safer to specify /dev/xvda.

rootflags=nobarrier avoids a compatibility issue between newer kernels like Ubuntu Precise’s and less-newer Linode hosts that would otherwise make your fs go read-only and ruin your day.

$ sudoedit /etc/fstab

Add barrier=0 to your filesystem mount options, like so:

--- fstab~	2013-03-10 03:45:18.000000000 +0000
+++ fstab	2013-03-10 03:45:23.000000000 +0000
@@ -6,6 +6,6 @@
 #
 # <file system> <mount point>   <type>  <options>       <dump>  <pass>
 proc        /proc        proc    defaults                       0 0
-/dev/xvda   /            ext3    noatime,errors=remount-ro      0 1
-/dev/xvdb   /home        ext3    noatime,errors=remount-ro      0 2
+/dev/xvda   /            ext3    noatime,errors=remount-ro,barrier=0      0 1
+/dev/xvdb   /home        ext3    noatime,errors=remount-ro,barrier=0      0 2
 /dev/xvdc   none         swap    sw                             0 0

This is for the same reasons as the rootflags=nobarrier stuff above. I think you can skip it on the root fs, but it won’t hurt, and you definitely need it on any secondary filesystems.

$ sudo aptitude install linux-virtual

After downloading and installing roughly half of the repository, this will eventually pop up a curses interface asking you to install grub-pc on your MBR. You do not have an MBR. Hit Enter without selecting any of the devices to get through the first screen, then hit Left and Enter to select <Yes> in the confirmation screen.

From here, you can switch to the Linode Library guides for 10.04 or 11.04, starting with the line “Create the file /etc/init/hvc0.conf with the following contents.”. (That file may already exist, but in any case, you do need to follow the later instructions.)

(Caveat: menu.lst includes entries to boot into single-user mode. They are broken. This would not be hard to fix – see defoptions and kopt – but my heart belongs to Finnix, so I don’t care.)

(Edits: Copy editing.) (Edit, 2013-03-10T03:54:43Z: Elaborate on /etc/fstab and barrier=0. Remove note about single-user mode – it seems to work?) (Edit, 04:09:12Z: Wait, no, single-user mode doesn’t work. Elaborate.)