How to build your own VyOS template for XenServer

Hi,

I’m sure every XenServer user remembers very well that once upon a time when Vyatta was released it came along with a preconfigured XenServer template which was very convenient and quick way to get rolling. Then Vyatta discountinued image preparation for free edition but actually it’s quite simple to prepare this image yourself and if you tend to have a highly customized environment you may even include some custom settings in the template (like NTP servers, users and passwords etc. but also entire config branches for many services) so that you don’t have to configure it manually on each new VM.

I created this manual a while ago and it was even posted on vyatta.org but since it’s no longer available, please find this revised guide below. It’s tested with VyOS 1.0.4 and XenServer 6.2.


  1. Start with downloading the ISO file, be sure to download the “virt” version made for virtual environments.

  2. Create a new VM in XenServer using “Other install media” template (scroll down the list). Select the VyOS ISO as the installation source. It’s enough to assign 512 MB of RAM and 1 vCPU. This is only for the template VM and your actual VM that will be later created based on this template may have other settings. Therefore you also don’t need to assign any interfaces. 4 GB disk is enough for the storage.

  3. Start the VM and login as vyos/vyos and process with the image installation. It’s important to answer “Yes” when setup asks whether to prepare the config files for PV conversion.

install image
  1. Reboot the VM and make sure it boots from the disk (you can unmount the ISO while VM is shut down).

  2. Login again and mount XenTools ISO:

sudo su
mount /dev/cdrom /mnt
  1. Now install XenTools:
/mnt/Linux/install.sh
  1. Power off the VM (do not reboot it):
poweroff
  1. Now go to XenServer host console (either via XenCenter or just ssh to the host). We will now convert the VM from HVM to PV.

  2. Find the UUID of the template VM and change its boot policy:

[root@XEN05 ~]# xe vm-list name-label=VyOS_Template
uuid ( RO)           : 6cb4d109-5499-d112-c777-d2a2c8369b39
     name-label ( RW): VYOS_Template
    power-state ( RO): halted

[root@XEN05 ~]# xe vm-param-set uuid=6cb4d109-5499-d112-c777-d2a2c8369b39 HVM-boot-policy=""
[root@XEN05 ~]# xe vm-param-set uuid=6cb4d109-5499-d112-c777-d2a2c8369b39 PV-bootloader=pygrub
[root@XEN05 ~]# xe vm-param-set uuid=6cb4d109-5499-d112-c777-d2a2c8369b39 PV-args="console=hvc0 xencons=hvc"
  1. Now find the UUID of the bootable disk’s VBD - it’s important to grab the identifier of the VBD and not the VDI! Set the VBD as bootable.
[root@XEN05 ~]# xe vm-disk-list uuid=6cb4d109-5499-d112-c777-d2a2c8369b39
Disk 0 VBD:
uuid ( RO)             : 15ef5e96-9682-2db7-df6e-25f3c1acab80
    vm-name-label ( RO): VYOS_Template
       userdevice ( RW): 0


Disk 0 VDI:
uuid ( RO)             : aeaf3bfa-b396-4e9e-bb33-3b6770a1897a
       name-label ( RW): VYOS_Template
    sr-name-label ( RO): Local B SR
     virtual-size ( RO): 4294967296


[root@XEN05 ~]# xe vbd-param-set uuid=15ef5e96-9682-2db7-df6e-25f3c1acab80 bootable=true
  1. Check if the VM boots. It should be up and running just fine. Now let’s prepare the VM to save it as a template. We need to make sure the configuration file is “agnostic”, e.g. doesn’t contain any MAC addresses that most probably won’t exist on another system :wink: We can edit the configuration via CLI or just open the /config/config.boot file in nano and make changes there. If you edit via CLI make sure to issue “save” when you’re done.

  2. While doing that we can also make any other configuration customizations like setting the NTP server etc. Also delete the “console ttyS0” configuration entry to prevent frequent error messages in the console (INIT: Id “T0” respawning too fast…).

  3. Power off the VM when you’re confident the config file is clear and prepared. Do not boot the template VM again. Instead right-click it in XenCenter and select “Convert to template”.


That’s it, you can now clone the template and make new VMs. You can also export this template as an XVA file and import it on another XenServer hosts. I’m happy to help if you have any problems or questions :slight_smile:

Best regards,
Docent

Thanks, you helped me a lot :slight_smile:

Super Post !!, Thanks a lot

I got as far as trying to boot the VM after running the 3 xe vm-param-set commands and the xe-vbd-param-set command. I then tried to boot the VM and it wouldn’t boot with a message, "The bootloader for this VM returned and error – did the VM installation succeed? Unable to find partition containing kernel

What did I hose up?

Hi,

Before migrate to VyOS I used a Vyatta XenServer appliance…Today I Install from scratch VyOS on XenServer 6.5 SP1 and moved config from Vyatta to VyOS, but I have a few problems:

  • how to disabled this: INIT: Id “T0” respawning too fast: disabled for 5 minutes
  • when I turn off a VM VyOS and want turn on again, all the time I get messages: No bootable device. I resolved this problem reattch disk,but is not a resolve…

I had the same problem, removing the pv cdrom from the dvd drive fixed it for me.

Registered on the forums just to say, thank you. Performance is so much better with PV enabled.

Thanks @hhegeman, that worked for me too!

One change here to original post:

A better option is to change the console ttyS0 to console hvc0. This will allow the console to display properly in XenCenter.

Thanks all!

Hi I know this is an old post, is there any way to get this guide updated for VyOS 1.3 for XCP-NG Version 8?

When i try to load the guest tools it errors out with the following:

Any help is appreciated.

I figured this one out. I will make a full guide in a new post soon for the community. I know there is users of XenServer and XCP-NG out there that want to make use of the management agent. Once installed you can failover between hosts properly for HA.

I tested this in both XCP-NG version 7.6 and 8.0. This was performed with VyOS 1.3 rolling release on 4/1/2020. HVM is the way to go now, no need for PV.

When selecting the template select Debian 9 or 10.

The key step was removing the Xen VyOS package first.
sudo apt-get purge vyos-xe-guest-utilities

then run the XCP-NG installer again
/mnt/Linux/install.sh

reboot, enjoy!