This page is part of my webdevster.com tutorial, see index to OpenQRM and XEN LVM based HVM VM.

[2.4] Step 4. Configure LVM for Xen VM

Here is a breakdown (I’m keeping it simple here) of the LVM, installation process.

LVM->VG->LV->VM OS

The VM image (OS and Swap) will be on one LV. The LV will be on the VG. LV will be treated as one Hard Drive available to the VM, therefore the VM, upon installation will create partitions inside LV, i.e. OS on primary partition and Swap - logical disk; depending on your preference.

Create Volume Group (VG) and a Logical Volume (LV) on your LVM, for your Xen VM.

Now, since we already created an LVM partition, prior to installing Debian, all that’s left is to create a Volume Group, (VG), and Logical Volumes (LV).

prompt>fdisk -l

 

Disk /dev/sda: 72.9 GB, 72999763968 bytes
255 heads, 63 sectors/track, 8875 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000d4c0c
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         486     3903763+  83  Linux
/dev/sda2             487         729     1951897+   5  Extended
/dev/sda3             730        8875    65432745   8e  Linux LVM
/dev/sda5             487         729     1951866   82  Linux swap / Solaris
  • We’ll be creating one VG in sda3 LVM partition, and naming it vol.

    To initialize partition to support LVM

    prompt>pvcreate /dev/sda3

    Create a VG named vol.

    prompt>vgcreate vol /dev/sda3
  • We’ll be creating one LV in the newly created VG vol, and naming it vmx01cms01 (to match our VM host name).

    The size will be 15gb. Read notes directly below to learn more…

    prompt>lvcreate -L 15gb -n vmx01cms01 vol prompt>mkfs -t ext3 /dev/vol/vmx01cms01
  • View the newly created LV:
    prompt>lvdisplay

     

      --- Logical volume ---
      LV Name                /dev/vol/vmx01cms01
      VG Name                vol
      LV UUID                tcswzC-yo6x-vFcn-RqgV-C2DU-RBBQ-SpoiZc
      LV Write Access        read/write
      LV Status              available
      # open                 0
      LV Size                15.00 GB
      Current LE             3840
      Segments               1
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     256
      Block device           254:0

Now your LV is ready for a VM installation. On to the next.

NOTE:
Once the OS is installed, the size 15gb, can be changed with Gparted LiveCD, like you would any computer. The steps are easy with OpenQRM. With OpenQRM WebUI, you first backup the LV, by cloning the LV, increase size of the cloned LV, and boot VM with Gparted LiveCD. Done.

[2.5] Step 5. Install Xen Guest VM, on Xen Host LV

Here we’ll install the Operating System VM on the newly created LV, with a Debian x64 OS. Our goal, for our purpose here is to simply populate the LV with an OS.

Download the OS image ISO.

We are using an ISO, instead of a cdrom to install the OS.

prompt>mkdir -p /dl/os && cd /dl/os

Visit http://releases.ubuntu.com/ or http://www.debian.org/releases/lenny/debian-installer/, and select your version (copy download link) of Ubuntu (i.e. Lucid Lynx LTS x64) or Debian Lenny; same VM installation applies to either distro. In my example we’ll download Debian GNU/Linux 5.0.6 (Lenny) AMD Net install.

prompt>wget http://cdimage.debian.org/debian-cd/5.0.6/amd64/iso-cd/debian-506-amd64-netinst.iso

 

Create the VM (domU)

We’ll create a VM on the LV we created. This process, directly uses the Xen VM cfg creation file by means of HVM (full virtualization), instead of starting with the normal xen-tools.conf file, which creates this Xen VM cfg file for us (mostly used for paravirtualization).

Create a new Xen VM config file:

prompt>nano /etc/xen/vmx01cms01.cfg

Copy, paste, and save the following into this new vmx01cms01.cfg, file.

kernel = "/usr/lib/xen-default/boot/hvmloader"
builder='hvm'
device_model="/usr/lib/xen-3.2-1/bin/qemu-dm"
name = "vmx01cms01"
#vif = [ 'type=ioemu, bridge=eth0' ]
vif = [  "mac=00:79:F9:AC:AA:98, type=ioemu, bridge=eth0", ]
#disk = [ 'phy:/dev/vol/vmx01cms01,ioemu:hda,w','file:/dl/os/ubuntu-10.04.1-server-amd64.iso,ioemu:hdc:cdrom,r']
disk = [ 'phy:/dev/vol/vmx01cms01,ioemu:hda,w','file:/dl/os/debian-506-amd64-netinst.iso,ioemu:hdc:cdrom,r']
boot="d"
vnc=1
vncviewer=1
vncdisplay=6

TIP:
It’s advisable to set the random MAC address right way, so you don’t run into any ethernet issues or other issues. Visit, Test MAC Address Generator, to auto generate a MAC address for you. Download your own portable random MAC address generator, from Random MAC address generator OR visit Xen Wiki - MAC Address, to guide you through the process of creating your own MAC address.

 

TIP:
For windows installation, you can change hdc:cdrom to hdb:cdrom, per Xen 3.0.4 HVM and Debian Etch.
If you decide to use the cdrom of Xen host, change: file:/dl/os/debian-506-amd64-netinst.iso,ioemu:hdc:cdrom,r to: phy:/dev/cdrom,hdc:cdrom,r and change boot=”d” to boot=”c”. This is not in the scope of this tutorial; just FYI.
If you decide to create a boot order 1 Cdrom than 2 Disk, change boot=”d” to boot=”cd”.
It’s advisable to assign a random MAC address right away, so you don’t have problems with your ethX coming up.
If you don’t need to assign a MAC address right away, change vif = [ "mac=00:79:F9:AC:AA:98, type=ioemu, bridge=eth0", ] to vif = [ 'type=ioemu, bridge=eth0' ]
If you would like to change the vnc display (i.e. vncviewer 127.0.0.1:6) to 7 (i.e. vncviewer 127.0.0.1:7), change vncdisplay=6 to vncdisplay=7.

NOTE:
Your Xen host is using (5) for vnc display, i.e. vncviewer 127.0.0.1:5, so it’s a good idea to keep or set the VM vncdisplay=6 to another number other than 1-5, i.e. vncviewer 127.0.0.1:7; to make sure their is no conflict, when we move onto OpenQRM. OpenQRM, will start the vnc displays for the newly created VMs at 1.

Start the Installation Process

prompt>xm create /etc/xen/vmx01cms01.cfg

NOTE:
If you decide not to go through with the installation (no harm done), i.e. you decide to reconfigure something. prompt> xm destroy vmx01cms01

View and interact with the installation process via VNC Client

  • If your client is on a Windows Machine, launch VNC Client viewer (display), and type in:
    10.1.11.11:5906 or 10.1.11.11:6
    You’ll be prompted for password.
  • If your client is on your Xen host Server, than type in:
    localhost:6 or x01:6 or 127.0.0.1:6
    You’ll be prompted for password.
  • If your client is on a Linux Machine, than type:
    prompt>vncviewer 10.1.11.11:6
    Connected to RFB server, using protocol version 3.8
    Performing standard VNC authentication<
    Password: [Enter Password]

Your VNC display will look like this:
VNC VM Guest Display

Depending on your hardware, it may take a while for each ‘task’ to install, so just be patient. The graphics rendering will take a while to render (this is normal), since we don’t have xorg or Gnome installed; and we’re remoting into the system through VNC. However, if each installation ‘task’ is taking a super long time, than check vmx01cms01.cfg file to make sure it’s hdc not hdb.

If VNC display is not coming up, you can troubleshoot Xen HOst ‘qemu-dm’ with the following command:

prompt>netstat -tap

or you might of just forgot to start the vncserver

prompt>vncserver

Make sure to make it start up on Xen host boot, like described above VNC Server Installation and Configuration - Autostart at Boot.

Install VM

Host Name vmx01cms01
Domain Name lc1.cloud1
So the FQDN is vmx01cms01.lc1.cloud1

Answer each step of the installation process, as though you were installing a physical server to your preference. I selected Guided Partitioning -> Guided - use entire disk, or you can use manual partitioning with no LVM; two ‘primary’ partitions; 12gb for OS and 4.1gb for swap; swap in my case is twice the size of ram I will give the VM.

See My Example:
VM Guest Partition - My Example

The reason I selected two primary partitions, is to keep it simple and chances are I will not be adding more than three partitions, so no need for logical swap. With normal partitioning instead of LVM, you’ll be able to use Gparted in the future. This is totally up to you, because it depends on what the VM, is going to be used for; this is key. Finish the installation.

Remove ISO image

The final step in the installer, “Installation Complete” is to boot into your new system. At this point or during installation process you’ll want to remove “iso image” directive, by editing your vmx01cms01.cfg file.

Pay attention here:

prompt>nano /etc/xen/vmx01cms01.cfg

If you want to use the Xen host’s cdrom drive:

change:

disk = [ 'phy:/dev/vol/vmx01cms01,ioemu:hda,w','file:/dl/os/debian-506-amd64-netinst.iso,ioemu:hdc:cdrom,r']
boot="d"

to:

disk = [ 'phy:/dev/vol/vmx01cms01,ioemu:hda,w','phy:/dev/cdrom,hdc:cdrom,r', ]
boot="cd"

If you don’t want to use the Xen host’s cdrom drive:

change:

disk = [ 'phy:/dev/vol/vmx01cms01,ioemu:hda,w','file:/dl/os/debian-506-amd64-netinst.iso,ioemu:hdc:cdrom,r']
boot="d"

to:

disk = [ 'phy:/dev/vol/vmx01cms01,ioemu:hda,w', ]
#boot="d"

NOTE:
If you choose to use Xen host’s cdrom, than you must always, “I repeat again”, always have a cdrom drive attached to the Xen host, or else the VM will fail to boot. This gave me a lot of headaches, you’ll see a message in xend.log like:
DEBUG (DevController:156) Waiting for 768.
DEBUG (DevController:595) hotplugStatusCallback /local/domain/0/backend/vbd/4/768/hotplug-status.

Boot into new VM

You can now select: “Continue” to boot into new system.

prompt>xm destroy vmx01cms01 prompt>/etc/init.d/xend restart prompt>xm create /etc/xen/vmx01cms01.cfg

View Progress (or troubleshoot), by opening another ssh terminal:

prompt>tail -f /var/log/xen/xend.log -n 30

View and interact with your new VM via VNC Client

prompt>vncviewer 10.1.11.11:6

If it fails, it’s best to restart Xen host, as your first troubleshoot try.

prompt>reboot

At this point, do not configure the VM OS settings (i.e. static, etc.) once it reboots. The configuring is best done after OpenQRM, takes control of it (or finished with this tutorial).

Create Backup of the Xen VM cfg file

After you have a working VM, it’s a good idea to make a copy of it.

prompt>mkdir -p /bak/vm prompt>cp /etc/xen/vmx01cms01.cfg /bak/vm/

You, now you have the LV populated with an OS.

Before moving onto the next chapter (Chapter 3 - Integrating OpenQRM with Xen.), reboot, to check if everything is successful

prompt>reboot

If you need additonal help, please see next page 9, Step 6. Xen Troubleshooting and Optional Useful CLI Commands. Otherwise, you can go straight to page 10, Chapter 3 - Xen and OpenQRM Integration.

Pages: 1 2 3 4 5 6 7 8 9 10 11

This entry was posted on Sunday, November 21st, 2010 at 6:51 pm and is filed under How To. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.