Difference between revisions of "Installing a new virtual machine on XenServer"
From Christoph's Personal Wiki
m (Christoph moved page Installing a new slice on XenServer to Installing a new virtual machine on XenServer) |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | This article will walk you through the steps necessary to create a new slice/instance on a XenServer host. I will call my XenServer "<code>xenserver.champ.com</code>". | + | This article will walk you through the steps necessary to create a new slice/instance/virtual machine (VM) on a XenServer host. I will call my XenServer "<code>xenserver.champ.com</code>". |
* Create a VM titled "<code>slice-<your name></code>" (so, for example, <code>slice-champ</code>) with the template titled "<code>slice-template</code>". | * Create a VM titled "<code>slice-<your name></code>" (so, for example, <code>slice-champ</code>) with the template titled "<code>slice-template</code>". | ||
Line 6: | Line 6: | ||
xe vm-list | xe vm-list | ||
− | * Create a 20GB VDI in the "slices" SR for the VM for use as root. The VDI should be named "<code>slice-<your name></code>". You should create a VBD for this VDI attached as <code>xvda</code>. | + | * Create a 20GB virtual disk image (VDI; i.e., a virtual hard drive image record in XenServer) in the "slices" SR for the VM for use as root. The VDI should be named "<code>slice-<your name></code>". You should create a virtual block device (VBD; i.e., what XenServer calls what you "plug" into) for this VDI attached as <code>xvda</code>. |
xe vdi-create sr-uuid=a6dbac41-2bb1-78dd-5a43-f168ee19c3ba name-label=slice-champ virtual-size=20GiB type=user | xe vdi-create sr-uuid=a6dbac41-2bb1-78dd-5a43-f168ee19c3ba name-label=slice-champ virtual-size=20GiB type=user | ||
Line 17: | Line 17: | ||
xe vbd-create vm-uuid=0b25cddd-d35b-1e41-6963-4dd2013fb338 device=xvda1 vdi-uuid=0de6be45-e3a5-4fa2-ae79-5f239f17cdaa | 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 mode=rw type=Disk device=0 bootable=true | ||
#~OR~ | #~OR~ | ||
xe vbd-create vm-uuid=$VMID vdi-uuid=$VDIID device=xvda1 | xe vbd-create vm-uuid=$VMID vdi-uuid=$VDIID device=xvda1 | ||
Line 26: | Line 28: | ||
xe vbd-param-set uuid=$VBDID userdevice=xvda | 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 "<code>swap for slice-<your name></code>". You should create a VBD for this VDI attached as <code>xvdc</code>. | + | * Create a 1GB VDI in the "slices" storage repository (SR) for the VM for use as swap. The VDI should be named "<code>swap for slice-<your name></code>". You should create a VBD for this VDI attached as <code>xvdc</code>. |
xe vdi-create sr-uuid=$SRID name-label="swap for slice-champ" virtual-size=1GiB type=user | xe vdi-create sr-uuid=$SRID name-label="swap for slice-champ" virtual-size=1GiB type=user | ||
Line 35: | Line 37: | ||
NATNET_ID=$(xe network-list name-label='NatNet' --minimal) | NATNET_ID=$(xe network-list name-label='NatNet' --minimal) | ||
− | xe vif-create network-uuid=$NATNET_ID vm-uuid=$VMID device=0 | + | xe vif-create network-uuid=$NATNET_ID vm-uuid=$VMID mac=random device=0 |
− | * Create a VIF for this VM that is attached to the network titled "InternalNet". This should be attached to the VM as <code>eth1</code>. | + | * Create a virtual network interface (VIF) for this VM that is attached to the network titled "InternalNet". This should be attached to the VM as <code>eth1</code>. |
INTERNALNET_ID=$(xe network-list name-label='InternalNet' --minimal) | INTERNALNET_ID=$(xe network-list name-label='InternalNet' --minimal) | ||
− | xe vif-create network-uuid=$INTERNALNET_ID vm-uuid=$VMID device=1 | + | xe vif-create network-uuid=$INTERNALNET_ID vm-uuid=$VMID mac=random device=1 |
* Configure your VM to CD-install Debian using the following CD available on the host (<code>xe cd-list</code>): <code>debian-6.0.7-amd64-CD-1.iso</code> | * Configure your VM to CD-install Debian using the following CD available on the host (<code>xe cd-list</code>): <code>debian-6.0.7-amd64-CD-1.iso</code> | ||
Line 46: | Line 48: | ||
xe vm-param-get uuid=$VMID param-name=allowed-VBD-devices | 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 vm-cd-add vm=slice-champ cd-name="debian-6.0.7-amd64-CD-1.iso" device=4 | ||
− | xe vbd-param-set uuid= | + | xe vbd-param-set uuid=$VBDID 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) | 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 | xe vm-param-set uuid=$VMID other-config:install-repository=cdrom | ||
+ | |||
+ | * Set memory limits (optional, but a good idea): | ||
+ | xe vm-memory-limits-set uuid=$VMID static-min=512MiB static-max=512MiB dynamic-min=512MiB dynamic-max=512MiB | ||
* Start your VM. | * Start your VM. | ||
Line 94: | Line 99: | ||
lvs | lvs | ||
showmount -e localhost | showmount -e localhost | ||
+ | cat /etc/xensource-inventory | ||
[[Category:XenServer]] | [[Category:XenServer]] |
Latest revision as of 16:25, 20 June 2017
This article will walk you through the steps necessary to create a new slice/instance/virtual machine (VM) 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 virtual disk image (VDI; i.e., a virtual hard drive image record in XenServer) in the "slices" SR for the VM for use as root. The VDI should be named "
slice-<your name>
". You should create a virtual block device (VBD; i.e., what XenServer calls what you "plug" into) for this VDI attached asxvda
.
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 mode=rw type=Disk device=0 bootable=true #~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" storage repository (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 asxvdc
.
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 mac=random device=0
- Create a virtual network interface (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 mac=random 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=$VBDID 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
- Set memory limits (optional, but a good idea):
xe vm-memory-limits-set uuid=$VMID static-min=512MiB static-max=512MiB dynamic-min=512MiB dynamic-max=512MiB
- 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 thevm=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 cat /etc/xensource-inventory