Posted by Steve on Sun 1 Jan 2006 at 15:46
Xen, the virtualisation system, is a great tool for running fresh copies of an operating system. However it doesn't allow you to run X11 programs. Here we can fix that with the help of VNC.
VNC is the "virtual network computer", a simple tool which allows you to share a graphical display to other hosts. We introduced using VNC to graphically administer remote computers last year.
If we have a virtual installation of Debian running within Xen we can use the VNC server to export the graphical display to all machines upon the LAN - this is perfect for running programs such as Firefox which require a display.
(The other approach is to use X11 forwarding via SSH. That will work nicely for many programs, but if you're wanting an actual desktop it isn't so hot.)
To setup the export of the display is relatively simple. We just need to install the X11 packages upon the virtual instance, and any programs we might wish to run, and then make a minor tweak to export the display.
Upon the virtual image run:
apt-get update apt-get install xserver-xfree86 vncserver xfonts-100dpi xfonts-75dpi xfonts-base rxvt
This will give your instance almost everything it needs. The only things you're missing is a window manager and a login manager. We'll come back to those shortly.
Once the installation has finished you'll be prompted to configure your X server - you may simply select all the default answers. The system should default to a Vesa video server and this is sufficient for our needs.
The next step is to configure a login manager, so far I've tested xdm and gdm and both work nicely. (If you can get kdm to work I'd appreciate a comment with details.)
The login manager is the thing that we'll need to update to export the display via VNC. We'll also need to install a window manager, or desktop manager for to run.
I'm a fan of the simplicity of IceWM, so we'll use that:
apt-get install icewm-experimental
Now we choose the login manager. xdm is simple and basic, gdm has the useful advantage of having a "shutdown" and "reboot" button - so you might prefer that. (No matter if you're not running GNOME!)
XDM SetupGDM SetupXDM setup is very simple, you can install it and configure it to use the VNC server to export its display with:
apt-get install xdm echo ':0 /usr/bin/Xvnc /usr/bin/Xvnc -geometry 1024x768 -depth 24' \ > /usr/X11R6/lib/X11/xdm/XserversOnce this has been done start the manager with:
/etc/init.d/xdm stop /etc/init.d/xdm start
GDM setup is also pretty painless once it has been installed. We just need to make a change to the configuration file /etc/X11/gdm/gdm.conf, and add a new section.
Install gdm as follows:
apt-get install gdmNow we add a new section to end of the configuration file:
cat <<EOF >> /etc/X11/gdm/gdm.conf [server-VNC] name=VNC server command=/usr/bin/Xvnc -geometry 800x600 -depth 24 flexible=true EOFFinally we make that section the active server:
perl -pi.bak -e 's/^0=Standard/0=VNC/g' /etc/X11/gdm/gdm.confOnce this has been done we can restart the server as follows:
/etc/init.d/gdm stop /etc/init.d/gdm start
Once you've setup the login manager you should be able to connect from the host to the virtual server just by running:
xvncviewer xx.xxx.xx.xx
Where xx.xx.xx.xx is the IP address of your virtual server. Login and you should have complete control over the desktop - just as if it were a real machine in front of you.
(If you don't have it installed upon the host already you can fetch it with "apt-get install xvncviewer".)
You might want to experiment with different sizes for the display the defaults shown above of 800x600 can be changed to, say, 1024x768, if you have the screen space for it!
The only obvious drawback of using this approach is that the VNC server may be connected to without any password by anybody upon your LAN.
Firewalling is the order of the day here..
This article can be found online at the Debian Administration website at the following bookmarkable URL (along with associated comments):
This article is copyright 2006 Steve - please ask for permission to republish or translate.