Difference between revisions of "Vservers and X"

From Linux-VServer

Jump to: navigation, search
(migrated from old wiki)
 
(+cat)
Line 51: Line 51:
 
* verify with ping myhost.mydomain.com that the resolving works  
 
* verify with ping myhost.mydomain.com that the resolving works  
 
* start whatever X app you ahve installed (e.g. xeyes, xlogo, xterm ...)
 
* start whatever X app you ahve installed (e.g. xeyes, xlogo, xterm ...)
 +
 +
[[Category:Documentation]]

Revision as of 20:02, 21 October 2011

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

There are a few things you might want to do relating to X:

  1. Run an X server on the physical machine that the Vserver is running on, and log in on the keyboard, mouse, and monitor that are connected to the hardware the host and vserver run on.
  2. Connect from an Xserver on a different machine, and log into a desktop that is running on the Vserver.
  3. Run an X server on the host and connect to the vserver (I haven't tried this, but I can't imagine that there would be any problems - this should be pretty much the same as option 2. However, you would need to make sure that running the X server on the host didn't create any security concerns - -nolisten tcp should be used for example.)
  4. Simply forward X via SSH

Contents

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.

Note: 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 the vserver won't be running an X server. It will run an Xsession back to your local X server.

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 - if you don't do this, X will try to start and will fail - you will get IOPerm errors in /var/log/Xorg.1.log, and it may stop your display manager from starting. (TODO: check this path)
  • Set ListenXDMCP? to true in /etc/kde/.../kdmrc (TODO: check this path)
  • Add the line: LISTEN 82.x.y.z to your DM config file (/etc/kde/kdm/kdm-config ? <- TODO: Check this).

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 from startup.

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.
  • 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). You should get a grey screen, followed by the login manager for KDE/Gnome/X.

SSH Forwarding X

Using ssh X forwarding to get the gui of the apps you want.

  • first make sure your guest has an ip and a hostname.
  • install open-ssh server onto the guest.
  • edit the file /etc/ssh/sshd_config to include X11UseLocalhost no
  • restart the ssh server and make sure that you can logon
  • ssh into the guest with 'ssh -X'
  • if you can't ssh into the vserver check that your own ssh server is not interfering. if so bind it to your ip.
  • check the DISPLAY env. var, it should show you soemthing like myhost.mydomain.com:10.0
  • make sure that myhost.mydomain.com resolves to the guest IP
  • either configure it via DNS or just add it to /etc/hosts like this:

192.168.0.1 myhost.mydomain.com

  • verify with ping myhost.mydomain.com that the resolving works
  • start whatever X app you ahve installed (e.g. xeyes, xlogo, xterm ...)
Personal tools