With Xen installed, network bridging setup, and an LVM volume group ready, I created my first virtual machine.
Using https://help.ubuntu.com/community/Xen#Manually_creating_a_PV_Guest_VM as a guide:
Creating the Drive
I created a logical volume for the first VM:
lvcreate -nGuestA1-root -L100G Host-A-vg
Getting the Netboot Files
I needed something for the initial boot of the VM to run so we can install our OS. Ubuntu Netboot is an easy way to get a working OS installed.
mkdir -p /var/lib/xen/images/ubuntu-netboot cd /var/lib/xen/images/ubuntu-netboot/ wget ftp://ftp.utexas.edu/pub/ubuntu/dists/trusty/main/installer-amd64/current/images/netboot/xen/initrd.gz wget ftp://ftp.utexas.edu/pub/ubuntu/dists/trusty/main/installer-amd64/current/images/netboot/xen/vmlinuz
Creating the Configuration File for the VM
vim /etc/xen/GuestA1.cfg
Added the following:
name = "GuestA1" memory = 512 disk = ['phy:/dev/Host-A-vg/GuestA1-root,xvda,w'] vif = [' '] kernel = "/var/lib/xen/images/ubuntu-netboot/vmlinuz" ramdisk = "/var/lib/xen/images/ubuntu-netboot/initrd.gz" extra = "debian-installer/exit/always_halt=true -- console=hvc0"
Initial Run of the VM
Ran the VM to start the netboot install: xl create /etc/xen/GuestA1.cfg -c
At this point, the console changed to show the install choices for netboot. I just ran through the Ubuntu install. At the end of the install, it gives the familiar message that the system needs to reboot. The extra= line tells the VM to halt instead.
The final step is to replace the netboot kernel and disable the ramdisk. Initially I set it to boot with pygrub by changing /etc/xen/GuestA1.cfg by adding
bootloader = "pygrub"
and commenting out or removing
kernel = "/var/lib/xen/images/ubuntu-netboot/vmlinuz" ramdisk = "/var/lib/xen/images/ubuntu-netboot/initrd.gz" extra = "debian-installer/exit/always_halt=true -- console=hvc0"
Then running xl create /etc/xen/GuestA1.cfg -c again used pygrub to load the kernel and allowed the system to boot and give me a console.