Installing XenServer With 2 Local Storage Repositories

I recently encountered a scenario where a colleague of mine needed to setup a XenServer with an SSD SR for a VM storage and another pool for slower tier deep storage. The following is the order of operations to obtain 2 discretely separate storage repositories:



  1. Boot into your RAID controller and create a virtual disk for your fast tier storage that will be shared with your Xen install
  2. With one VD visible install XenServer selecting no drives at install time for VM Storage
  3. After successful install boot into RAID controller and setup the 2nd virtual disk
  4. Boot into XenServer and go to the local command-line from xsconsole
    1. Run the following command : ll /dev/disk/by-id
    2. Look for sdb make note of its path
    3. get UUID of host :  xe host-list
  5. Using the info from above fill this in the path to sdb and host UUID

xe sr-create content-type=user device-config:device=/dev/disk/by-id/<scsi-xxxxxxxxxxxxxxxxxxxxxxxxx> host-uuid=<host-uuid> name-label=”Local Storage 2” shared=false type=lvm

Your storage should be there now, proceed to joining the pool


Cleaning up Old XenServer Patches The Easy (Lazy) Way

Cleaning up patches on XenServer isn’t difficult but it can be annoying if you have a large number of hosts. Here’s the easy way to clean up your old patch files on all hosts….if you’re an extra lazy Linux admin you can use tmux to do this to all of them at the same time 🙂

for i in `xe patch-list | grep uuid | awk '{print $5}'` ; do xe patch-clean uuid=$i ; done

I’ve been wrapping up some large projects on the work front and several audio/music related projects so apologies for not posting here for a while. I have lots of good stuff coming down the pipe in the near future!

Convert KVM VMs to Citrix XenServer

Attach External Hard Drive or External Storage

For the purposes of this task you will want to attach some sort of removable storage. An easy way to determine what the device the storage shows as run the following before attaching the storage:


make note of the last /dev/sd# device you see. Now plugin your external storage and run the same command, you should see a new entry there that should be your path you will want to use in the next step (ex: /dev/sdd1)


Next we will mount the external storage to /mnt

mount /dev/sdd1 /mnt


List the LV Info

On the KVM host you wish to copy the VM from list the lv information


You should see a path like /dev/KVM/vmname.

Convert Raw LVM to VHD

Using the qemu-img utility you will need to run the following:

qemu-img convert -O vpc /dev/vg_name/lv_name /mnt/vmname

You can also convert to other formats as listed belelow:

Disk Format
QEMU -O Argument
Disk Format
QEMU -O Argument
qcow2 (Xen/KVM) qcow2
QED (KVM) qed
raw raw
VDI (vbox) vdi
VHD (Hyper-V/Citrix Xen) vpc
VMDK (VMWare/eSXI) vmdk

Once the disk is converted and on your external storage you will want to exit the /mnt directory and unmount

cd /
umount /mnt


Import to Citrix XenServer

Attach the external drive and mount it similarly to how you did in step 1, however you will need to check and see what device this shows up as, it will likely be /dev/sdb1. Mount this to the /mnt location.


Next we will need to identify the UUID of the storage repository in Xen we are going to use by UUID:

xe sr-list

Using the UUID from above create a global variable using the following:

RESTORE=$(xe vdi-create sr-uuid=<UUID of SR from above> name-label=<vmname> virtual-size=<size of drive +1 gb>GiB)

This will create an object named restore in your storage repository. Next we will want to import the VHD

xe vdi-import filename=/mnt/<vmanme> format=vhd --progress uuid=$RESTORE

Once the import completes you will want to create a new VM in Xen but not start it. After the VM creates you will want to remove the delete the hard drive associated with the VM on the storage tab. Once you do this click “attach disk” and select the disk you imported. Once this is attached you can start the VM and you should be good to go. Note on Windows systems and some linux systems you may need to update the network settings. Once this is done install Guest Tools, reboot and you’re all set.