0

I have an issue in which I cannot understand how to create a XenServer Virtual Machine from the command-line.

I have installed XenServer on an unused Tower unit, and currently SSH into it from my Mac. I chose to do so as XenCenter doesn't run on it, and also, as my project requires me to run the whole system from the command-line, but after spending an extortionate amount of time searching the internet for answers as to how to create VMs, I seemed to stumble upon the same, uninformative scripts, one after the other.

I understand that in order to create a VM, you run this command changing the <template-name>, and <vm-name> appropriately:

xe vm-install template=<template-name> new-name-label=<vm-name>

Again, as I am quite new to XenServer, I am unsure as to even what these need to be changed to.

In addition to this, I have no templates set or created, and wondered as to how I would do this. I hoped there would be a magical command such as xe template-new or something of the sort, but I couldn't find one. I am familiar with Docker, so wondered whether the process of creating a VM template was similar to creating a container image?

If I execute the above command (xe vm-install...), I receive the following output, if I substitute in either "Ubuntu 14.04 (64-bit)" for template name and "Ubuntu" as the label:

Error: No templates matched

I assumed that this would have been because I had not set the template, and wondered whether I could do this by creating an NFS VHD Storage Device?

I attempted to do this via the command line again, but searched the internet, and couldn't find any information as to how I would do it?

I am very confused, as XenServer is quite overwhelming, but I am determined to understand how to create a VM directly from the command line.

In order to help anyone who answers, I have included the details of my server below:
XenServer Host Name: xenserver-hxcwfafr-OliCallaghanXen
XenServer IP Address: 192.168.0.23

Many thanks for your time, and apologies for my probably ignorance.

Oli

  • Are you still looking into this? Is the template for Ubuntu 14.04 found in your version of XenServer? If not, you may need upgrade your version of XenServer. What version of XenServer are you using? – edesz Aug 6 '16 at 0:14
  • Oh god yes please! Ok so after some research I found that the tower I was using didn't support AMD-V, and so I was unable to run the VM in HVM mode, however I thinking i am supposed to be able to run it in PV mode? The problem I'm having however is running the VM in PV mode... I was also running the latest version of XenServer, but I know they released 7.0 recently so I've upgraded to that. Cheers man – Oli Callaghan Aug 7 '16 at 7:39
2

Ok, so eventually I found the answer to the problem I was facing. It turned out I must have had a corrupt install of XenServer, and after downloading the .iso again and reinstalling, I found that by executing xe template-list output a long list of useful templates.

The next hurdle I had to cross was running a VM in PV mode, as the tower unit I was using did not support HVM. It actually turns out that all 32-bit Linux Distributions are compatible out of the box with PV (as a general rule of thumb, anything old is compatible eg. Ubuntu 12.04 and 10.Whatever 32-bit; Debian Squeeze and Wheezy 32-bit), and so you are able to launch a VM in exactly the same way using the following commands:

xe sr-list outputs the list of storage repositories; the storage repository 'local storage' of type 'ext' provided for me a location where I could store the disks of each VM respectively.

xe template-list outputs the list of templates accessible on the XenServer host.

xe vm-install template=<template> new-name-label=<name_for_vm> sr-uuid=<storage_repository_uuid> 'installs' a VM based off the template onto the machine, however no actual installation occurs at this point. This then outputs the UUID of the VM in the console. By executing the command xe vm-list you can see a list of VMs which are currently installed on the host, displaying UUIDs for each and their current state.

xe network-list bridge=xenbr0 --minimal outputs the UUID of the bridge xenbr0 which is the default bridge for a fresh install of XenServer. If you are using a different bridge or want to attach the VM to a different adapter, then you can define a different name in place (however you need to make sure you've created one first :P).

xe vif-create vm-uuid=<vm_uuid> network-uuid=<network_uuid> mac=random device=0 creates a virtual network interface for the VM with a random MAC address.

xe vm-param-set uuid=<vm_uuid> other-config:install-repository=<http://server/redhat/5.0> defines the install location for the net installer of the OS. Personally, I found that by searching for mirrors on the internet for the specific flavour of OS, I was able to find the mirror. Then instead of guessing what the install repository was, I searched through the repository until I found the folder marked xen with the file vmlinuz contained within. I copied this address in, and then ran xe vm-start uuid=<vm_uuid> receiving an error that the URL was incorrect. Within this URL, some of it will be repeated so remove the repeated part and run the 'xe vm-param-set ...' command again. For Ubuntu 12.04, the mirror I used was http://http://archive.ubuntu.com/ubuntu/dists/precise-updates/.

xe vm-start uuid=<vm_uuid> will power on the VM and it will launch. This process will take a fair amount of time as it actually downloads the installer, but it should in practise only take around 2 minutes.

Congratulations! You've started your own VM running on your rubbish non-HVM tower unit, however the next step is to actually connect to it.

In order to connect, run the command xe console uuid=<vm_uuid>. This will then bring up a dialogue saying that you've connected to the console of your VM. The first time I tried this, I received no sort of output, and was perplexed, however a swift tap of the enter key sorted it out, and the setup began.

If you need any more help with setting up your VMs, then there is a great document on Citrix's website http://docs.vmd.citrix.com/XenServer/5.0.0/1.0/en_gb/guest.html that explains the process fairly thoroughly (but also not very simply either).

I sincerely hope that this has cleared up the process of launching a VM on a non HVM machine, and that this actually becomes fairly useful.

Good luck trying to get the installer to connect to the internet... (might just be me running in VirtualBox), Oli.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.