We currently migrate to MediaWiki from our old installation, but not all content has been migrated yet. Take a look at the Wiki Team page for instructions how to help or browse through our new wiki at wiki.linux-vserver.org to find the information already migrated.

This page has been made to answer the questions related to running X ( XFree86 and XOrg ) in a Vserver.

Due to the wierdness in the ways that X uses it's terminology,

There are two main things you might want to do relating to X:

- Run an X server on the physical machine that the Vserver is running on, and log in on the local keyboard, mouse, and monitor.

- Connect from an Xserver on a different machine, and log into a desktop remotely on the Vserver.

Running an X server inside a vserver

Allow capability CAP_SYS_RAWIO. It can be set in the capabilities file or the vserver config depending on your util-vserver.
Set up a mouse device, such as /dev/psaux or /dev/input/mice
Set up a vc/tty device, such as /dev/tty7 or /dev/vc/7 (major 4, minor same as device). If you are running a main X server you might need to use 8 or 9 for the vc/tty device
Set up /dev/kmem (not 100% sure this is needed, don't think X has to have it to run) (note: Xorg on debian sid require a /dev/mem -- NebuchadnezzaR?)
Now just switch to a console, log in as root, enter your vserver and startx, a caveat on newer versions of vserver when switching between a vserver X server and the main server's X server you need to switch :to a console first or you can lose access to the main server's X server.
You'll also need pts/pty devices to run things like xterm, but if you have ssh set up you probably already have them.

All the stuff below is written from memory - I don't have access to the machine I did this on right now, so I'll have to come back later, and fill in the blanks.

Running an X session on a vserver

For this, you don't need to assign any special capabilities to the vserver, as "X" itself won't be running in the vserver - it will be running on the machine that you want the display from the vserver to appear on.
In the Vserver:
- Install the xdm package - this is the process that listens on udp/177 for XMDCP requests. You can also use kdm, the package that comes with KDE, or gdm, for Gnome.
- Install your desktop of choice. I used KDE.
- Comment out the local X server in /etc/X11*/?dm/Xservers (TODO: check this path)
- Set ListenXDMCP?=false to true in /etc/kde/.../kdmrc (TODO: check this path)
Make sure that the you can run [xkg]dm in the vserver. [xkd]dm logs to /var/log, and you can run it with higher debug levels from the command line to work out any problems. Most distros will have an init script to run this.
netstat -plnu | grep :177 should show your ?dm running on udp/177.
Problems I encountered:
If your ?dm starts, and exits without any errors, this may mean that your greeter program isn't working or installed.
I had to change /etc/kde/kdm/kdm-config and add the line: LISTEN 82.x.y.z to make it run on udp/177.
My konsole program didn't start properly - this was due to /dev/ptmx not being writable by my user - chmod 666 /dev/ptmx as root solved this.
Test it by running X -query w.x.y.z :2 on a remote machine (not the vserver).