I am using a rather ancient version of the Xen kernel because I am short of time at the moment and this is something I have worked with before. But hopefully, I should be able to get the same thing done on a more recent Xen kernel soon.
So to install a new domain from the command line, do:
sudo xen-create-image --hostname=xen_7 --size=1Gb --swap=256Mb --ide --ip=10.5.155.7 --netmask=255.255.240.0 --gateway=10.5.159.255 --force --dir=/home/xen --memory=256Mb --arch=i386 --kernel=/boot/vmlinuz-2.6.24-16-xen --initrd=/boot/initrd.img-2.6.24-16-xen --install-method=debootstrap --dist=hardy --mirror=http://archive.ubuntu.com/ubuntu/
Most of the parameters are self-explanatory. I am using static IP address (
10.5.155.7
) on my VM. The kernel (vmlinuz-2.6.24-16-xen
) and the initial ram disk (initrd.img-2.6.24-16-xen
) should be present in your boot
directory. Ususally the gateway
parameter and the netmask
parameter would be the same for your Domain-0 and user domains. To see how much memory is available for the new domain that you are creating use the df
or free
commands before hand.Once the new domain has been created you will see a new configuration file in the
/etc/xen/
directory. This file needs to be edited a little bit as follows:# Configuration file for the Xen instance xen_7, created
# by xen-tools 3.8 on Thu Sep 2 19:12:55 2010.
#
#
# Kernel + memory size
#
kernel = '/boot/vmlinuz-2.6.24-16-xen'
ramdisk = '/boot/initrd.img-2.6.24-16-xen'
memory = '256'
vcpu = '2'
#
# Disk device(s).
#
root = '/dev/hda2 ro'
disk = [
'tap:aio:/home/xen/domains/xen_7/swap.img,hda1,w',
'tap:aio:/home/xen/domains/xen_7/disk.img,hda2,w',
The text in red shows the text that has been changed/added. The
vcpu
parameter can be used if your want your domain to have more than one virtual processor. Later when your machine has booted you can check that this is indeed the case from the /proc/cpuinfo
file.So now we are all set to boot up our machine. In the Domain-0 terminal, type:
On the client machine, do
sudo xm create /etc/xen/xen_7.cfg
You could monitor the booting up and working of your new domain from Domain-0 using xentop
and sudo xm list
To access your machine, use: sudo xm console xen_7
Login as root
and set your new password using passwd
command. If the network on your new domain is not functioning for some reason, look at this post for possible ways to correct the problem.So at this point you have a functioning domain that you can access via the terminal. But now we want to get GUI access using tightVNC. To do this, a truck load of software needs to be installed. I have used the
dpkg --get-selections
option to generate a list of all the software that I needed on my machine. Use the dpkg --set-selection
command followed by dselect
(Select the "install" option on the interface opened by dselect
) to install all the packages in the list.Now the client/remote machine from which you want to access the graphical user interface of your domains needs to have VNCviewer (
sudo apt-get install vncviewer
) installed. On the host (guest domain) terminal, do:
Xvfb :0 -screen 0 800x600x16 &
export DISPLAY=:0
x11vnc -display :0&
xterm&
You can check that the Xvfb
and xterm
processes have started from the list of running processes. (ps uax)
On the client machine, do
vncviewer 10.5.155.6:0
. You should see the GUI interface at this point. To test that the graphics are working, try: glxgears
Well, that's it! You should see an animation of a bunch of gears rotating on your screen.... Which means that you have a GUI access to your machine!