Grant McWilliams

×

Error

[sigplus] Critical error: Image gallery folder galleries/frankencloud is expected to be a path relative to the image base folder specified in the back-end.

73 items tagged "Virtualization"

  • 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.

     

     

     

     

     

     

     

  • Access VHD VDIs from the Control Domain

     On occasion you may want to have access to a VM's Virtual Disk Image from the Control Domain (or another VM). An example of this would be access files in a VM disk that due to corruption will no longer boot. An XCP local Storage Repository is created from an LVM Volume Group. Each Virtual Disk Image represents one Logical Volume. However, mounting the Logical Volume directly isn't possible because there's  VHD (Virtual Hard Drive) container inside the Logical Volume. Inside the VHD is the real VM disk's partitions. The hierarchy goes something like this  Control Domain Volume Group -> Control Domain Logical Volume -> VHD Container -> VM disk -> VM disk physical Volume -> VM Disk Volume Group -> VM Disk Logical Volume -> VM Disk filesystem. You can see there's quite a few layers here but mounting the VM's disk filesystem IS possible. Here's how.

    Since the Control Domain is really a VM itself (privileged VM) we can create a Virtual Block Device using the VM's Virtual Disk Image. From there we use kpartx to map the partitions to Control Domain device nodes.

     

    1. Finding VDI UUID number

    [root@testcloud1 ~]# xe vbd-list
    uuid ( RO)             : b68a332b-4155-f1c4-b224-18fb465dc8e4
              vm-uuid ( RO): fec94868-0449-3616-39b9-08c3b27dab70
        vm-name-label ( RO): Fedora17
             vdi-uuid ( RO): 199619f0-e483-4618-bbd4-bdc9c524bde1
                empty ( RO): false
               device ( RO): 
    

     

    2. Finding the Control Domain UUID number 

    [root@testcloud1 ~]# xe vm-list is-control-domain=true
    uuid ( RO)           : 2dfc3f33-4afa-47dd-8af6-21877326f8e4
         name-label ( RW): Control domain on host: testcloud1
        power-state ( RO): running
    

     

    3. Creating a virtual block device for the VDI on our Control Domain. This returns the VBD UUID. 

    [root@testcloud1 ~]# xe vbd-create device=autodetect vm-uuid=2dfc3f33-4afa-47dd-8af6-21877326f8e4   vdi-uuid=199619f0-e483-4618-bbd4-bdc9c524bde1
    11740055-f8d4-3d84-1f90-fb1f4b646fd6

      

    4. Plugging in the Virtual Block Device gives us a /dev/sm/backend/<sr-uuid>/<vdi-uuid> device which fdisk will list. 

    [root@testcloud1 ~]# xe vbd-plug uuid=11740055-f8d4-3d84-1f90-fb1f4b646fd6 

     

    5. Showing the VBD attached to the control domain AND to the Fedora17 VM 

    [root@testcloud1 ~]# xe vbd-list 
    uuid ( RO)             : b68a332b-4155-f1c4-b224-18fb465dc8e4
              vm-uuid ( RO): fec94868-0449-3616-39b9-08c3b27dab70
        vm-name-label ( RO): Fedora17
             vdi-uuid ( RO): 199619f0-e483-4618-bbd4-bdc9c524bde1
                empty ( RO): false
               device ( RO): 
    
    
    uuid ( RO)             : 11740055-f8d4-3d84-1f90-fb1f4b646fd6
              vm-uuid ( RO): 2dfc3f33-4afa-47dd-8af6-21877326f8e4
        vm-name-label ( RO): Control domain on host: testcloud1
             vdi-uuid ( RO): 199619f0-e483-4618-bbd4-bdc9c524bde1
                empty ( RO): false
               device ( RO): sm/backend/ec2eb4df-040c-2a75-1c9f-69b953ac9e8d/199619f0-e483-4618-bbd4-bdc9c524bde1
    
    
    

    6. Showing the Device Node using ls and fdisk

    [root@testcloud1 ~]# ls -l /dev/sm/backend/ec2eb4df-040c-2a75-1c9f-69b953ac9e8d/199619f0-e483-4618-bbd4-bdc9c524bde1
    brw------- 1 root root 253, 0 Jan 12 00:52 /dev/sm/backend/ec2eb4df-040c-2a75-1c9f-69b953ac9e8d/199619f0-e483-4618-bbd4-bdc9c524bde1

     

    [root@testcloud1 ~]# fdisk -l $(ls /dev/sm/backend/ec2eb4df-040c-2a75-1c9f-69b953ac9e8d/199619f0-e483-4618-bbd4-bdc9c524bde1)
    
    Disk /dev/sm/backend/ec2eb4df-040c-2a75-1c9f-69b953ac9e8d/199619f0-e483-4618-bbd4-bdc9c524bde1: 8589 MB, 8589934592 bytes
    255 heads, 63 sectors/track, 1044 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    
                                                                                         Device Boot      Start         End      Blocks   Id  System
    /dev/sm/backend/ec2eb4df-040c-2a75-1c9f-69b953ac9e8d/199619f0-e483-4618-bbd4-bd  *           1         980     7863296   83  Linux
    Partition 1 does not end on cylinder boundary.
    /dev/sm/backend/ec2eb4df-040c-2a75-1c9f-69b953ac9e8d/199619f0-e483-4618-bbd4-bd            980        1045      524288   82  Linux swap / Solaris
    [root@testcloud1 ~]# kpartx -a $(ls /dev/sm/backend/ec2eb4df-040c-2a75-1c9f-69b953ac9e8d/199619f0-e483-4618-bbd4-bdc9c524bde1)
    [root@testcloud1 ~]# ls /dev/mapper/
    199619f0-e483-4618-bbd4-bdc9c524bde1p1
    199619f0-e483-4618-bbd4-bdc9c524bde1p2
    control
    VG_XenStorage--ec2eb4df--040c--2a75--1c9f--69b953ac9e8d-MGT
    VG_XenStorage--ec2eb4df--040c--2a75--1c9f--69b953ac9e8d-VHD--199619f0--e483--4618--bbd4--bdc9c524bde1
    VG_XenStorage--ec2eb4df--040c--2a75--1c9f--69b953ac9e8d-VHD--6c663b1b--d9c4--45bd--9071--3f6b4668d164
    

     

    7. Use kpartx to create /dev/mapper entries for each partition.

    [root@testcloud1 ~]# kpartx -a $(ls /dev/sm/backend/ec2eb4df-040c-2a75-1c9f-69b953ac9e8d/199619f0-e483-4618-bbd4-bdc9c524bde1)

     

    8. kpartx creates /dev/mapper nodes

    [root@testcloud1 ~]# ls /dev/mapper/
    199619f0-e483-4618-bbd4-bdc9c524bde1p1
    199619f0-e483-4618-bbd4-bdc9c524bde1p2
    control
    VG_XenStorage--ec2eb4df--040c--2a75--1c9f--69b953ac9e8d-MGT
    VG_XenStorage--ec2eb4df--040c--2a75--1c9f--69b953ac9e8d-VHD--199619f0--e483--4618--bbd4--bdc9c524bde1
    VG_XenStorage--ec2eb4df--040c--2a75--1c9f--69b953ac9e8d-VHD--6c663b1b--d9c4--45bd--9071--3f6b4668d164
    

     

    9. Mount the partitions

    [root@testcloud1 ~]# mount /dev/mapper/199619f0-e483-4618-bbd4-bdc9c524bde1p1 /media/Fedora17-rootfs/

     

    [root@testcloud1 ~]# ls /media/Fedora17-rootfs/
    bin  boot  dev  etc  home  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
    
    

     

    Notes:Be careful with mounting VDI's from VMs on the Control Domain. Best practice is to make sure that the VDI is not accessible from the Control Domain AND the VM at the same time. Mounting to two locations at once is a great way of corrupting your disk by having two different Operating Systems writing to the disk at the same time.

  • 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

  • Apply hotfixes to XCP 1.6

    Xenserver hotfixes are released as patches that need to be applied with patch-pool-apply. Although technically this could work with XCP as long as you got the correct Xenserver patch it's better to apply patches the "new" way using Yum and the default xcp repository.

    Any minor software updates to Xen Cloud Platform will be released into the XCP Yum repository at downloads.xen.org.  XCP 1.6 comes with a ready made Yum repository file at /etc/yum.repos.d/xcp.repo although by default the repository is disabled.

    To apply updates use the yum update command you have to enable the repo and tell rpm not  to gpg check the packages. Hopefully the latter behavior will change in the future.

    yum --enablerepo xcp --nogpgcheck update

    If you'd like to enable the repo and turn gpg checking off by default so future updates are easier then change the enabled=0 line to enabled=1. Also add a line to the /etc/yum.repos.d/xcp.repo file to turn gpgchecking off for this ONE repository.

     

    [xcp]
    name=XCP 1.6 Updates
    baseurl=http://downloads.xen.org/XCP/repo/xcp-1.6.10/
    enabled=1
    gpgcheck=0
    

    I don't know if I recommend enabling by default as I like to do my updates manually. I really have issues with turning gpg checking off but currently the packages are distributed without a gpg signature so if you have it turned on the update will fail. Our only choice is to turn it off.

  • Automated install of CentOS 6 VM (32 bit)

    Note: Updated for XCP 1.5b/1.6

    Install Type

    • Non-interactive
    • Network boot
    • Commandline
    • Paravirtualized

    Prerequisites

    • XCP/Xenserver
    • Access to Internet
    • Working DHCP server
    • Working DNS name resolution

    Introduction

    This tutorial was written in the spirit of my CentOS 6 virtual machine (32 bit) installation on Xen howtowhich was based on the CentOS 5 version of the same. In those tutorials I created a disk, downloaded a kernel, kickstart file plus a xen config file which installed CentOS using the kickstart file. This has proven very popular since you can't install a paravirtualized domain using an install disk. This has been a very nice installation howto because you don't have to download any install CD/DVDs and you could create VMs using nothing more than a commandline login. It's also very nice because it can be mirrored locally if you're doing a bunch of them just by rsyncing a CentOS mirror locally then downloading my files and editing them.

    I've recently migrated a lot of my XEN systems to Xen Cloud Platform and it's a very different animal indeed. However, I still needed a system of creating CentOS Virtual Machines in that same manner. I didn't want to download a CentOS install DVD or need a graphical login to install the OS thus this tutorial was born.

    It uses the very same CentOS 6 kickstart file from my site as the Xen tutorial. It also uses the very same CentOS 6 repositories on the Internet so in a lot aspects it IS the same tutorial crafted for XCP but will be a bit shorter.

     More after the jump.

  • Automated install of CentOS 6 VM (64 bit)

    Note: updated for XCP 1.5b/1.6 and Xenserver 6.x.

    Install Type

    • Non-interactive
    • Network boot
    • Commandline
    • Paravirtualized

    Prerequisites

    • XCP/Xenserver
    • Access to Internet
    • Working DHCP server
    • Working DNS name resolution

    Introduction

    This tutorial was written in the spirit of my CentOS 6 virtual machine (64 bit) installation on Xen. In those tutorials I created a disk, downloaded a kernel, kickstart file plus a xen config file which installed CentOS using the kickstart file. This has proven very popular since you can't install a paravirtualized domain using an install disk. This has been a very nice installation howto because you don't have to download any install CD/DVDs and you could create VMs using nothing more than a commandline login. It's also very nice because it can be mirrored locally if you're doing a bunch of them just by rsyncing a CentOS mirror locally then downloading my files and editing them.

     

  • Automated install of CentOS 7 VM (64 bit)

    Install Type

    • Non-interactive
    • Network boot
    • Commandline
    • Paravirtualized

    Prerequisites

    • XCP/Xenserver
    • Access to Internet
    • Working DHCP server
    • Working DNS name resolution

    Introduction

    This tutorial was written in the spirit of my CentOS 6 virtual machine (64 bit) installation on Xen howto. In that tutorial I created a disk, downloaded a kernel, kickstart file plus a xen config file which installed CentOS using the kickstart file. This has proven very popular since you can't install a paravirtualized domain using an install disk. This has been a very nice installation howto because you don't have to download any install CD/DVDs and you could create VMs using nothing more than a commandline login. It's also very nice because it can be mirrored locally if you're doing a bunch of them just by rsyncing a CentOS mirror locally then downloading my files and editing them.

    I now use Xenserver and it's a very different animal indeed. However, I still needed a system of creating CentOS Virtual Machines in that same manner. I didn't want to download a CentOS install DVD or need a graphical login to install the OS thus this tutorial was born.

    Warning! This tutorial is for CentOS version 7 on Xenserver 6.5. To use Xenserver 6.2 or later you will need to shoehorn grub-legacy into it.I've managed to get CentOS7 to run in Xenserver 6.2 but I had to do the following. 

    1. Install CentOS7 in Xenserver 6.5 
    2. Boot the VM and login
    3. Uninstall grub2
    4. Manually download grub-legacy and install
    5. Download grub.conf file to /boot/grub/grub.conf (edit if necessary)
    6. Run the grub command to install it
      1. # grub
      2. grub> device (hd0) /dev/xvda
      3. grub> root (hd0,0)
      4. grub> setup (hd0)
      5. grub> quit
    7. Place exclude=grub* in your /etc/yum.conf
    8. Shut down the VM and export it using vm-export
    9. Copy the VM to the Xenserver 6.2 host and vm-import

     

  • Automated install of Debian Wheezy VM (64 bit) using preseed

    Note: This is not totally automated yet. I need to fix several things.

    Install Type

    • Non-interactive
    • Network boot
    • Commandline
    • Paravirtualized

    Prerequisites

    • XCP/Xenserver
    • Access to Internet
    • Working DHCP server
    • Working DNS name resolution
     

    Introduction

    In this tutorial I create a disk, download a kernel, preseed file and install Debian Wheezy using the preseed file. This has proven very popular since you can't install a paravirtualized domain using an install disk. This has been a very nice installation howto because you don't have to download any install CD/DVDs and you could create VMs using nothing more than a commandline login. It's also very nice because it can be mirrored locally if you're doing a bunch of them just by rsyncing a Ubuntu mirror locally then downloading my files and editing them.

     

     Note: This tutorial is designed so you can copy and paste the text inside the boxes. I don't actually type any of this in and neither should you.

     

    1. Getting the network info

    This line gets the Network UUID for xenbr0. If you're using a different bridge you will want to insert it here. Get a list of XCP networks with xe network-list. This network is connected to the outside interface. This tutorial requires there to be a DHCP server on this network answering requests and providing network access to the Internet.

    NETUUID=$(xe network-list bridge=xenbr0 --minimal)

    2. Creating the VM and setting parameters

    Here we create a new template from the Debian Squeeze template. Then we create the VM from the new Debian template, create a network interface and add it to our network from step one. Additional settings are for configuring the install repository and specifying thepreseed file from my site. The last setting turns off VNC so we can watch the install via a text console (very important in my environment).  Even if you can't see all the text below just highlight and paste. The text is there even if it's not visible.

     

    TMPLUUID=$(xe template-list | grep -B1 'name-label.*Debian.*Squeeze.*64-bit' | awk -F: '/uuid/{print $2}'| tr -d " ")
    VMUUID=$(xe vm-install new-name-label="Debian Wheezy" template=${TMPLUUID}) 
    xe vif-create vm-uuid=${VMUUID} network-uuid=${NETUUID} mac=random device=0
    xe vm-param-set uuid=${VMUUID} other-config-install-repository=http://ftp.us.debian.org/debian/
    xe vm-param-set uuid=${VMUUID} other-config:debian-release=wheezy
    xe vm-param-set uuid=${VMUUID} other-config:install-methods=http,cdrom,ftp,nfs
    xe vm-param-set uuid=${VMUUID} PV-args="netcfg/get_hostname=Wheezy debian-installer/locale=en_US console-keymaps-at/keymap=us console-setup/layoutcode=us console-setup/ask_detect=false interface=eth0 netcfg/disable_dhcp=false preseed/url=http://grantmcwilliams.com/files/preseed-debian-wheezy.cfg console=hvc0"
    xe vm-param-set uuid=${VMUUID} other-config:disable_pv_vnc=1
    
    

    3. Starting the VM and watching the install

    The VM installs without any interaction from the user at this point. It is however, nice to watch it using xenconsole. Once it's done installing it will shutdown.

    If you're using XCP 1.0/1.1

    xe vm-start uuid=$VMUUID
    DOMID=$(xe vm-list uuid=${VMUUID} params=dom-id --minimal)
    /usr/lib/xen/bin/xenconsole ${DOMID}

    If you're using XCP 1.5b/1.6

    xe vm-start uuid=$VMUUID ; xe console uuid=$VMUUID

    4. Starting the VM and configuring settings

    We need to boot the VM up again and using xenconsole log in to reset the finish configuration.

    If you're using XCP 1.0/1.1

    xe vm-start uuid=$VMUUID
    DOMID=$(xe vm-list uuid=${VMUUID} params=dom-id --minimal)
    /usr/lib/xen/bin/xenconsole ${DOMID}

    If you're using XCP 1.5b/1.6

    xe vm-start uuid=$VMUUID
    xe console uuid=$VMUUID

    Now that your Debian Wheezy VM is running you can login. The password was automatically set by the preseed file.

    • Username:debian
    • Password: password

    Reset the ubuntu users password.  If you want to keep the IP assignment dynamic note the ip address.

    5. Shutting down the VM and re-enabling VNC

    If you're going to use XVP or some other method of connecting to the VMs direct VNC connection you'll need to enable it.

    xe vm-shutdown uuid=$VMUUID
    xe vm-param-remove uuid=${VMUUID} other-config:disable_pv_vnc
    xe vm-start uuid=$VMUUID

    7. Export our VM for safe keeping

    Before you start modifying the base Debian Wheezy image you should back it up.

    xe vm-export uuid=$VMUUID filename=DebianWheezy-base.xva

    Be aware that you may not have enough space on the Control Domain's disk to export it. A good solution (and shorter than explaining how to add disks to the control domain) is to mount an nfs volume and export it there.

    mount nfsserver:/share /media/share
    xe vm-export uuid=$VMUUID filename=/media/share/DebianWheezy-base.xva

    This would mount the NFS share on nfsserver to /media/share. The exported disk would be saved on the NFS share.

     

  • Automated install of Fedora 20 VM (32 bit)

    Note: updated for XCP 1.5b/1.6 and Xenserver 6.x

    Install Type

    • Non-interactive
    • Network boot
    • Commandline
    • Paravirtualized

    Prerequisites

    • XCP/Xenserver
    • Access to Internet
    • Working DHCP server
    • Working DNS name resolution

    Introduction

    This tutorial was originally written for CentOS and has been adapted for Fedora 20. 


     Note: This tutorial is designed so you can copy and paste the text inside the boxes. I don't actually type any of this in and neither should you.

     

    1. Getting the network info

    This line gets the Network UUID for xenbr0. If you're using a different bridge you will want to insert it here. Get a list of XCP networks with xe network-list. This network is connected to the outside interface. This tutorial requires there to be a DHCP server on this network answering requests and providing network access to the Internet.

    NETUUID=$(xe network-list bridge=xenbr0 --minimal)

    2. Creating the VM and setting parameters

    Here we create the VM from the RHEL6 template, create a network interface and add it to our network from step one. Additional settings are for configuring the install repository and specifying the kickstart file from my site. The last setting turns off VNC so we can watch the install via a text console (very important in my environment).  Even if you can't see all the text below just highlight and paste. The text is there even if it's not visible.

    TMPLUUID=$(xe template-list | grep -B1 'name-label.*Red Hat.* 6.*32-bit' | awk -F: '/uuid/{print $2}'| tr -d " ")
    VMUUID=$(xe vm-install new-name-label="Fedora20" template=${TMPLUUID})
    xe vif-create vm-uuid=$VMUUID network-uuid=$NETUUID mac=random device=0
    xe vm-param-set uuid=$VMUUID other-config:install-repository=http://mirror.symnds.com/distributions/fedora/releases/20/Fedora/i386/os/
    xe vm-param-set uuid=$VMUUID PV-args="ks=http://grantmcwilliams.com/files/kickstart-minimal-fedora20-i386.cfg ksdevice=eth0"
    xe vm-param-set uuid=${VMUUID} other-config:disable_pv_vnc=1

    3. Starting the VM and watching the install

    The VM installs without any interaction from the user at this point. It is however, nice to watch it using xenconsole. Once it's done installing it will shutdown.

    If you're using XCP 1.0/1.1

    xe vm-start uuid=$VMUUID
    DOMID=$(xe vm-list uuid=${VMUUID} params=dom-id --minimal)
    /usr/lib/xen/bin/xenconsole ${DOMID}

     

    If you're using XCP 1.5b/1.6 or Xenserver 6.x

    xe vm-start uuid=$VMUUID
    xe console uuid=$VMUUID

     

    4. Starting the VM and configuring settings

    We need to boot the VM up again and using xenconsole log in as root to configure the network and reset the root users password.

    If you're using XCP 1.0/1.1

    xe vm-start uuid=$VMUUID
    DOMID=$(xe vm-list uuid=${VMUUID} params=dom-id --minimal)
    /usr/lib/xen/bin/xenconsole ${DOMID}

    If you're using XCP 1.5b/1.6 or Xenserver 6.x

    xe vm-start uuid=$VMUUID
    xe console uuid=$VMUUID

    Now that yourFedora VM is running you can login. The password was automatically set by the kickstart file.

    • Username: root
    • Password: password

    Reset the root users password and change the network settings to static IP using system-config-network. If you want to keep the IP assignment dynamic note the ip address.

    5. Shutting down the VM and re-enabling VNC

    If you're going to use XVP or some other method of connecting to the VMs direct VNC connection you'll need to enable it.

    xe vm-shutdown uuid=$VMUUID
    xe vm-param-remove uuid=${VMUUID} param-name=other-config param-key=disable_pv_vnc
    xe vm-start uuid=$VMUUID

     

    6. Add RPMfusion repository

    I almost always install RPMfusion. It is very stable and doesn't replace standard packages.

    yum localinstall --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm

     

    7. Export our VM for safe keeping

    Before you start modifying the base Fedora image you should back it up.

    xe vm-export uuid=$VMUUID filename=Fedora20-base.xva

      

    Be aware that you may not have enough space on the Control Domain's disk to export it. A good solution (and shorter than explaining how to add disks to the control domain) is to mount an nfs volume and export it there.

    mount nfsserver:/share /media/share
    xe vm-export uuid=$VMUUID filename=/media/share/Fedora20-base.xva

     

    This would mount the NFS share on nfsserver to /media/share. The exported disk would be saved on the NFS share.

     

    Notes: Since it's more likely that you will want to do a Fedora desktop install than for the other Operating Systems I've written tutorials for I've put together a list of packages for your custom kickstart file (extracted from the Fedora-20-comps.xml file.)

     

    • admin-tools
    • authoring-and-publishing
    • base
    • base-x
    • books
    • cloud-infrastructure
    • clustering
    • design-suite
    • development-libs
    • development-tools
    • dial-up
    • directory-server
    • dns-server
    • dogtag
    • eclipse
    • editors
    • education
    • electronic-lab
    • engineering-and-scientific
    • fedora-packager
    • font-design
    • fonts
    • ftp-server
    • games
    • gnome-desktop
    • gnome-software-development
    • graphical-internet
    • graphics
    • haskell
    • input-methods
    • java
    • java-development
    • kde-desktop
    • kde-software-development
    • legacy-fonts
    • legacy-network-server
    • legacy-software-development
    • libreoffice-development
    • lxde-desktop
    • mail-server
    • medical
    • meego-netbook
    • milkymist
    • mingw32
    • mysql
    • network-server
    • news-server
    • ocaml
    • office
    • perl
    • printing
    • robotics-suite
    • ruby
    • server-cfg
    • smb-server
    • sound-and-video
    • sql-server
    • sugar-desktop
    • system-tools
    • text-internet
    • virtualization
    • virtualization-hypervisor
    • web-development
    • web-server
    • window-managers
    • xfce-desktop
    • xfce-software-development
    • x-software-development

     

    To insert any of these package groups into your own custom kickstart file precede the group name with an @ and insert it in the Package section.

    # Packages
    %packages --excludedocs
    @ base
    man
    man-pages
    sendmail
    yum-presto
    %end

    Then to use your kickstart file save it to a webserver somewhere. Follow the installation instructions but refer to your kickstart file (ks=<URL> in Step 2. 

    xe vm-param-set uuid=$VMUUID PV-args="ks=http://grantmcwilliams.com/files/kickstart-minimal-fedora20-i386.cfg ksdevice=eth0"

     

  • Automated install of Fedora 20 VM (32 bit)

    Note: updated for XCP 1.5b/1.6 and Xenserver 6.x

    Install Type

    • Non-interactive
    • Network boot
    • Commandline
    • Paravirtualized

    Prerequisites

    • XCP/Xenserver
    • Access to Internet
    • Working DHCP server
    • Working DNS name resolution

    Introduction

    This tutorial was originally written for CentOS and has been adapted for Fedora 20. 

  • Automated install of Fedora 20 VM (64 bit)

    Note: updated for XCP 1.5b/1.6 and Xenserver 6.x

    Install Type

    • Non-interactive
    • Network boot
    • Commandline
    • Paravirtualized

    Prerequisites

    • XCP/Xenserver
    • Access to Internet
    • Working DHCP server
    • Working DNS name resolution

    Introduction

    This tutorial was originally written for CentOS and has been adapted for Fedora 20 x86_64. 

  • Automated install of Kali Linux VM (64 bit) using preseed

    Note: This has not really been tested yet. I wanted to get it up here so people can start using it and I can work on it.

    Install Type

    • Non-interactive
    • Network boot
    • Commandline
    • Paravirtualized

    Prerequisites

    • XCP/Xenserver
    • Access to Internet
    • Working DHCP server
    • Working DNS name resolution
     

    Introduction

    In this tutorial I create a disk, download a kernel, preseed file and install Kali LInux using the preseed file. This has proven very popular since you can't install a paravirtualized domain using an install disk. This has been a very nice installation howto because you don't have to download any install CD/DVDs and you could create VMs using nothing more than a commandline login. It's also very nice because it can be mirrored locally if you're doing a bunch of them just by rsyncing a Ubuntu mirror locally then downloading my files and editing them.

     

     Note: This tutorial is designed so you can copy and paste the text inside the boxes. I don't actually type any of this in and neither should you.

     

    1. Getting the network info

    This line gets the Network UUID for xenbr0. If you're using a different bridge you will want to insert it here. Get a list of XCP networks with xe network-list. This network is connected to the outside interface. This tutorial requires there to be a DHCP server on this network answering requests and providing network access to the Internet.

    NETUUID=$(xe network-list bridge=xenbr0 --minimal)
    

     

    2. Creating the VM and setting parameters

    Here we create a new template from the Debian Squeeze template. Then we create the VM from the new Debian template, create a network interface and add it to our network from step one. Additional settings are for configuring the install repository and specifying thepreseed file from my site. The last setting turns off VNC so we can watch the install via a text console (very important in my environment).  Even if you can't see all the text below just highlight and paste. The text is there even if it's not visible.

     

    TMPLUUID=$(xe template-list | grep -B1 'name-label.*Debian.*Squeeze.*64-bit' | awk -F: '/uuid/{print $2}'| tr -d " ")
    VMUUID=$(xe vm-install new-name-label="Kali Linux" template=${TMPLUUID}) 
    xe vif-create vm-uuid=${VMUUID} network-uuid=${NETUUID} mac=random device=0
    xe vm-param-set uuid=${VMUUID} other-config-install-repository=http://http.kali.org
    xe vm-param-set uuid=${VMUUID} other-config:debian-release=kali
    xe vm-param-set uuid=${VMUUID} other-config:install-methods=http,cdrom,ftp,nfs
    xe vm-param-set uuid=${VMUUID} PV-args="netcfg/get_hostname=Kali debian-installer/locale=en_US console-keymaps-at/keymap=us console-setup/layoutcode=us console-setup/ask_detect=false interface=eth0 netcfg/disable_dhcp=false preseed/url=http://grantmcwilliams.com/files/preseed-kali-linux.cfg console=hvc0"
    xe vm-param-set uuid=${VMUUID} other-config:disable_pv_vnc=1

     

    3. Starting the VM and watching the install

    The VM installs without any interaction from the user at this point. It is however, nice to watch it using xenconsole. Once it's done installing it will shutdown.

    If you're using XCP 1.0/1.1

    xe vm-start uuid=$VMUUID
    DOMID=$(xe vm-list uuid=${VMUUID} params=dom-id --minimal)
    /usr/lib/xen/bin/xenconsole ${DOMID

    If you're using XCP 1.5b/1.6

    xe vm-start uuid=$VMUUID ; xe console uuid=$VMUUID

    4. Starting the VM and configuring settings

    We need to boot the VM up again and using xenconsole log in to reset the finish configuration.

    If you're using XCP 1.0/1.1

    xe vm-start uuid=$VMUUID
    DOMID=$(xe vm-list uuid=${VMUUID} params=dom-id --minimal)
    /usr/lib/xen/bin/xenconsole ${DOMID}

     

    If you're using XCP 1.5b/1.6

    xe vm-start uuid=$VMUUID
    xe console uuid=$VMUUID

     

    Now that your Kali Linux VM is running you can login. The password was automatically set by the preseed file.

    • Username:root
    • Password: password

    Reset the root users password.  If you want to keep the IP assignment dynamic note the ip address.

    5. Shutting down the VM and re-enabling VNC

    If you're going to use XVP or some other method of connecting to the VMs direct VNC connection you'll need to enable it.

    xe vm-shutdown uuid=$VMUUID
    xe vm-param-remove uuid=${VMUUID} other-config:disable_pv_vnc
    xe vm-start uuid=$VMUUID

     

    7. Export our VM for safe keeping

    Before you start modifying the base Kali Linux image you should back it up.

    xe vm-export uuid=$VMUUID filename=Kali-Linux-base.xva

     

     

    Be aware that you may not have enough space on the Control Domain's disk to export it. A good solution (and shorter than explaining how to add disks to the control domain) is to mount an nfs volume and export it there.

    mount nfsserver:/share /media/share
    xe vm-export uuid=$VMUUID filename=/media/share/Kali-Linux-base.xva

     

    This would mount the NFS share on nfsserver to /media/share. The exported disk would be saved on the NFS share.

     

  • Automated install of Ubuntu 12.04 VM (32 bit) using preseed

    Note: Updated to work with XCP 1.5b/1.6

    Install Type

    • Non-interactive
    • Network boot
    • Commandline
    • Paravirtualized

    Prerequisites

    • XCP/Xenserver
    • Access to Internet
    • Working DHCP server
    • Working DNS name resolution
     

    Introduction

    In this tutorial I create a disk, download a kernel, preseed file and install Ubuntu using the preseed file. This has proven very popular since you can't install a paravirtualized domain using an install disk. This has been a very nice installation howto because you don't have to download any install CD/DVDs and you could create VMs using nothing more than a commandline login. It's also very nice because it can be mirrored locally if you're doing a bunch of them just by rsyncing a Ubuntu mirror locally then downloading my files and editing them.

     

  • Automated install of Ubuntu 12.04 VM (64 bit) using kickstart

    Note: This is not quite functional. Ubuntu is asking a few questions during the install and then ultimately failing. I would recommend using my other Ubuntu 12.04 tutorial using a preseed file to auto install.

    Note: Updated to work with XCP 1.5b/1.6

    Thanks goes out to Alastair Brunton for troubleshooting this tutorial for me.

    Install Type

    • Non-interactive
    • Network boot
    • Commandline
    • Paravirtualized

    Prerequisites

    • XCP/Xenserver
    • Access to Internet
    • Working DHCP server
    • Working DNS name resolution
     

    Introduction

    This tutorial was written in the spirit of my CentOS 6 VM (64 bit) automated installation on XCP howto. In this tutorial I create a disk, download a kernel, kickstart file and install Ubuntu using the kickstart file. This has proven very popular since you can't install a paravirtualized domain using an install disk. This has been a very nice installation howto because you don't have to download any install CD/DVDs and you could create VMs using nothing more than a commandline login. It's also very nice because it can be mirrored locally if you're doing a bunch of them just by rsyncing a Ubuntu mirror locally then downloading my files and editing them.

    This tutorial isn't "debian pure" since I chose to use a kickstart file instead of a preseed file. I've created preseed files for doing automated installations of Ubuntu before but in this case I wanted this tutorial to be as close to the CentOS one as possible making it easier for me to maintain thus the kickstart file.

     

  • Automated install of Ubuntu 12.04 VM (64 bit) using preseed

    Note: Updated to work with XCP 1.5b/1.6

    Install Type

    • Non-interactive
    • Network boot
    • Commandline
    • Paravirtualized

    Prerequisites

    • XCP/Xenserver
    • Access to Internet
    • Working DHCP server
    • Working DNS name resolution
     

    Introduction

    In this tutorial I create a disk, download a kernel, preseed file and install Ubuntu using the preseed file. This has proven very popular since you can't install a paravirtualized domain using an install disk. This has been a very nice installation howto because you don't have to download any install CD/DVDs and you could create VMs using nothing more than a commandline login. It's also very nice because it can be mirrored locally if you're doing a bunch of them just by rsyncing an Ubuntu mirror locally then downloading my files and editing them.

     

  • Behold Frankencloud!

    [sigplus] Critical error: Image gallery folder galleries/frankencloud is expected to be a path relative to the image base folder specified in the back-end.

    I've been wanting to revive some equipment from the garage. I have some old dual Xeon machines that I picked up from a contract a while back. I also bought some "Designed for Google" dual CPU Xeon boards that I haven't used for anything. I've been using one of these boards in a server that's been running non-stop for probably 6 years and it's always been rock solid. Now that I'm documenting Xen Cloud Platform as part of the Xenapi Admin Project I wanted to put together a multi-host cloud using Xen Cloud Platform and it's best if your hosts match thus the renewed interest in getting this machine up and going.

    However, there's been a few problems. 

    1. The CPUs from the Google boards don't work in the ASUS boards due to different FSB
    2. I only had three CPUs for four sockets
    3. I was missing a heat sink too
    4. They use DDR2 ECC Registered ram which isn't common
    5. Intel should have their teeth kicked in for designing three (count them) different heat sink/fan designs for one socket.
    6. I needed backplates for two CPUs, the ones that arrived had no spring clips
    7. My replacement heatsink came with one spring clip
    8. Only one retailer had spring clips

    So I started by ordering a new copper heatsink because at the time I thought I could use the CPUs out of the Google boards.  The heatsink arrived with one spring clip, I needed two. After I realized that I couldn't use the CPUs from the Google boards I then ordered a new CPU.  Armed with a new CPU and heatsink I installed them only to find out that I needed a spring clip to keep the heat sink ON the CPU. Only one retailer even carried it so I ordered one.  Now if only I had a power supply strong enough to run the board. Back to the garage again. 

    In the garage I found a brand new computer case which surprisingly also had a brand new Pentium D motherboard in it. More booty from contracts. I wasn't concerned with the Pentium D but it had a Sparkle Power 600 watt power supply... Score!! 

    As of today I now have a dual Xeon server in a 4u case to match it's duplicate. I need to score some ddr2 ecc registered ram as it only has 2 GB in it. That crap is expensive so I went to Ebay and I have bids on a couple batches of 8GB. We'll see if I get them.

    The board was too big for the case too. I had to get out the hacksaw and cut away at the drive cage so it would fit. and drill new holes in the side of the case to mount a fan for more direct airflow.

     

    This board is a little interesting.  It has...

    1. Two Ultra-SCSI 320 channels
    2. A zero channel raid slot
    3. 64 bit, 133 mhz PCI-X slots
    4. 8x PCI Express slot
    5. 133 MB/sec IDE
    6. SATA2
    7. 8 Dimm slots
    8. 2 CPU sockets

    The Xeons don't have VT in them so I'll only be able to paravirtualize but that's all I ever do anyway. However Xeon 7030s have VT and will fit the board if anyone has any they want to get rid of cheap.

     

    {gallery labels=filename}galleries/frankencloud{/gallery}  

     

     

  • 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

  • Cleaning up XCP's xe command with BASH

    I've mentioned before that XCP/Xenserver's xe command is great for scripting but not always that great for interactive use. Because XCP relies so much on using UUID's for identification it's not very human friendly. Also the xe help is quite bad leading to our team that's working on writing documentation for xe. Even so xe makes a great scripting tool. 

    To show the difference between xe's output and what I think it could be let me introduce my lstemplate.sh script available in the XCP Downloads Section of this website. The xe command has a tendency to show output on multiple lines which isn't very parsable and is sort of hard to read. I understand that it's easier to program though. I however, like as much info on one line as possible allowing me to send the output into awk/cut if I wish and also keeps formatting clean. 

    Below is the output from xe template-list 

      ....

    You can see the output doesn't wrap well and isn't that easy to read. My biggest irritation is trying to find the template for the OS I want to use. There are a lot of templates and I usually end up scrolling for quite some time to get the right one. My other choice is to pipe the output of xe template-list into grep -B1 to search for the name and print the line before the name-label which will show the UUID number. For instance xe template-list | grep -B1 'Red Hat'. As easy as that is I find myself scanning the output of xe template-list in order to know what to grep for which defeats the purpose of grepping. 

    To solve this I wrote a small script called lstemplate.sh (list template). Below is the output. 

     

    You can also pass a -v (verbose) flag to get the descriptions too. 

     

     

  • Convert a Qemu image to Vbox vdi

     

    To convert a QEMU qcow format disk to VirtualBox vdi format you need to have Qemu installed. Qemu has tools to help convert disk formats.

    grant@workstation:~$qemu-img convert hda-qcow.img -O raw hda.img
    grant@workstation:~$ VBoxManage convertdd hda.img hda.vdi
    VirtualBox Command Line Management Interface Version 1.6.0
    (C) 2005-2008 Sun Microsystems, Inc.
    All rights reserved.

    Converting VDI: from DD image file="hda.img" to file="hda.vdi"...
    Creating fixed image with size 1024966656 bytes (978MB)...


    This will convert a QEMU qcow format disk image to VirtualBox vdi format.

     

     

  • Convert raw disk images to vdi format

    If you're moving from a real server installation to a VirtualBox virtualized configuration you may want to take your real physical disk and just turn it into a virtual disk. There are advantages to creating a new disk and rsyncing your OS into it but this tutorial will show you how to make an exact copy of it. Note the exact copy will be the same size as the real physical disk so make sure you have enough drive space. This is most useful for Operating System images with shared storage for data. I wouldn't advise anyone to make a 1TB copy of their new drive and turn it into a VDI file!

    To get the image from the disk use the dd command.

    1. dd if=/dev/hda of=./hda.img
    2. VBoxManage convertdd hda.img hda.vdi
    grant@workstation:~$ dd if=/dev/hda of=./hda.img
    grant@workstation:~$ VBoxManage convertdd hda.img hda.vdi
    VirtualBox Command Line Management Interface Version 1.6.0
    (C) 2005-2008 Sun Microsystems, Inc.
    All rights reserved.

    Converting VDI: from DD image file="hda.img" to file="hda.vdi"...
    Creating fixed image with size 1024966656 bytes (978MB)...

    This will make an exact copy of /dev/hda to the raw image file hda.img. Then VBoxManage will convert the raw disk hda.img to hda.vdi for use with VirtualBox.

  • Convert raw disk images to vdi format

    If you're moving from a real server installation to a VirtualBox virtualized configuration you may want to take your real physical disk and just turn it into a virtual disk. There are advantages to creating a new disk and rsyncing your OS into it but this tutorial will show you how to make an exact copy of it. Note the exact copy will be the same size as the real physical disk so make sure you have enough drive space. This is most useful for Operating System images with shared storage for data. I wouldn't advise anyone to make a 1TB copy of their new drive and turn it into a VDI file!

    To get the image from the disk use the dd command.

    1. dd if=/dev/hda of=./hda.img
    2. VBoxManage convertdd hda.img hda.vdi
    grant@workstation:~$ dd if=/dev/hda of=./hda.img
    grant@workstation:~$ VBoxManage convertdd hda.img hda.vdi
    VirtualBox Command Line Management Interface Version 1.6.0
    (C) 2005-2008 Sun Microsystems, Inc.
    All rights reserved.

    Converting VDI: from DD image file="hda.img" to file="hda.vdi"...
    Creating fixed image with size 1024966656 bytes (978MB)...

    This will make an exact copy of /dev/hda to the raw image file hda.img. Then VBoxManage will convert the raw disk hda.img to hda.vdi for use with VirtualBox.

  • 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.

     

  • Copy of Automated install of CentOS 7 VM (64 bit)

    Install Type

    • Non-interactive
    • Network boot
    • Commandline
    • Paravirtualized

    Prerequisites

    • XCP/Xenserver
    • Access to Internet
    • Working DHCP server
    • Working DNS name resolution

    Introduction

    This tutorial was written in the spirit of my CentOS 6 virtual machine (64 bit) installation on Xen howto. In that tutorial I created a disk, downloaded a kernel, kickstart file plus a xen config file which installed CentOS using the kickstart file. This has proven very popular since you can't install a paravirtualized domain using an install disk. This has been a very nice installation howto because you don't have to download any install CD/DVDs and you could create VMs using nothing more than a commandline login. It's also very nice because it can be mirrored locally if you're doing a bunch of them just by rsyncing a CentOS mirror locally then downloading my files and editing them.

    I now use Xenserver and it's a very different animal indeed. However, I still needed a system of creating CentOS Virtual Machines in that same manner. I didn't want to download a CentOS install DVD or need a graphical login to install the OS thus this tutorial was born.

    This tutorial is for CentOS version 7. 

     

  • 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 iSCSI target on a Control Domain

     

    Prerequisites

     

    • XCP/Xenserver
    • Access to Internet

     

    Update: June 2nd, 2014 - I changed most of the tgtadm long format options to short format due to my not being able to remember the long format. For some reason --lld didn't seem like a valid option. I did however keep --lun and --backing-store.

    Creating an iSCSI target on Xen Cloud Platform 1.1

    Premise: I have two pools – The first has one host in it that acts as a router, firewall and Host for a couple of special VMs for (DNS, DHCP, NFS, Web) the hosts in a second pool. I've added iSCSI SAN to it's lists of jobs using a software iSCSI target in the 8 steps below.

     

    1. Install tgt from CentOS repos

    yum --enablerepo=base install scsi-target-utils

    2. Start the tgt service

    service tgtd start

    chkconfig tgtd on

    3. Preparing for LVM

     

    I'm using a separate hard drive - /dev/sdb and creating one partition which will be used as my LVM Physical Volume. We'll then add it to the Volume Group and carve it up into Logical Volumes. This way I can just add another hard drive to the Volume Group when we want more capacity and the rest of the tutorial stays the same. The bold letters are what I input, I accepted the defaults everywhere else.

  • 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.

  • Create custom templates

    Prerequisites

    • XCP/Xenserver

     

    Creating a template

    The following is how to create new custom templates based on existing templates in Xen Cloud Platform. 

    1. Get the template UUID that we want to use as our base. As usual just copy and paste the line in yellow into a root terminal on your XCP host.

    xe template-list | grep -B1 name-label | awk -F: '{print $2}'

    The output should look like this..

     

     688c625b-93b8-8e66-62e5-4542eca1e597

     Red Hat Enterprise Linux 6 (32-bit)

     

     c4e28252-030f-524a-c5d8-7da85df3ccf5

    Windows Server 2003 (64-bit)

    ......

     

    Scroll through the list and find the template you want to clone then copy and past it's UUID number ie.  688c625b-93b8-8e66-62e5-4542eca1e597. Choose a new name for your custom template and enter the following line with the UUID of the template you want to clone and the name you want it to have.

     

    xe vm-clone uuid=<UUID> new-name-label="<NAME>"
    xe template-param-set uuid=<UUID> other-config:install-methods=http,ftp,nfs other-config:default_template=true

    Now you should have a new template of your own that you can customize. More after the jump.

  • Fedora automated install on Xenserver updated.

    I have a tendency to keep using the same tutorials of mine and only when I need them updated do I go through the process of writing, testing and publishing the changes. However, when people attempt to use my Xenserver tutorials to install newer versions of Linux I tend to go update them but if nobody asks then they get ignored. You can tell which tutorials I use by which ones are up-to-date. For instance the Ubuntu Automated Install is still stuck at Ubuntu 12.04. That probably needs to be rectified but since I rarely use Ubuntu it's on the back burner (Kali/Wheezy will get update first probably). 

    Today's announcement concerns Fedora 20 on Xenserver. I started using Fedora (again) when the wonderful version 17 came out. Then 18 was released with new bugs followed by 19 which had the same bugs and a ridiculous installer. Fedora 20 still has the same odd installer bits with the same usability issues (OK button is either on the top left or bottom right depending on what you're doing) but Fedora 17 just isn't being supported anymore so I've updated to Korora 20 which is based on Fedora 20. Due to popular demand this also means that my Fedora 17 on Xenserver tutorial just got updated as well.

    As usual I only use the x86_64 tutorials so I blindly updated the i386 version as well but have not tested it.

    Enjoy!

    Fedora 20 x86_64 Automated Install

    Fedora 20 i386 Automated Install

     

  • Fix the XCP expired license issue

    If you're running virtually any version of Xen Cloud Platform you may have run into this error message.

    Your license has expired.  Please contact your support representative.

    It's not really possible to have an expired license on Xen Cloud Platform (XCP) since it's FREE. It's just a regressive bug that has been very stubborn. However, until they fix it for real in XCP 1.5 you'll need follow the steps below.  

    Open a root terminal on the XCP host and copy and paste the commands below.

     

    service xapi stop;sleep 5
    NEXTMONTH=`date --date="next Month" '+%Y%m%d'`
    sed -i "s/\(expiry.\{3\}\)[0-9]\{8\}/\1$NEXTMONTH/g" /var/xapi/state.db
    service xapi start
    echo done

     

    The last line is only to get all the important lines to run automatically. If you don't hit enter it doesn't hurt anything.  You could also copy and paste these lines into a script and have it run as a cronjob. Because XCP doesn't like you bumping it's "evaluation license" out more than 30 days you might want to run the cronjob once a week to make sure your license doesn't lapse while you're waiting for the cronjob to run

  • 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.

     

     

  • How to manage VM images on XCP

    Once you've created a VM from one of my other tutorials (CentOS 64bit/CentOS 32 bit) you may want to make copies/clones and/or backup the images. There are several ways that you can make a backup copy of a VM all with subtle differences so we'll cover them below. 

     

    Copying a Virtual Machine

    The following is how to make a full copy of a VM on Xen Cloud Platform. When you do a full copy it does just that, it creates a new VM and makes a full copy of the disk.

    Syntax from the XenServer Administrators Guide

    vm-copy new-name-label=<name_for_copy> [new-name-description=<description_for_copy>] 
    [sr-uuid=<uuid_of_sr>] [<vm-selector>=<vm_selector_value>...]

    This may need a bit of explaining. You need to know a couple of items before you can make a copy of a VM.

    1. The Name or UUID of the old VM
    2. The Name of the new VM
    Optionally
    1. The Description of the new VM
    2. The Storage Repository to hold the new VM

     

    The simplest method of copying a VM would be to just accept the defaults.

     

    [root@cloud1 ~]# xe vm-list
    uuid ( RO)           : adde907a-3b85-80e5-e7c9-47718dd1d55b
         name-label ( RW): baseimage
        power-state ( RO): halted
    [root@cloud1 ~]# xe vm-copy name-label=baseimage new-name-label=baseimage-copy
    
     

    This process may take a few minutes depending on the size of the disk image. It's worth noting that it's more reliable to use a VM's UUID to identify it than it's name and the reason for this is that XCP allows you to have more than one VM in a pool with the same name. The line above would look a bit different if we'd used the VM's UUID.

    [root@cloud1 ~]# xe vm-list
    uuid ( RO)           : adde907a-3b85-80e5 -e7c9-47718dd1d55b
         name-label ( RW): baseimage
        power-state ( RO): halted
     [root@cloud1 ~]# xe vm-copy vm-uuid=adde907a-3b85-80e5-e7c9-47718dd1d55bnew-name-description="Copy of baseimage" new-name-label=baseimage-copy new-name-label=baseimage-copy

     

    Using the UUID isn't quite as people friendly as name-label because UUID's are a bit scary looking. I usually use name-label to identify VM's unless something funky is going on then I'll switch over to UUIDs. For instance I rebooted a VM by name-label and was logged into the whole time and it clearly didn't reboot. While troubleshooting I realized I had two VMs with the same name-label and XCP rebooted the one I wasn't logged into. Below is an example of multiple VMs using the same name-label.

      

    [root@cloud1 ~]# xe vm-list name-label=baseimage-copy

    uuid ( RO)           : 7062651a-6c05-ac3b-fe71-5dd9b6ca2c18

         name-label ( RW): baseimage-copyThe simplest method of copying a VM would be to just accept the defaults.

     

     

     

    [root@cloud1 ~]# xe vm-list

    uuid ( RO)           : adde907a-3b85-80e5-e7c9-47718dd1d55b

         name-label ( RW): baseimage

        power-state ( RO): halted

    [root@cloud1 ~]# xe vm-copy name-label=baseimage new-name-label=baseimage-copy

     

    This process may take a few minutes depending on the size of the disk image. It's worth noting that it's more reliable to use a VM's UUID to identify it than it's name and the reason for this is that XCP allows you to have more than one VM in a pool with the same name. The line above would look a bit different if we'd used the VM's UUID.

     

        power-state ( RO): halted

     

    uuid ( RO)           : fce951a3-1105-6e36-b6db-09ba3fd37180

         name-label ( RW): baseimage-copy

        power-state ( RO): halted 

     

    The other instance where I use UUIDs would be scripting. If I'm managing VMs using a shell script I'll always use UUIDs since shell scripts don't care about pretty name labels and UUIDs are more reliable.

    You may want to add a description to the VM as well for future reference.

    [root@cloud1 ~]# xe vm-list
    uuid ( RO)           : adde907a-3b85-80e5-e7c9-47718dd1d55b
         name-label ( RW): baseimage
        power-state ( RO): haltedthe Man, the Myth, the Legend
     [root@cloud1 ~]# xe vm-copy name-label=baseimage new-name-label=baseimage-copy new-name-description="Copy of baseimage"
    [root@cloud1 ~]# xe vm-list name-label=baseimage-copy params=name-description,name-label 
    name-label ( RW)          : baseimage-copy
        name-description ( RW): Copy of baseimage
    
      
     
     
    Sometimes you need to specify the Storage Repository to copy the image to. In the examples above the disk image will be copied to the DEFAULT Storage Repository so normally you don't have to specify. However there are several cases where you may want to specify. An example of this would be if the storage repository you want the VM copied to isn't default.
    [root@cloud1 ~]# xe sr-list 
    uuid ( RO)                : 92bf5d33-a164-d75c-26c0-3f53f0490ba0
              name-label ( RW): iSCSI_Disk2
        name-description ( RW): SSD on cloud0
                    host ( RO): <shared> 
                    type ( RO): lvmoiscsi
            content-type ( RO): user
    [root@cloud1 ~]# xe sr-list
    uuid ( RO)                : 92bf5d33-a164-d75c-26c0-3f53f0490ba0
              name-label ( RW): iSCSI_Disk2
        name-description ( RW): SSD on cloud0
                    host ( RO): <shared>
                    type ( RO): lvmoiscsi
            content-type ( RO): user
    [root@cloud1 ~]# xe vm-copy name-label=baseimage new-name-label=baseimage-copy new-name-description="Copy of baseimage" sr-uuid=92bf5d33-a164-d75c-26c0-3f53f0490ba0
     
     This will copy the VM to the Storage Repository with the UUID of 92bf5d33-a164-d75c-26c0-3f53f0490ba0. Be careful with this though. If the Storage Repository isn't accessible by that host ie. it isn't shared then the VM won't be able to start. 
     

    Cloning a Virtual Machine

    Cloning a VM is very similar to Copying it with the exception of it being much faster and you can't choose your Storage Repository. You can't specify the Storage Repository because it creates a Copy on Write instance of the original disk. This means the clone goes very fast due to it not writing very much data. As a VM changes the contents of the disk by adding/removing files the changes are stored in the Copy on Write clone and not the original disk. This means you can create them very fast but you can't clone to a new Storage Repository.

    [root@cloud1 ~]# xe vm-list
    uuid ( RO)           : adde907a-3b85-80e5-e7c9-47718dd1d55b
         name-label ( RW): baseimage
        power-state ( RO): haltedthe Man, the Myth, the Legend
     [root@cloud1 ~]# xe vm-clone name-label=baseimage new-name-label=baseimage-copy new-name-description="Copy of baseimage"
    [root@cloud1 ~]# xe vm-list name-label=baseimage-copy params=name-description,name-label 
    name-label ( RW)          : baseimage-copy
        name-description ( RW): Copy of baseimage
    

     

    Something to keep in mind. If you clone VM1 to VM2, then clone that to VM3 and so on you will eventually have a great deal of overhead writing to the disks. Each time a VM wants to write to disk Xen Cloud Platform has to check each disk image to see what's changed. Therefor it's recommended to clone the original and not clone a clone. If you have multiple levels of clones you can do a vm-copy to make a fresh new VM disk to restore performance.

     

  • Install git on XCP/Xenserver host

    To develop the Xenapi Admin Tools for the Xenapi Admin Project I install git on the XCP/Xenserver host so I can write tools and keep the github project up to date as well. Following is how to get git working on XCP 1.6 - Xenserver 6.5.  To develop tools I just mount my XCP host /partition on my development machine via sshfs so I can edit tools remotely. When I'm satisfied with the tools I commit them using git commit -a  followed by git push to send the changes to the xenapi-admin-tools github repository.

     

     Add the EPEL repo, install git then disable the repo

    We add the EPEL repo (which is necessary), install git and then disable the repo immediately to keep other system specific packages from updating.

    rpm -ivh http://mirror.itc.virginia.edu/fedora-epel/5/i386/epel-release-5-4.noarch.rpm
    yum install git
    sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/epel.repo

     

    Configuring git

    To use git to clone our Xenapi Admin Tools repository you'll need to set a few configuration items. Change "Your User Name" to your actual username you want to authenticate with. Change "Your Email Address" to your own email address.

    git config --global user.name "Your User Name"
    git config --global user.email "Your Email Address" git config --global credential.helper cache git config --global credential.helper 'cache --timeout 3600'
    git config --global push.default simple

     

    Clone the xenapi-admin-tools github and add it to your PATH (OPTIONAL)

    Cloning the github repo is pretty easy. Below we clone the Xenapi Admin Projects tools repo which  will create a /root/xenapi-admin-tools directory. The tools are in xenapi-admin-tools/releases/<version number> but to use them we'll need to add that directory to our system $PATH variable.

    cd /root
    git clone https://github.com/Xenapi-Admin-Project/xenapi-admin-tools.git
    echo 'PATH="$PATH:/root/xenapi-admin-tools/releases/4.1"' >> ~/.bashrc

     

     

     

  • Install xe on CentOS6

    Sometimes you want to control your XCP/Xenserver pool from another host. In my case it's my firewall/iSCSI SAN box which is CentOS 6.5 X86_64. I could just remote execute xe using SSH but this doesn't allow me to set $XE_EXTRA_ARGS. Setting $XE_EXTRA_ARGS allows me to run xe commands remotely without having to specify the server, username, password or port number every time I run xe.

     

    export XE_EXTRA_ARGS="server=${POOL},port=${PORT},username=${USER},password=${PASSWORD}"

     

    A better choice is to install xe on the CentOS 6.5 host. 

    Install pre-reqs

    Install stunnel

    yum install stunnel

     

     Install xapi-xe rpm from Xenserver CD

    Because the Control Domain in Xenserver is 32 bit the xe command included is also 32 bit. If you have 64 bit CentOS you will need to install 32 bit glibc. The best way is to just let yum worry about it as apposed to using rpm.

    If you already have a XenServer CD available you can copy the xapi-xe rpm to your CentOS host directly. If not follow the directions below.

    wget http://downloadns.citrix.com.edgesuite.net/akdlm/8159/XenServer-6.2.0-install-cd.iso
    mkdir xsiso
    mount -o loop XenServer-6.2.0-install-cd.iso xsio
    yum install xsio/packages.main/xapi-xe-0.2-5669.i686.rpm

     

     Control remote poolmaster using xe

     Because the poolmaster is remote you'll need to include the server, port, username and password in your commandline. 

    xe -s <poolmaster> -p 443 -u root -pw <root password> vm-list

    You can set these items in the XE_EXTRA_ARGS variable to make using xe easier.

    export XE_EXTRA_ARGS="server=${POOL},port=${PORT},username=${USER},password=${PASSWORD}"
    xe vm-list
  • 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.



  • Install Xenapi Admin Tools from github

    The Xenapi Admin Tools are starting to  become so useful that I don't like having XCP hosts without them. Currently you can go to http://xenapi-admin-project.github.com/xenapi-admin-tools/ and download the archive onto your host, extract it and then copy the tools to your PATH. This however, is a lot of work since they get updated often. In the coming weeks (months?) I'll be finishing the Yum repo for Xenapi Admin Tools so the XCP package manager can keep them up to date. Until I get that accomplished however it may be easier to just install git and clone the github repository. Every time you want to get updates you'd just cd into the xenapi-admin-tools directory and run git pull.

     

    With that in mind we have to add the EPEL repository where git is housed in order to use Yum to install it.

     

    Install the EPEL repo

    rpm -ivhhttp://mirror.itc.virginia.edu/fedora-epel/5/i386/epel-release-5-4.noarch.rpm

     

    Install git

    yum install git

     

    Disable EPEL repo

    The EPEL repository is enabled by default so we didn't have to do anything special to install git. However, you may not want it enabled all the time because packages that EPEL hosts may replace XCP specific packages and mess up your system

    sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/epel.repo

     

  • Install Xenserver from a USB thumbdrive

    Prerequisites

    • A Linux or Windows PC
    • USB Thumbdrive
    • Xenserver ISO image (tested versions)
      • XCP 1.1
      • XCP 1.5/1.6
      • Xenserver 6.2
      • Xenserver 6.5

     

    Software

    If you're using Windows you need to download Unetbootin. Most Linux distributions include it in their repositories so you can install it using the standard Linux package managers (yum, apt-get, zypper,synaptic etc.). You will also need to download the Xenserver installation CD and save it. 

     

    Setting up the USB thumb drive

    The USB thumbdrive has to have a partition on it and it has to be formatted as FAT32. 

     

    1. Make yourself root using su or sudo.
    2. fdisk <device>
    3. Create a new partition and change the partition type to vfat
    4. Save the partition
    5. Format it using mkfs -t vfat <device>

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    Installing XCP/Xenserver on the thumbdrive

    1. Mount the partition with the mount command or just remove the thumb drive and reinsert it (usually works)
    2. Start unetbootin
    3. Select Diskimage and then your XCP/Xenserver ISO image that you downloaded
    4. Select USB Drive under Type
    5. Select your thumb drive device
    6. Press OK

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    Fixing the thumbdrive so it will boot properly

    The isolinux is used to boot ISO9660 disks like cdroms. We need to change the config so it uses syslinux which is used to boot hard disks.

    cd into your mounted thumbdrive and copy/paste the following commands

    mv boot/isolinux/isolinux.cfg boot/isolinux/syslinux.cfg
    mv boot/isolinux boot/syslinux
    mv syslinux.cfg syslinux.cfg.bak
     

     

     

     

     

     

     

     

     

    You're done. Insert the thumbdrive into your future XCP/Xenserver host and reboot. You may need to go into the BIOS to change the boot order so it will boot from a USB device.

    Notes:

    1. Although I mentioned you can do this from Windows I won't be providing any support for it because I don't use Windows
    2. The thumbdrive needs to be formatted as FAT32 only
    3. Unetbootin has a tendency to just add files to the thumbdrive so make sure you format the thumbdrive between uses
    4. Not renaming the syslinux/isolinux files will get you an Unfound kernel error on boot

     

    A common error is getting the dreaded mboot.c32: not a COM32R image  message. This seems to be because on some versions of the XCP install media the mboot.c32 file is not quite right. The last time I had to fix this I created a Xenserver 6.2 USB thumbdrive (which worked) and copied the /boot/syslinux/mboot.c32 file from there into my XCP 1.1 USB thumbdrive (which got the error listed above). Copy the good mboot.c32 file to the USB thumbdrive's /boot/syslinux folder. This solved the problem for me and so far I've only had it with XCP 1.1.

    Xenserver 6.2 - 6.5 doesn't seem to have the problem listed above.

  • Install Xenserver Hotfixes to XCP

    Hi,

    It looks like you're using the Performance Monitoring Supplemental Pack.

    "Failed to process plugin: xcp-rrdd-xenpm" looks like a known issue. (The problem is that xcp-rrdd doesn't cope with metrics payloads greater than 16KiB.)

    This will not affect operation at all -- it merely means that you won't see any metrics about the time your server's CPUs spend in C- and P-states.

    If my guess about the cause of the issue is correct, and you are feeling brave, you could attempt to fix this by applying a XenServer hotfix (XS61E017, available from http://support.citrix.com/article/CTX137168) to your XCP host. But I don't know the details on how to do this -- I'm sure someone else on this list could help you if you want to try this.

    To unpack a XenServer hotfix, run the command:

    gpg --homedir /opt/xensource/gpg/ --no-default-keyring --keyring /opt/xensource/gpg/pubring.gpg --output hotfix.unsigned --decrypt <XSUPDATE.the_filename>

    This will give you the file 'hotfix.unsigned'. You can then do 'sh hotfix.unsigned unpack' which will give you a tmp directory with the unpacked rpms. You can then install the rpms.

    And I'm sorry that this process isn't seamless on XCP like it is on XenServer.

    Mike

     

     

  • Install XenWebManager Appliance

    Possibly the easiest way to get a graphical management interface running on XCP is to use the Xen Web Manager Appliance. The appliance is a complete Virtual Machine with XenWebManager installed and ready to run. 

    These commands should be typed into your XCP cloud host.

     

    1. Download and import the appliance 

    This is a very long URL from Sourceforge but it does work if you copy and paste it.

    cd ~
    wget http://downloads.sourceforge.net/project/xenwebmanager/appliances/xenwebmanager.xva.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fxenwebmanager%2F&ts=1365405701&use_mirror=superb-dca3 gunzip xenwebmanager.xva.gz xe vm-import filename=xenwebmanager.xva

     

     

    2. Verify the appliance and start it 

    [root@testcloud1 ~]# xe vm-list name-label=xenwebmanager
    uuid ( RO)           : 70f63ce4-b775-22c6-a556-a03a7bea6220
         name-label ( RW): xenwebmanager
        power-state ( RO): halted
    
    [root@testcloud1 ~]# xe vm-start name-label=xenwebmanager
    

     

  • Install XenWebManager on XCP host

     This tutorial is for installing XenWebManager on an XCP host but should work just as well for installing XenWebManager on any Redhat based hosts (CentOS/Fedora).

    It's best to install XenWebManager on another machine or even a VM for security reasons but I could see installing it on a host for simplicity's sake.

    You will need to be root in order to follow the instructions below.

     

    1. Download and install the packages

     

    cd ~
    wget http://iweb.dl.sourceforge.net/project/xenwebmanager/xenwebmanager_beta_full.tar.gz
    tar -xzvpf xenwebmanager_beta_full.tar.gz 
    cd xenwebmanager/tools
    bash install_rh.sh

     

    2. Run XenWebManager

    Run xenwebmanager service. The install script above already configures it to auto-start on XCP host bootup. To turn auto-start off - chkconfig xenwebmanager off...

    service xenwebmanager start

     

  • Install XVP Appliance

    Using my tutorials it's fairly easy to install Linux... as long as I've written a tutorial for it. It's also fairly easy to start and stop your VMs... if you understand the XE command or you've installed xenapi-admin-tools. If you're the type of person who appreciates a good graphical interface you can run Citrix' own Xencenter software which does a great job. However it's a Windows application so if you (like me) don't run Windows then you can't easily run Xencenter. There is a free GUI based management tool named XVP that allows you to do simple administration of your VMs like starting and stopping them. It also handles the messiness of tunneling through network and firewalls to provide a VNC console on your local desktop which can be very handy if you want to do a graphical install.

     

    There are two ways to getting XVP to run on your xapi cloud:

    1. Create a CentOS VM and install/configure all of the XVP packages
    2. Download the XVP Appliance VM image and run it

    We will choose the latter as it's a great deal easier to do. 

     

    Creating a download location large enough for the xvpappliance VM image

    You have an issue with just downloading the XVP Appliance and importing it into XCP as the image is too big for the stock XCP Operating System drive so we will remedy this by creating an ext3 formatted Logical Volume to store the image in temporarily.

    Get the name of your  Storage Repository named "Local Storage". This would be the default SR created on install. 

    [root@testcloud1]# xe sr-list
    uuid ( RO)                : 735f9d8e-64eb-71b7-9fd4-47c342c7c9e4
              name-label ( RW): Local storage
        name-description ( RW): 
                    host ( RO): testcloud1
                    type ( RO): lvm
            content-type ( RO): user
    

     

  • Interactive install of OpenSuse 11.4 VM (64 bit)

    Note: Updated to work with XCP 1.5b/1.6

    Install Type

    • Interactive
    • Network boot
    • Commandline
    • Paravirtualized

    Prerequisites

    • XCP/Xenserver
    • Access to Internet
    • Working DHCP server
    • Working DNS name resolution

    Introduction

    This tutorial was written in the spirit of my CentOS 6 VM (64 bit) automated installation on XCP  howto. In that tutorial I do an automated network installation of CentOS 6. This has proven very popular since you can't install a paravirtualized domain using a physical install media. This has been a very nice installation howto because you don't have to download any install CD/DVDs and you could create VMs using nothing more than a commandline login. It's also very nice because it can be mirrored locally if you're doing a bunch of them just by rsyncing a CentOS mirror locally then downloading my files and editing them.

    There became a need to do the same thing using OpenSuse thus this tutorial.  

  • KVM 80 on CentOS 5.2

    This isn't really a howto per se but rather a pointer to RPMs for KVM on CentOS/RHEL.

    You can get KVM 80 for x86_64 here.

    http://www.lfarkas.org/linux/packages/centos/5/x86_64/

    The same site doesn't seem to have i386 RPMs but they do have i386 SRPMS that you could build.

     

    http://www.lfarkas.org/linux/packages/centos/5/SRPMS/

     

    I don't have time to do any sort of tutorial on building KVM SRPMs because I'm not currently using KVM for any projects. In the future I'll get to it but probably not too soon.

  • KVM Howtos

    I don't generally use KVM so the Howto's here are old and probably obsolete.

     

  • KVM on CentOS

    So here's a quick howto on getting KVM to work on CentOS5.x. I'll add more tutorials when I start using KVM more. For now I spend all my time on VirtualBox at work and Xen everywhere else. KVM is maturing fast but still not where Xen is for the most part. It also needs VT support in the CPUs which means not everyone can use it. My 4 core, 8 vcpu Xeon machine in the garage won't run KVM so I'm not spending a lot of time with it right now. One of the reasons I don't use KVM in a production environment is it moves too fast and the distros are just too far behind as you'll see in the howto

     

    1. First you need to see if you're CPU has the needed hardware VT support

     

    egrep 'vmx|svm' /proc/cpuinfo

    If you have an Intel CPU with VT support you should get back vmx and svm if it's AMD with VT support. If you get nothing you need to use Xen or VirtualBox as both support Virtualization without the hardware VT support.

     

    2. Install KVM and QEMU

     

    yum install kvm kmod-kvm qemu

    The current version of KVM is 36 which is ancient (August 2007) but stable as far as KVM goes. Even with this version I've gotten lockups and strange behavior. The most recent version of KVM is 74 so you can imagine what's been added since version 36. If you want to check it out yourself here's the changelog.

  • 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

  • Make VMs autoboot

    Getting VMs to boot up automatically when an XCP host powers up is fairly easy but not entirely logical. With the old Xen we'd just copy the config file into /etc/xen/auto but XCP/Xenserver has no such directory. Using XCP/Xenserver you have to tell the pool to turn on auto_poweron and you also have to set it for the VM you want to autoboot as well. 

     

    1. Get the Pool UUID number

    Use xe pool-list to get the UUID of the pool.  We see the pool UUID is d47b4251-60bc-aa36-c572-c425fdc1b897.

    [root@testcloud1 ~]# xe pool-list
    uuid ( RO)                : d47b4251-60bc-aa36-c572-c425fdc1b897
              name-label ( RW): 
        name-description ( RW): 
                  master ( RO): c76a1ba7-8cdd-45a7-8399-38f242355a43
              default-SR ( RW): 735f9d8e-64eb-71b7-9fd4-47c342c7c9e4
    

     

    2. Set auto_poweron for the pool 

    To set the value of a pool parameter we'll use the xe pool-param-set. Use the pool UUID from the previous step here. We'll be setting the auto_poweron item of the other-config map parameter to true.

    xe pool-param-set uuid=d47b4251-60bc-aa36-c572-c425fdc1b897 other-config:auto_poweron=true

     

    3. Get the VM UUID number

    Use xe vm-list to get the UUID of the VM you'd like to autoboot. We see the VM UUID is  d2e81fdd-e2cd-b0db-8b0e-e280611eb446. 

    [root@testcloud1 ~]# xe vm-list
    uuid ( RO)           : d2e81fdd-e2cd-b0db-8b0e-e280611eb446
         name-label ( RW): CentOS6
        power-state ( RO): halted
    
    

     

    4. Set auto_poweron for the VM 

    To set the value of a VM parameter we'll use xe vm-param-set. Use the VM UUID from the previous step here. We'll be setting the auto_poweron item of the other-config map parameter to true.

    xe vm-param-set uuid=d2e81fdd-e2cd-b0db-8b0e-e280611eb446 other-config:auto_poweron=true

     

    5. Test

    Test your work by rebooting the host.

     

     

  • Making Xenapi Admin Tools XCP 1.6 compliant

    I've started the process of making Xenapi Admin Tools XCP 1.6 compliant. I haven't found too many things I've had to change but XCP referrs to a few parameters differently. 

    For instance the software-version map parameter has changed the product_brand item to platform_name. The item product_version has been changed to platform_version.

     

    XCP 1.1 XCP 1.6
    product_brand platform_name
    product_version platform_version

     

    Neither of these changes are major and I believe they were made to make XCP more compatible with Xenserver (or at least bring their code into sync) but my lshosts command would bring up nothing for both of those columns. This has been fixed and backwards compatibility has been maintained with XCP 1.1.

  • New download section for Xen Cloud Platform/Xenserver scripts

    As I build tools to help manage my clouds I will upload them here. So far I have three - mktemplate.sh, lstemplate.sh and lsvms.sh.

    1. mktemplate.sh is a wizard that creates XCP/Xenserver templates.
    2. lstemplate.sh lists XCP/Xenserver templates showing name-label and UUID sorted with colors. Optionally it shows the template description.
    3. lsvms.sh lists XCP/Xenserver Virtual Machines including name, running state, UUID and it's host.

    In each of these cases I needed this functionality in a nice easy to use command. I also wanted the output to be parsable if possible ie. it needed to be line oriented and each field separated by white space. 

    There will be many more tools coming as I get time and I have needs. I'd love to have a tool that lists VM hardware (nics, disks, cds) in a nice manner, a tool to list disks and the srs they reside on with flags (rw etc..). Stay tuned.

    The tools have been moved to github so the most convenient way to install them is to install git and do a git clone.

    Intall Git on XCP - http://grantmcwilliams.com/item/652-install-git-on-xcp-host

    Git clone - git clone https://github.com/Xenapi-Admin-Project/xenapi-admin-tools

  • New XCP tools

    As I and the team are writing manpages for XCP's xe command and it's 361 sub commands I'm writing more XCP tools. Last night I hacked out lshostvms.sh and xcptop.sh.

    The lshostvms.sh script gives a quick list of hosts and shows numerically how many VMs are currently running on each. This includes the Control Domain itself currently  but I may change that in the future.

     

     

     

     

     

     

     

     The xcptop.sh script gives a list of all hosts and for each CPU core shows the utilisation according to XCP. 

     

  • OpenSuse 11.4 VM (64 bit) automated installation on XCP

    Install Type

    • Semi-automated
    • Network boot
    • Commandline
    • Paravirtualized

    Introduction

    This tutorial was written in the spirit of my CentOS 6 VM (64 bit) automated installation on XCP  howto. In that tutorial I do an automated network installation of CentOS 6. This has proven very popular since you can't install a paravirtualized domain using a physical install media. This has been a very nice installation howto because you don't have to download any install CD/DVDs and you could create VMs using nothing more than a commandline login. It's also very nice because it can be mirrored locally if you're doing a bunch of them just by rsyncing a CentOS mirror locally then downloading my files and editing them.

    There became a need to do the same thing using OpenSuse thus this tutorial.  

  • 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.

  • VirtualBox Howtos

    I use VirtualBox almost every day but I haven't created a product around it in a very long time so the Howto's here will probably be very old until the time comes when I'm digging into it again.

  • 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