I’ve been using VirtualBox on a Windows server host for sometime now but I want to be able to utilise the full power of my host for VMs and this is only really possible if you have what I call a ‘raw’ setup i.e. rather than having a full OS ‘under’ your VM you have a basic cut down OS whose only task is to run VMs. There are many options for this kind of solution but I’m going with XenServer for now as it has been recommended to me.
Installation
- Download the ISO from: http://www.citrix.com (go to XenServer/Download Now to get Free XenServer)
- Burn the ISO to disk: put a blank CD disk in the drive, double click the ISO in Windows and choose the drive.
- Put the disk in the drive and turn the system on.
- Answer the various questions, including which disk to install onto. I also installed the Linux supplemental pack and Verified the installation source
- Install XenCenter (the desktop client for XenServer):
- Browse to http://[ip of the XenServer host] and click on XenCenter installer.
- Once installed add the server.
- Request a key: Tools/License Manager
Installing a Supplemental Pack on a running host
It’s much easier to install supplemental packs at install but you may not have the them at installation so want to install them retrospectively:- Download them from http://www.citrix.com go to http://www.citrix.com XenServer, Downloads then login to go to the XenServer version and view downloads.
- Mount the network share:
- Edit hosts to give the source computer a name
vi /etc/hosts
i
[ip of computer] [name]
<ESC>:wq<Enter> - Create destination for mount:
mkdir /mnt/[share name] - Edit fstab to add line for the mount:
vi /etc/fstab
//[server name]/[share name] /mnt/[share destination name] cifs exec,credentials=/etc/cifspw 0 0 - Create a file with the windows credentials:
vi /etc/cifspw
i (to enter insert mode)
username=[domain or computer name]/[username]
password=[password]
<ESC>:wq<Enter> - Secure the file: chmod 600 /etc/cifspw
- Mount it: mount –a
NB if you get Permission denied try adding your computer name as a prefix to username eg:
username=[domain or computer name]/[username] - Check it worked:
ls /mnt/[share name] - Mount the iso and run:
mkdir /tmp/iso
mount -o loop /mnt/[share name]/XenServer-5.6.1-fp1-linux-cd.iso /tmp/iso - Run the install:
cd /tmp/iso
./install.sh - Clear up:
cd
umount /tmp/iso
rmdir /tmp/iso
Create a VM
Once installed and running you may need to download some isos to set up a VM. You can do this from the command line using:wget 'http://www.ubuntu.com/start-download?distro=server&bits=64&release=latest' –O [output filename]
Alternatively you can install across the network. e.g. select URL and enter a source e.g. http://ftp.uk.debian.org/debian/
Then using XenCenter setup a new VM.
- Install the XenServer Tools on the Guest
In Linux:
cd /mnt
ls
sudo mkdir xs-tools
sudo mount /dev/xvdd /mnt/xs-tools/
#mount: block device /dev/xvdd is write-protected, mounting read-only
cd /mnt/xs-tools/Linux/
bash install.sh
Auto Startup a Virtual Machine
- Get the UUID of the VM:
xe vm-list - Set it to autostart:
xe vm-param-set uuid=[UUID of VM] other-config:auto_poweron=true
Auto Shutdown
I wanted to shutdown the server daily to conserve energy. I found the answer on the Citrix forums here but in case that moves or gets deleted I include a summary here:- Find your Server name and VM names with:
xe vm-shutdown vm=<TAB><TAB>
xe host-shutdown host=<TAB><TAB> - Log in to the server via SSH
Create the script in vi:
vi /usr/local/etc/shutdownscript.sh
Enable insert mode: i - Type:
#!/bin/bash
xe vm-shutdown vm=VMNAME1
xe vm-shutdown vm=VMNAME2
xe host-disable host=HOSTNAME
xe host-shutdown host=HOSTNAME
End insert mode and write the script to disk with:
<ESC>:wq - Make it executable:
chmod 700 /usr/local/etc/shutdownscript.sh - Get cron to start at at 10pm:
crontab –e
Enable insert mode:
:i
Insert the following line:
* 22 * * * /usr/local/etc/shutdownscript.sh
End this edit and write back the crontab with:
<ESC>
:wq - Restart cron:
Great Post, took forever to find a working cifs explanation for /etc/fstab!
ReplyDelete