Grant McWilliams

41 items tagged "Howto"

  • 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

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

     

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

     

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

  • 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

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



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

     

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

  • 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

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

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

     

  • 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