Installing a new virtual machine on XenServer

From Christoph's Personal Wiki
Revision as of 10:44, 30 September 2013 by Christoph (Talk | contribs)

Jump to: navigation, search

This article will walk you through the steps necessary to create a new slice/instance on a XenServer host. I will call my XenServer "xenserver.champ.com".

  • Create a VM titled "slice-<your name>" (so, for example, slice-champ) with the template titled "slice-template".
xe vm-install template=slice-template new-name-label=slice-champ
xe vm-list
  • Create a 20GB VDI in the "slices" SR for the VM for use as root. The VDI should be named "slice-<your name>". You should create a VBD for this VDI attached as xvda.
xe vdi-create sr-uuid=a6dbac41-2bb1-78dd-5a43-f168ee19c3ba name-label=slice-champ virtual-size=20GiB type=user
#~OR~
SRID=$(xe sr-list name-label=slices --minimal)
xe vdi-create sr-uuid=$SRID name-label=slice-champ virtual-size=20GiB type=user
VMID=$(xe vm-list name-label=slice-champ --minimal)
VDIID=$(xe vdi-list name-label=slice-champ --minimal)
xe vbd-create vm-uuid=0b25cddd-d35b-1e41-6963-4dd2013fb338 device=xvda1 vdi-uuid=0de6be45-e3a5-4fa2-ae79-5f239f17cdaa
#~OR~
xe vbd-create vm-uuid=$VMID vdi-uuid=$VDIID device=xvda1
VBDID=$(xe vbd-list vm-name-label=slice-champ --minimal)
  • Change device from "xvda1" to "xvda"
xe vbd-param-set uuid=e6ea41d9-a61e-e1d9-0c63-d3002efb579e userdevice=xvda
#~OR~
xe vbd-param-set uuid=$VBDID userdevice=xvda
  • Create a 1GB VDI in the "slices" SR for the VM for use as swap. The VDI should be named "swap for slice-<your name>". You should create a VBD for this VDI attached as xvdc.
xe vdi-create sr-uuid=$SRID name-label="swap for slice-champ" virtual-size=1GiB type=user
VDI_SWAP_ID=$(xe vdi-list name-label="swap for slice-champ" --minimal)
xe vbd-create vm-uuid=$VMID vdi-uuid=$VDI_SWAP_ID device=xvdc 
  • Create a VIF for this VM that is attached to the network titled "NatNet". This should be attached to the VM as eth0.
NATNET_ID=$(xe network-list name-label='NatNet' --minimal)
xe vif-create network-uuid=$NATNET_ID vm-uuid=$VMID device=0
  • Create a VIF for this VM that is attached to the network titled "InternalNet". This should be attached to the VM as eth1.
INTERNALNET_ID=$(xe network-list name-label='InternalNet' --minimal)
xe vif-create network-uuid=$INTERNALNET_ID vm-uuid=$VMID device=1
  • Configure your VM to CD-install Debian using the following CD available on the host (xe cd-list): debian-6.0.7-amd64-CD-1.iso
xe vm-param-get uuid=$VMID param-name=allowed-VBD-devices
xe vm-cd-add vm=slice-champ cd-name="debian-6.0.7-amd64-CD-1.iso" device=4
xe vbd-param-set uuid=c491af53-23c4-2c1f-485f-e218aeb0ace6 bootable=true
DEBIAN_VBD_ID=$(xe vbd-list vdi-name-label=debian-6.0.7-amd64-CD-1.iso vm-name-label=slice-champ --minimal)
xe vm-param-set uuid=$VMID other-config:install-repository=cdrom
  • Start your VM.
xe vm-start uuid=$VMID
  • If everything is correct, you should be able to connect to it via VNC
sudo apt-get install xvnc2viewer
/root/get-vnc-address
vncviewer -via xenserver.champ.com localhost:2 # on local computer
  • Partition
xvda (primary) /
xvdc (primary) swap
  • After you finish the install process, you will need to remove the CD and associated VBD, then set the bootable flag to true on your xvda VBD.
xe vbd-eject uuid=c491af53-23c4-2c1f-485f-e218aeb0ace6
xe vbd-param-set uuid=e6ea41d9-a61e-e1d9-0c63-d3002efb579e bootable=true
reboot
xe vm-start name-label=slice-champ
/root/get-vnc-address
vncviewer -via xenserver.champ.com localhost:2 # on local computer
  • Install xs-tools.iso inside the vm=slice-champ
xe vm-cd-add vm=slice-champ cd-name=xs-tools.iso device=5
# inside the vm=slice-champ
mount /dev/xvdf /mnt
cd /mnt/Linux
./install.sh #~OR~ dpkg -i /mnt/Linux/xe-guest-utilities_6.1.0-1031_amd64.deb
reboot
# on the XenServer
xe vm-cd-list vm=slice-champ

Misc commands to check the status of your host or slice

xl list
iostat -xkd 1
list_domains
xentop
tap-ctl list
lvs
showmount -e localhost