Grant McWilliams

31 items tagged "Xen"

  • A disk free command for Xen Cloud Platform

    XCP and Xenserver store their Virtual Disk Images on storage repository. To see how much space you have on your LVM or lvmoisci storage repositories from the commandline can be quite a chore so I wrote a df command for storage repositories. My dfsr command mimics the output of the Linux df command with the human readable flag set (-h). All values will be printed in Kilobytes, Megabytes, Gigabytes and so on. It shows the size of the repository, how much is used, how much is available, the percent used and the Storage Repository type. 

     Get it from my Virtualization downloads section.

     

     

     

     

     

     

     

  • Add a CD to a VM

    Prerequisites

    • XCP/Xenserver

    Adding a CD to a running VM is not a difficult task if you know which commands to use. By adding I mean we're going to insert a virtual CD disk into a virtual machine using our little virtual hands. ;-)

     

    1. Get the name of your Virtual Machine

    In this case the name is CentOS6 and the UUID is cefb9f88-0424-6701-5ba1-070490c69203.

    [ root@cloud2 ~/bin ] xe vm-list
         uuid ( RO)           : cefb9f88-0424-6701-5ba1-070490c69203
              name-label ( RW): CentOS6
             power-state ( RO): running

     

    2. Get the name of the CD disk

    In this case our disk is named CentOS-6.3-x86_64-LiveCD.iso.

    [ root@cloud2 ~/bin ] xe cd-list
        uuid ( RO)          : 0549c68a-e38d-4cd8-9974-ba0b9167ff5a
            name-label ( RW): CentOS-6.3-x86_64-LiveCD.iso
    

     

    3. Identify a free Virtual Block Device number

    Use the VM UUID that we retrieved in step 1.

    [ root@cloud2 ~/bin ] xe vm-param-get uuid=cefb9f88-0424-6701-5ba1-070490c69203 \
    param-name=allowed-VBD-devices 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15

     

    4. Add the CD to the VM. Use the VM UUID from step 1, the CD name from step 2 and the VBD device number from step 3.

    [ root@cloud2 ~/bin ] xe vm-cd-add uuid=cefb9f88-0424-6701-5ba1-070490c69203 \
    device=5 cd-name=CentOS-6.3-x86_64-LiveCD.iso

     

    5. Verify using xe vm-cd-list

     By using xe vm-cd-list we can list the CD's currently plugged into our VM.

     

    [ root@cloud2 ~/bin ] xe vm-cd-list uuid=cefb9f88-0424-6701-5ba1-070490c69203 
    CD 0 VBD:
    uuid ( RO)             : 40f6b5c9-14fd-4379-d82c-d0ff34472a04
        vm-name-label ( RO): 955300270
                empty ( RO): false
           userdevice ( RW): 5
    
    
    CD 0 VDI:
    uuid ( RO)             : 0549c68a-e38d-4cd8-9974-ba0b9167ff5a
           name-label ( RW): CentOS-6.3-x86_64-LiveCD.iso
        sr-name-label ( RO): NFS ISO
         virtual-size ( RO): 725614592
    

     

    6. Unplugging the CD disk

    When done with the CD you can unplug it even easier. We specify the VM UUID and tell it to eject the CD which it does. 

     

     [ root@cloud2 ~/bin ] xe vm-cd-eject uuid=cefb9f88-0424-6701-5ba1-070490c69203

     

  • Add a hard disk to a VM

    Installing from an XCP/Xenserver template usually gives you one Virtual Disk to install the operating system on. Depending on your needs this disk may not be large enough. Following is a tutorial on how to add an additional disk to a virtual machine.

    Terminology: 

     

    Virtual Machine - A virtual machine is a computer that's virtualized and running on a hypervisor. In our case the hypervisor is Xen Cloud Platform/Xenserver. The Virtual Machine can be running any operating system.

    Virtual Disk Image - Think of a Virtual Disk Image as a hard drive.

    Storage Repository - A "box" storing Virtual Disk Images. Think of this as an external box storing virtual hard drives. The virtual hard drives are the Virtual Disk Images mentioned above.

    Virtual Block Device - A Virtual Block Device connects a Virtual Disk Image to a Virtual Machine. In traditional computer terms you could think of it as the cable. 

    The process for adding a hard drive to a real computer

    1. Insert the disk in the hard drive box
    2. Connect the cable to the hard drive box
    3. Insert the cable into the Computer

    The process of adding a new Virtual Disk for a Virtual Machine is 

    1. Create a new Virtual Disk Image
    2. Create a new Virtual Block Device for it
    3. Connect the Virtual Block Device to the Virtual Machine

     

    1. Get available free space

    You will need to know how much free space is available on your Storage Repository.

    [ root@cloud2 ~ ] xe sr-list
    uuid ( RO)                : 36bf480a-5df9-4453-50f0-2bac4a86cb42
                  name-label ( RW): localsr-cloud1
        name-description ( RW): 
                             host ( RO): cloud1.acs.edcc.edu
                            type ( RO): lvm
               content-type ( RO): user

    Now that we have the Storage Repository's UUID number (36bf480a-5df9-4453-50f0-2bac4a86cb42) we can use xe sr-list again to give us the physical size and how much space is being utilized.

    [ root@cloud2 ~ ] xe sr-list uuid=36bf480a-5df9-4453-50f0-2bac4a86cb42 \
    params=physical-utilisation,physical-size
    physical-utilisation ( RO) : 214752559104 physical-size ( RO): 991600574464

    Quick math (991600574464 - 214752559104 = 776848015360) shows us that we have about 776 MB free.

    2. Create the Virtual Disk Image

    Now that we know the available space on the storage repository we can make a new Virtual Disk Image using xe vdi-create.

    [ root@cloud2 ~ ] xe vdi-create sr-uuid=bd1ac90d-7c23-dc07-dfa3-edc9f1cd73c4 \
    name-label=DATADISK type=user virtual-size=100GiB
    ee9c5daa-392c-4a0d-a5c1-4ebb7caabd73

    This command outputs the VDI's UUID. You can get information about any VDI using the xe vdi-list command.

    [ root@cloud2 ~ ] xe vdi-list uuid=ee9c5daa-392c-4a0d-a5c1-4ebb7caabd73 
    uuid ( RO)                : ee9c5daa-392c-4a0d-a5c1-4ebb7caabd73
              name-label ( RW): DATADISK
     name-description ( RW): 
                      sr-uuid ( RO): bd1ac90d-7c23-dc07-dfa3-edc9f1cd73c4
                virtual-size ( RO): 107374182400
                   sharable ( RO): false
                 read-only ( RO): false

    The result of xe vm-list shows that the virtual size of the VDI is about 100 GB and it's name-label is DATADISK. To add this new disk to a VM I'll need to get the VM's UUID number by using xe vm-list.

    [ root@cloud2 ~ ] xe vm-list name-label=CentOS6
         uuid ( RO)           : cefb9f88-0424-6701-5ba1-070490c69203
         name-label ( RW): CentOS6
          power-state ( RO): running

     

    3. Get the available Virtual Block Device numbers

    We will also need to know which Virtual Block Device numbers are available. We can use the xe vm-param-get command for this.

    [ root@cloud2 ~ ] xe vm-param-get uuid=cefb9f88-0424-6701-5ba1-070490c69203 \
    param-name=allowed-VBD-devices
    7; 8; 9; 10; 11; 12; 13; 14; 15

    In summary:

    1. VDI UUID is ee9c5daa-392c-4a0d-a5c1-4ebb7caabd73
    2. VM UUID is cefb9f88-0424-6701-5ba1-070490c69203
    3. Available VBD numbers are 7, 8, 9, 10, 11, 12, 13, 14 and 15

     

    4. Create the Virtual Block Device

    Create the Virtual Block Device (VBD) using the xe vbd-create command and the VM UUID, VDI UUID and the first available VBD number.

    [ root@cloud2 ~ ] xe vbd-create device=7 vm-uuid=cefb9f88-0424-6701-5ba1-070490c69203 \ 
    vdi-uuid=ee9c5daa-392c-4a0d-a5c1-4ebb7caabd73 bootable=false mode=RW type=Disk
    333ab620-3ee1-0420-d31a-217e4ef1df45

    I created Virtual Block Device 7 (device=7). Using device=0 would have given me a /dev/dev/xvda which I already have. The xe-param-get command showed my first available Virtual Block Device number was 7. Notice that we associated the Virtual Disk Image (VDI) to the Virtual Machine (VM) by using a Virtual Block Device (VBD).

    5. Plug in the disk to the VM

    The VM won't see the disk yet as it hasn't been "plugged in". We can do this by either rebooting the VM or using the xe vbd-plug command. Let's plug the VBD into the running VM.

    [ root@cloud2 ~ ]  xe vbd-plug uuid=333ab620-3ee1-0420-d31a-217e4ef1df45

    6. Verify that it worked

    Log into the VM via ssh or xenconsole and see if the disk appeared by catting /proc/partitions.

    [root@Centos6 ~]# cat /proc/partitions
    major minor  #blocks  name
    
     202        0    8388608 xvda
     202        1     102400 xvda1
     202        2    8285184 xvda2
     253        0    7733248 dm-0
     253        1     524288 dm-1
     202       16  104857600 xvdb

  • Centos 5 virtual machine (32 bit) installation on Xen

     

     

    A lot of this tutorial was stolen from the CentOS wiki - http://wiki.centos.org/HowTos/Xen/InstallingCentOSDomU. I've shortened it by quite a bit to make it easier.  I assume you know this already but you will need to be logged in as root or have root privileges in order to execute this tutorial.

    Creating an Image

    The first step is to create an image that will hold the domU virtual disk. Since this can just be a file filled with zeros, our usual friend dd comes in handy.  The following command will create a /srv/xen/centos5.img file of 11GB, although the actual data blocks are allocated in a lazy fashion meaning that the disk image doesn't actually take up the whole 11GB until you fill it up. This is referred to as a sparse file.

     

    dd if=/dev/zero of=/srv/xen/centos5.img oflag=direct bs=1M seek=10240 count=1

     

    Preparing the Xen configuration file for installation

    Xen uses one configuration file per domain. The configuration for the domain will be slightly different during the installation, because we have to provide installation kernels, and possibly some boot parameters. Here we download the installation kernel, ramdisk and xen config file.

  • Centos 5 virtual machine (64 bit) installation on Xen

    A lot of this tutorial was stolen from the CentOS wiki - http://wiki.centos.org/HowTos/Xen/InstallingCentOSDomU. I've shortened it by quite a bit to make it easier.  I assume you know this already but you will need to be logged in as root or have root privileges in order to execute this tutorial.

    Creating an Image

    The first step is to create an image that will hold the domU virtual disk. Since this can just be a file filled with zeros, our usual friend dd comes in handy.  The following command will create a /srv/xen/centos5.img file of 11GB, although the actual data blocks are allocated in a lazy fashion meaning that the disk image doesn't actually take up the whole 11GB until you fill it up. This is referred to as a sparse file.

     

    dd if=/dev/zero of=/srv/xen/centos5.img oflag=direct bs=1M seek=10240 count=1

     

  • Centos 6 virtual machine (32 bit) installation on Xen

    Note: I lost my original xen config files so I've created new ones here. I no longer have a xen system so I can't test them. Please let me know if the tutorial still works or not - Grant

    Introduction

    A lot of this tutorial was stolen from my CentOS 5 Installation which in turn was stolen from the CentOS wiki. I've shortened and updated it for installing a CentOS 6 DomU. I just copy and paste all the indented lines into a root terminal and voila! a CentOS VM.

    1. Creating an Virtual Disk Image

    The first step is to create an disk image that will act as the VM hard drive. The following command will create a 4 GB sparse disk image named /srv/xen/centos6.img. A sparse file is created in such a way that the disk image doesn't actually take up the whole 4GB until you fill it up. If you'd like a larger (11GB) disk image substitute seek=10240 into the following line. I make my VMs nice and small so I can move them around easier. Making a disk image larger or adding a second drive later is easier than making it smaller or taking a drive away.

     

    dd if=/dev/zero of=/srv/xen/centos6.img oflag=direct bs=1M seek=3800 count=1

    2. Preparing the Xen configuration file for installation

    Xen uses one configuration file per VM. We will start out with a config to do the install and replace it later with a config for normal operation. Now we download the install kernel, ramdisk and xen config file.

    wget http://mirror.centos.org/centos/6/os/i386/isolinux/vmlinuz -O /boot/vmlinuz-xen6-install
    wget http://mirror.centos.org/centos/6/os/i386/isolinux/initrd.img -O /boot/initrd-xen6-install
    wget http://www.grantmcwilliams.com/files/xen-centos6-i386-install -O /etc/xen/centos6

     

     

     

    3. Starting the installation

    A kickstart file holds instructions for automatic installation and is referenced in my xen config above. My example kickstart file is very minimal but is enough to get a working CentOS 6 VM.

     

  • Centos 6 virtual machine (64 bit) installation on Xen

    Note:I lost my original xen config files so I've created new ones here. I no longer have a xen system so I can't test them. Please let me know if the tutorial still works or not -Grant

    Introduction

    A lot of this tutorial was stolen from my CentOS 5 Installation which in turn was stolen from the CentOS wiki. I've shortened and updated it for installing a CentOS 6 DomU. I just copy and paste all the indented lines into a root terminal and voila! a CentOS VM.

    1. Creating an Virtual Disk Image

    The first step is to create an disk image that will act as the VM hard drive. The following command will create a 4 GB sparse disk image named /srv/xen/centos6.img. A sparse file is created in such a way that the disk image doesn't actually take up the whole 4GB until you fill it up. If you'd like a larger (11GB) disk image substitute seek=10240 into the following line. I make my VMs nice and small so I can move them around easier. Making a disk image larger or adding a second drive later is easier than making it smaller or taking a drive away.

     

    dd if=/dev/zero of=/srv/xen/centos6.img oflag=direct bs=1M seek=3800 count=1

    2. Preparing the Xen configuration file for installation

    Xen uses one configuration file per VM. We will start out with a config to do the install and replace it later with a config for normal operation. Now we download the install kernel, ramdisk and xen config file.

    wget http://mirror.centos.org/centos/6/os/x86_64/isolinux/vmlinuz -O /boot/vmlinuz-xen6-install
    wget http://mirror.centos.org/centos/6/os/x86_64/isolinux/initrd.img -O /boot/initrd-xen6-install
    wget http://www.grantmcwilliams.com/files/xen-centos6-x86_64-install -O /etc/xen/centos6

      

     

    3. Starting the installation

    A kickstart file holds instructions for automatic installation and is referenced in my xen config above. My example kickstart file is very minimal but is enough to get a working CentOS 6 VM.

     

  • Citrix looking for Xen Evangelist

    Citrix has an opening for a Xen Evangelist. From their blog:

    "The Xen Open Source Evangelist will be an advocate for Xen.org projects (Xen, Xen Cloud Platform and Xen ARM) and be primarily engaged with open source Xen users, upstream and downstream projects of Xen as well as developers of Xen.org projects. In addition the Open Source Xen Evangelist will be responsible for representing Citrix and explaining their products and services in the appropriate venues."



    It goes on to say that the person would demo and speak at key events around the world, communicate with the community, educate people on Xen and encourage the community to contribute to Xen.  
    Sounds like an interesting opportunity. For more information apply at the Citrix site

  • Convert Xen disk image to LVM Logical Volume

    How to move from a tap:aio file to an LVM Logical Volume.

    In Xen we can provide virtualized hard drives several different ways. It's not uncommon to create a large empty file using dd and then specify it as the hard drive like this.

     

  • Create a Zimbra mail server on Xen

    I this tutorial we'll set up a Xen domU specifically for Zimbra because it likes to take over an entire machine. We'll also set up authenticated mail sending via gmails smtp servers and configure our router to forward requests to the appropriate domU. Lastly we'll use Apache on another machine (virtual or not) to proxy web connections to our DomU.

     

    You will want to follow the Create a Centos virtual machine on Xen tutorial before continuing with these instructions. Once you have created your Xen Virtual Machine running CentOS5 proceed with this tutorial.

     

    Preparing for installation

    Before you install Zimbra you want to set the network settings and hostname. I would advise you to set a static IP address for the Virtual Machine as well as setting the hostname to something unique. If this Virtual Machine is behind a NAT you'll get errors about the DNS name not being able to be resolved. We can edit the /etc/hosts to get rid of those.

    /etc/hosts

    192.168.1.102   mail.soundlinuxtraining.com

    /etc/sysconfig/network

    NETWORKING=yes

    NETWORKING_IPV6=yes

    HOSTNAME=mail.soundlinuxtraining.com

    Edit system network settings - set IP address, Netmask etc.. and set the current hostname

    system-config-network
    hostname mail.soundlinuxtraining.com
    service network restart

    Shut down Sendmail to avoid conflicts on port 25

    service sendmail stop
    chkconfig sendmail off

    Before installing Zimbra we'll install some of it's dependencies.

    yum install fetchmail gmp compat-libstdc++-296 compat-libstdc++-33 libtool-ltdl

    Installing Zimbra

    We need to download Zimbra in order to install it.

  • Create an EXT CD repository

     Prerequisites 

    • XCP/Xenserver

     Utilizing an ISO image in a VM's cdrom drive is fairly easy to do but because of the limited size of the Control Domain's (dom0) operating system partition it's difficult to download ISO images to /opt/xensource/packages/iso and it isn't really recommended to put them there anyway. In this tutorial we'll create a CD repository using an additional hard drive on Dom0.

    First we need to know the device name of the disk. 

    [root@cloud1 media]# cat /proc/partitions 
    major minor  #blocks  name
       8        0  976762584 sda
       8        1    4194304 sda1
       8        2    4194304 sda2
       8        3  968371393 sda3
       8       16  234431064 sdb
  • Create an LVM CD repository

     Prerequisites 

    • XCP/Xenserver

     Utilizing an ISO image in a VM's cdrom drive is fairly easy to do but because of the limited size of the Control Domain's (dom0) operating system partition it's difficult to download ISO images to /opt/xensource/packages/iso and it isn't really recommended to put them there anyway. In this tutorial we'll create a CD repository using an local Logical Volume.

    First we need to know the name of the LVM Volume Group. This is taken from the Storage Repository's UUID. To get this we'll use xe host-list. 

    [root@cloud1 ~]# xe sr-list type=lvm
    uuid ( RO)                : 36bf480a-5df9-4453-50f0-2bac4a86cb42
              name-label ( RW): localsr-cloud1
        name-description ( RW): 
                    host ( RO): cloud1.acs.edcc.edu
                    type ( RO): lvm
            content-type ( RO): user
    
    

    Using xe sr-list type=lvm shows only our local Storage Repository which has the UUID of 36bf480a-5df9-4453-50f0-2bac4a86cb42. We'll now use the vgs command to give us the names of all Volume Groups including VG_XenStorage-36bf480a-5df9-4453-50f0-2bac4a86cb42 which matches our SR UUID.

  • Create an NFS CD repository

     Prerequisites 

    • XCP/Xenserver

     Utilizing an ISO image in a VM's cdrom drive is fairly easy to do but because of the limited size of the Control Domain's (dom0) operating system partition it's difficult to download ISO images to /opt/xensource/packages/iso and it isn't really recommended to put them there anyway. In this tutorial we'll create a CD repository using an NFS share.

    In our example we'll be using a share on the cloud0 host named /media/NFSISO. To set this up on cloud0 you'd log into cloud0 as root and add this line to the /etc/exports file of your NFS server. 

     

    /media/NFSISO/ *(rw)

     

    I'd recommend that you secure your NFS share more tightly than I've done here but for the purpose of this tutorial we'll go with it. We need to make a directory that we can mount our NFS share on first.

  • Getting Started with Xen

    I'm using a Xen Virtual Server to provide my Linux students with their own machines with admin rights. This has prompted interest in Xen from a lot of people just starting out in Virtualization. Following is a quick explaination of Xen and how to get a Virtual Machine up and running as fast as possible.

    Hypervisors

    Xen is a hypervisor meaning that it runs above the hardware but below any OS. Traditionally when you "virtualized" an OS you'd have a computer that you logged into which you installed virtualization software on such as VMWare workstation or VirtualBox. With this software you'd start the Virtual Machine from it's GUI and install the Guest OS via CDROM. In this case you have a Host Machine (the real physical machine) and a Guest Machine (the virtualized OS). With a hypervisor ALL operating systems are virtualized. This might seem a bit strange or impossible but is very powerful and extremely effecient. The side effect is that Xen can be very complex to set up. Let me explain the Xen boot process.

    Xen Boot Process

    1. Machine runs code in Master Boot Record
    2. Bootloader loads the OS kernel
    3. Xen lodges itself in memory and loads the rest of the kernel in a Virtual Machine
    4. The user logs into the first Virtual Machine and starts, stops and restarts the other Virtual Machines from there

    The name for the first Virtual Machine is Dom0 - it's the privileged Domain so it has direct access to the physical hardware. All subsequent Virtual Machines that are started are called DomU - unprivileged Domains. To manage a Xen Virtual Server you log into the Privileged Domain (Dom0) and use various commands to administer the Unprivileged Domains (DomUs).

    Two modes of Virtualization

    Virtualizers work in one of two modes - paravirtualization or hardware (full) virtualization. The difference being that a paravirtualized DomU OS knows it's being virtualized and has extensions to allow and assist in this. Paravirtualized Operating Systems are very fast and effecient. However there are times when you won't be virtualizing an OS that has these extensions such as Windows. In this case you need to use a CPU that has hardware vitualization support and run Xen in HVM (Hardware Virtualization Mode).

    Paravirtualization:

    • Runs on a lot of hardware - x86, x86-64, Itanium and PowerPC 970 with or without hardware Virtualization support
    • DomUs can be Linux, NetBSD and Solaris
    • Very fast

    Full Virtualization:

    • Requires Intel or AMD cpus with Virtualization Support built in
    • DomUs can be most any unmodified OS including Windows
    • Not so fast

    To get around the speed issues with Full Virtualization there are paravirtualized drivers that have been written for many Operating Systems including Windows for disk access and network cards. This allows Full Virtualization to reach the speeds of paravirtualization in these two areas without requiring further modification to the Operating System. The Linux KVM Hypervisor runsin Full Virtualization mode all the time and thus needs paravirtualized drivers.

     

     

  • Install Xen 3.4 on CentOS 5 (32 bit) the easy way

     

    1. First we need to add the YUM repository holding the updated Xen. You will need to be logged in as root to carry out these instructions

     

    wget http://www.gitco.de/linux/i386/centos/5/CentOS-GITCO.repo -O /etc/yum.repos.d/CentOS-GITCO.repo

    2. Uninstall and reinstall the Virtualization group

    yum groupremove Virtualization
    yum update
    yum clean all
    yum groupinstall -y Virtualization
  • Install Xen 3.4 on CentOS5 (64bit) the easy way

    1. First we need to download the YUM repository file for the updated Xen. Then uninstall the old Virtualization group and reinstall it. This will upgrade the packages.

    wget http://www.gitco.de/linux/x86_64/centos/5/CentOS-GITCO.repo -O /etc/yum.repos.d/gitco.repo
    yum groupremove Virtualization
    yum groupinstall -y Virtualization

    Yum will probably want to upgrade some other files along with the ones we've chosen.

    Warning! If you get an error message from grubby this is bad!

    Installing: kernel-xen                   ####################### [ 9/13]
    grubby fatal error: unable to find a suitable template

    This means that your grub.conf file couldn't be written to for whaterver reason so you won't be able to successfully reboot. If you get this message you need to edit your /boot/grub/grub.conf file and make the kernel lines match the kernel you installed.

    Get your installed kernel version:

    [ root@vs / ] rpm -q kernel-xen

    kernel-xen-2.6.18-128.4.1.el5

    Now edit your /boot/grub/grub.conf to match this

    # grub.conf generated by anaconda
    #
    # Note that you do not have to rerun grub after making changes to this file
    # NOTICE:  You have a /boot partition.  This means that
    #          all kernel and initrd paths are relative to /boot/, eg.
    #          root (hd0,0)
    #          kernel /vmlinuz-version ro root=/dev/vgsys/lvroot
    #          initrd /initrd-version.img
    #boot=/dev/sda
    default=0
    timeout=5
    splashimage=(hd0,0)/grub/splash.xpm.gz
    hiddenmenu
    title CentOS (2.6.18-128.4.1.el5xen)
    root (hd0,0)
    kernel /xen.gz-3.4.0
    module /vmlinuz-2.6.18-128.4.1.el5xen ro root=/dev/vgsys/lvroot rhgb quiet
    module /initrd-2.6.18-128.4.1.el5xen.img

    4. Reboot - no really I mean it.

    5. Try it out by using the xm dmesg command

    \ \/ /___ _ __   |___ / |___ / / _ \
    \  // _ \ '_ \    |_ \   |_ \| | | |
    /  \  __/ | | |  ___) | ___) | |_| |
    /_/\_\___|_| |_| |____(_)____(_)___/

    (XEN) Xen version 3.3.0 (This email address is being protected from spambots. You need JavaScript enabled to view it.) (gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)) Tue Sep  9 20:18:14 CEST 2008
    (XEN) Latest ChangeSet: unavailable
    (XEN) Command line:
    (XEN) Video information:
    (XEN)  VGA is text mode 80x25, font 8x16
    (XEN)  VBE/DDC methods: V2; EDID transfer time: 2 seconds
    (XEN) Disc information:
    (XEN)  Found 1 MBR signatures
    (XEN)  Found 1 EDD information structures
    (XEN) Xen-e820 RAM map:

    That's about all. If you have any questions drop a comment here.

  • Install xen-tools on CentOS 5.x

     

    Download xen-tools, install rpmstrap and install xen-tools. If there's a newever version of xen-tools available substitute that filename

    yum install -y rpmstrap 
    wget http://xen-tools.org/software/xen-tools/xen-tools-3.9.tar.gz
    tar -xzvpf xen-tools-3.9.tar.gz
    cd xen-tools-3.9/
    make install

    I've not using xen-tools that much but I wanted to put together a tutorial anyway. Let me know how it goes.



  • List XCP Host information

    I've been working on ways of getting information to the XCP/Xenserver Admins eyes faster than the standard xe commandline tool provides. This tool - lshosts is a rewrite of lshostvms.sh which showed each host and how many running VMs were on it, something I often would like to know. While rewriting it to include some of the better structure of my newer tools I started adding features. Now it displays either the Host's name-label or UUID, the number of running VMs, the CPU type, CPU cores, CPU speed, Total Memory, Free Memory and Network backend type. 

    As an added bonus I've added a -c option so the output is in CSV format. All future commands should have this option and I'll be retrofitting older commands when I get time.

    Download it from the XCP Downloads section. http://grantmcwilliams.com/tech/virtualization/downloads/category/4-xen-cloud-platform

  • Reboot stuck VMs

    Prerequisites

    • XCP/Xenserver

     

    Sometimes I get a stuck Virtual Machine that just won't go down and it's usually due to a lack of memory in the VM. When I issue a shutdown command from within the VM it starts the shutdown process but hangs part way through. Executing xe vm-shutdown --force uuid=<insert UUID here>  does nothing but lock up the terminal. If this happens to you follow the steps below to forcefully shut the VM down.  

    1. xe task-list (find the pending tasks UUID)
    2. xe task-cancel uuid=<task UUID>
    3. xe vm-list (note the VM's UUID)
    4. list_domains (find the VM's UUID and note the domain id)
    5. /opt/xensource/debug/destroy_domain -domid XX (where XX is the domain id from step 2)
    6. xe vm-shutdown --force uuid=<UUID from step 1>
    This will canceling the tasks that may be locking any new tasks e.g. the shutdown commands, destroying the domain and then shutting the VM down. I've had to do this several times on an Apache webserver that's getting pummeled from the Internet. 
     

    The steps above in script form (if you trust me). Step one has to be entered in manually. The rest can be copied and pasted.

    name="Name Label"
    TASK=$(xe task-list status=pending --minimal)
    xe task-cancel uuid="$TASK"
    VMUUID=$(xe vm-list name-label="$name" --minimal)
    DOMID=$(xe vm-list uuid="$VMUUID" params=dom-id --minimal) /opt/xensource/debug/destroy_domain -domid "$DOMID" xe vm-shutdown --force uuid="$VMUUID"

     

     

     

     

     

     

  • Resize Disk Image used as Xen DomU hard drive

    Scenario: In the Dom0 (Host) you have a file that you export to the DomU (Guest) and it appears as an entire hard drive and you want to make it larger.

    Example- Dom0: /srv/xen/diskimage.img -> DomU: /dev/xvda

     

    If you're using diskimages for your DomU drives you may need to increase their size if any of the DomU partitions become full.

    Resize the Xen Diskimage in Dom0

    1. Create a backup of the diskimage from Dom0

    2. Shutdown the DomU

    3. Add extra space to the diskimage using dd. This will add 1GB to the DomU image. Adjust count=  depending on how much you want to add. If you want a sparse file use seek= to define the entire disk size.

    dd if=/dev/zero bs=1M count=1024  >> ./diskimage.img

    or if you want a sparse file

    dd if=/dev/zero bs=1 count=0 seek=1G  >> ./diskimage.img

    4. Boot the domU

    Your disk should now be larger. You will need to use traditional tools inside the DomU to make the partitions and filesystems larger.

    Following are examples for Partitions and LVM.

     

    Expanding DomU Partitions from within DomU

    In this example we're using /dev/xvda as the example DomU device name, change this depending on your setup. Note this tutorial only works for resizing the last partition on the diskimage drive.

    1. Start the DomU and log in as root

    2. Start fdisk /dev/xvda

    3. Delete the last partition and recreate it with the start cylinder being identical as before and the ending cylinder being the default (end of disk)

    4. Exit fdisk

    5. You may have to reboot the DomU before going on.

    5. Resize the filesystem on the partition - resize2fs /dev/xvda1

     

    That's really it! You can only hot resize if the Filesystem is getting larger. If you need to shrink it then you'll have to take the Volume offline first. Isn't this easier than dealing with partitions that are too small?

    If the partition you want to resize is in the middle of the DomU drive you're in a bit of a pickle. For example if you want to resize / you have problems.

    • /boot - /dev/xvda1
    • / - /dev/xvda2
    • /var - /dev/xvda3

    This is the primary reason to using LVM. The solution to this problem isn't very elegant. You basically need to make another disk image and attatch it to the DomU in exactly the same manner as you attached /dev/xvda. The new drive should appear as /dev/xvdb if that's the way we entered it in the DomU config. Once it's done you need to restart DomU, fdisk and format the drive. Once formatted you can mount it and copy all of /var over, change /etc/fstab to map /var to /dev/xvdb1 and reboot the DomU again. Once rebooted you can delete /dev/xvda3 and resize /dev/xvda2.

    This process is really no different than if you had a real server but you don't have to install a physical hard drive. I think this shows why LVM is such an improvement over physical partitions.

     

     

  • Resize Disk Image used as Xen DomU partition

    Scenario: In the Dom0 (Host) you have a file that you export to the DomU (Guest) and it appears as a hard drive partition and you want to make it larger.

    Example- Dom0: /srv/xen/diskimage.img -> DomU: /dev/xvda1

     

    Resize the Disk Image in Dom0

    1. Shutdown the DomU

    2. Create a backup of the Disk Image using the cp command

    3. Add extra space to the diskimage using dd. This will add 1GB to the DomU image. Adjust count= depending on how much you want to add. If you want a sparse file use seek= to define the entire disk size.

    dd if=/dev/zero bs=1M count=1024 >> ./diskimage.img

    or if you want a sparse file

    dd if=/dev/zero bs=1 count=0 seek=1G >> diskimage.img

    4. Boot the domU

    Your view /proc/partitions your disk should now be larger. You will need to use traditional tools inside the DomU to make the partitions/LVs and filesystems larger as outlined below.

     

    Expanding DomU Partitions

    In this example we're using /dev/xvda as the drive name inside the DomU. Due to limitations in the way traditional partitions work this tutorial is only useful for resizing the last partition on the DomU drive.

    1. Start the DomU and log in as root

    2. Run fdisk /dev/xvda

    3. Note the last partitions start cylinder, then delete the last partition and recreate it with the start cylinder being the same as before and the end cylinder being the default (end of disk)

    4. Save this and exit fdisk

    5. Run partprobe to update the kernels partition table. View /proc/partitions to see if the last partition is now larger. If not, reboot.

    5. Resize the filesystem on the partition, for example using xvda2: resize2fs /dev/xvda2

     

    Expanding DomU Logical Volumes

    If you configured your DomU to use LVM and your Logical Volume is not big enough you can resize it.

    In the DomU we get the Logical Volume name by using the lvdisplay command.

    [ root@vs /srv/xen ] lvdisplay
    --- Logical volume ---
    LV Name                /dev/vgsys/lvvirt
    VG Name                vgsys
    LV UUID                XMWzWW-oZih-A5uH-91Sa-7l1y-8cqf-18KcNB
    LV Write Access        read/write
    LV Status              available
    # open                 1
    LV Size                60.00 GB
    Current LE             1920
    Segments               2
    Allocation             inherit
    Read ahead sectors     auto
    - currently set to     256
    Block device           253:2


    According to lvdisplay the path to our Logical Volume is /dev/vgsys/lvvirt.


    Hot Resizing Logical Volume:

    Resizing the Logical Volume is actually very easy, you'll be amazed.

    lvresize --size +10G /dev/vgsys/lvvirt

    This lvresize command specifies to add 10GB to /dev/vgsys/lvvirt. This will only take a second.

     

    Hot Resizing the filesystem:

    resize2fs /dev/mapper/vgsys-lvvirt

    That's really it! You can only hot resize if the Filesystem is getting larger. If you need to shrink it then you'll have to take the Volume offline first. Isn't this easier than dealing with partitions that are too small?

  • Resize Logical Volume used as DomU hard drive

    Scenario: In the Dom0 (Host) you have an LVM Logical Volume that you export to the DomU (Guest) and it appears as an entire hard drive which you want to make larger.

    Example- Dom0: /dev/VolGroup00/LogVol00 -> DomU: /dev/xvda

     

    Resizing an LVM Logical Volume used as a DomU drive

    A Logical Volume used as a DomU drive will appear in the DomU as /dev/xvda. A Logical Volume used as a DomU partition will appear in the DomU as /dev/xvda1. Please note the difference.

    The disk line in the Xen Domain config file stored in /etc/xen on the Dom0 will look something like this.

    disk = ['phy:vgsys/lvvirt,xvda,w']

    Get the Logical Volume name and path in Dom0

    On the Dom0 we need to expand the Logical Volume. We start by using the lvdisplay command to get the path to the Logical Volume

    [ root@vs /srv/xen ] lvdisplay
    --- Logical volume ---
    LV Name                /dev/vgsys/lvvirt
    VG Name                vgsys
    LV UUID                XMWzWW-oZih-A5uH-91Sa-7l1y-8cqf-18KcNB
    LV Write Access        read/write
    LV Status              available
    # open                 1
    LV Size                60.00 GB
    Current LE             1920
    Segments               2
    Allocation             inherit
    Read ahead sectors     auto
    - currently set to     256
    Block device           253:2

  • Resize Logical Volume used as DomU partition

    Scenario: In the Dom0 (Host) you have an LVM Logical Volume that you export to the DomU (Guest) and it appears as a hard drive partition which you want to make larger.

    Example- Dom0: /dev/VolGroup00/LogVol00 -> DomU: /dev/xvda1

     

    Resizing an LVM Logical Volume used as a DomU partition

    When you use an LVM Logical Volume as a DomU partition it will show up in the DomU as /dev/xvda1 as apposed to /dev/xvda. The line in the DomU config file will look something like this.

    disk = ['phy:vgsys/lvvirt,xvda1,w']

    Get the Logical Volume name and path

    So you gave your Xen virtual machine a 10GB Logical Volume and not it's not enough eh? This is easy to fix.

    We start by using the lvdisplay command to get the path to the Logical Volume

    [ root@vs /srv/xen ] lvdisplay
    --- Logical volume ---
    LV Name                /dev/vgsys/lvvirt
    VG Name                vgsys
    LV UUID                XMWzWW-oZih-A5uH-91Sa-7l1y-8cqf-18KcNB
    LV Write Access        read/write
    LV Status              available
    # open                 1
    LV Size                60.00 GB
    Current LE             1920
    Segments               2
    Allocation             inherit
    Read ahead sectors     auto
    - currently set to     256
    Block device           253:2

  • Tool to list XCP/Xenserver networks

    My newest XCP tool is to list networks in a quick concise manner. By default lsnetworks shows the network name, the bridge it's associated with, the VLAN tag (if there is one), the VMs that have a network interface on it and the number of that interface. 

    It can be found in the xenapi-admin-tools github.

     

     

     

    Because XCP/Xenserver relies so much on UUID numbers I've provided a -u option which lists every object by UUID number if it has one. This won't be quite as useful as an interactive tool but if you're copy and pasting UUID's into xe commands this will give you a quick summary of them in relation to networks. 

     

  • Updated Xen Howtos

    There's been a flurry of activity around The Man, The Myth, The Legend in the Xen Howtos section and for good reason - CentOS6 was released. It all started as a simple update to my installation tutorials but ultimately I spent half a week on it. There were some issues with how I was doing things because CentOS5 used the old Xen kernel and CentOS6 uses the new libvirt kernel. As of RHEL5/CentOS6 Xen Host (dom0) support is no longer in the kernel. However, Xen Guests (DomU) is and  is handled by libvirt. Last week the last bits of Xen Dom0 support were merged into Linux Kernel 3.0. This means that going forward all Linux distributions will have Xen Dom0 ability unless the distributors remove it.

    I've written and tested two xen tutorials this week.

    During the process of writing these tutorials I shrunk the size of the Disk Image. I did this because I like nice small VM disk images (and sparse too) so I can duplicate them and move them around easily. It's fairly easy to resize a disk image so I updated all four tutorials on how to resize Dom0 Disk Images and Logical Volumes as well as DomU Logical Volumes and partitions. I attempted to make it clearer too what the scenario was so people would know what the tutorial was trying to accomplish.

    As always have lots of fun and let me know if something doesn't work via the comments.

  • Virtual disk formats

    The problem with Virtualization systems is none of them want to standardize on one particular disk format. Actually they all do, they want their format to be the standard.

    • VMware has VMDK
    • QEMU has qcow and qcow2
    • UML has cow
    • Parallels has HDD
    • VirtualPC uses VHD
    • VirtualBox has VDI
    • Xen uses raw disk images

    To make matters more confusing VirtualBox has some support for VMDK, Commercial Xen supports VHD, the open source Xen supports qcow2 and Qemu can convert between many formats. So what I'm doing about this is putting up a series of Howtos in the Tech -> Virtualization areas on how to convert and use various disk formats in different Virtualization systems. To start with I just put together the following two Howtos.

  • Xen disk images vs LVM

     

    In setting up a Xen virtualized web server with about 15 GB of static files I questioned the wisdom of using a disk image as apposed to LVM. I read a bunch of forums about which is better and it seems the disk images are easier to manage because you can just copy to make backups etc.. LVM you just can't move it and pop it up whereever you want but you have more flexibility in resizeing and backing them up within the host OS. However what I didn't find on the forums is performance tests. People theororized about the speed difference but it seems nobodies sat down and done some tests. It's my goal that after summer vacation to put together a performance whitepaper comparing all the virtual machine solutions. For now I'll just put up xen disk images against LVM.

    So I created a 10 GB empty disk image using dd and I created a 10 GB LVM Logical volume and assigned both of them to the domU.

     

    name = "centtest"
    memory = "512"
    disk = [ 'tap:aio:/srv/xen/centos5.img,xvda,w', 'tap:aio:/srv/xen/centtest.img,xvdb,w', 'phy:/dev/vgsys/lvtest,xvdc,w' ]
    vif = [ 'bridge=xenbr0', ]
    bootloader="/usr/bin/pygrub"
    vcpus=1
    on_reboot = 'restart'
    on_crash = 'restart'
  • Xen Enterprise to be free

    As a strike against the industry leading VMWare, Citrix releases it's Xen Enterprise Virtualization platform to the public for free. Note this does not mean it's been released OpenSource as the Xen hypervisor is, it's just free to download and use on as many installations as you like. The difference is that it's free as in beer, not as in freedom. If Citrix wanted to change the license back to pay only after it hooks a million customers it can.

     

    Game Changing Move Goes Well Beyond Free Hypervisors to Accelerate the Adoption of World-Class Virtual Infrastructure for Both Enterprises and Cloud Providers

    BOSTON » 2/23/2009 » Citrix Systems, Inc. (Nasdaq: CTXS), the global leader in application delivery infrastructure, today unveiled a groundbreaking new version of Citrix® XenServer™ – the company’s enterprise-class, cloud-proven virtualization platform – that will be offered free of charge to any user for unlimited production deployment.  While basic hypervisors have been free for years, most have had limited practical use in real world environments.  With this new release, XenServer sets an entirely new standard for free virtualization with the addition of powerful new features like centralized multi-node management, multi-server resource sharing and full live motion.  Dramatically lowering the entry price of virtualization also helps address today’s challenging economic climate by making enterprise-class virtualization far more accessible to businesses of all sizes, regardless of budget.

     

    Xen Enterprise is running in 5000 datacenters worldwide. Downloads will be available in March. Here's the official announcement.

     

     

     

  • Xen Howtos

    Having moved to Xen Cloud Platform recently I don't anticipate there being more Howto's in this category in the future. I do however, keep up the CentOS installation tutorials because of popular demand.

     

  • Xenapi Admin Tools moving to github

    Up until about now I've been developing the Xenapi Admin Tools on my local cloud. I've been maintaining revisions on a local Subversion server which has been accessible by only the Xenapi Admin Project team. Now that we're slowly moving our projects public for inclusion in the Xen Cloud Platform's github I wanted to push Xenapi Admin Tools to github which is partly done as of today. 

    The URL for the repo is https://github.com/Xenapi-Admin-Project/xenapi-admin-tools. Please feel free to browse the code and the development docs which outline the Xenapi Admin Tools spec and it's built in functions. I also have a yum repo file and a SPEC file for when I start creating rpms for Xen Cloud Platform/Xenserver. For now I would not consider that anything but alpha. At some point you'll be able to just install the Xenapi-admin-repo rpm and then yum install xenapi-admin-tools to install all of the tools including their manpages, config files and more. Currently a lot of these things don't exist. Also there are two branches of code in the github repo - 3.0 and 4.0. Not all tools are available in 4.0 yet as I'm still rewriting them. The difference is massive speedups with 4.0. Stay tuned for more news.

  • Xenserver Howtos

    Xen Cloud Platform is the free/open community driven version of Citrix Xenserver.  I've moved all of my Xen Virtual Machines to Xen cloud Platform so any future tutorials will most likely be about XCP. I've found XCP to be a wonderful product but not necessarily an easy tool sometimes thus the tutorials you see below.

    Citrix Xenserver has been opensourced and thus there's no need for Xen Cloud Platform any longer. Most of the tutorials here work on both but all future tutorials will be targeting Xenserver. As time permits I'm updating tutorials for Xenserver 6.5 (Creedence) - Jan 15, 2014.

    How to get started: Go to xenserver.org and download the latest ISO disk image of Xenserver and install it on a machine. If you don't have a CD drive on your Xenserver host put the installer on a USB drive. It uses the whole machine as it's an appliance so beware. By the way I think this is the best design strategy. It's a good idea to let your Hypervisor/Cloud stack focus on what it's good at and not use it for playing World of Warcraft. ;-)

    Expect a great deal more Howtos in the future. Feel free to request them as well. If it's within scope of what I'm doing I may create one just for you.

     These tutorials can also be found on the Xenapi Admin Project website and the XCP wiki.

     

     

EasyTagCloud v2.8