X server with sound inside an OpenVZ / Proxmox container

Mike Green
Aug 24, 2009 · 5 min read

Generally when using X-based applications inside an OpenVZ or Proxmox container, the host node will run the X server and the container will use X forwarding through SSH to run the application. An article at the Open VZ Wiki explains this in more detail.

However, I wanted to have an X server inside the container itself. Moreover, it should also have support for sound (ALSA). The reason behind this is to have a container capable of running FreeSWITCH (a high performance VoIP switch similar to Asterisk) with the Skypiax trunk (for Skype connectivity) fully independent.

There are various methods of implementing the X server inside an OpenVZ or Proxmox container, especially if no direct video output is required. However, there is very little information available on how to enable sound inside an OpenVZ or Proxmox container. This article will explain how to do this.

Preparing the host node

The host node requires the proper sound modules installed. For example, on a server that does not require actual output through attached speakers, snd_dummy is sufficient. Enter the following command to load the snd_dummy module:

You can verify if everything went well with:

Which will display an output similar to:

If this is the case, then you’d want to make sure the snd_dummy will be loaded at boot time. Simply issue the following command:

Preparing the container

Setting device privileges

The next step is preparing the OpenVZ or Proxmox container. By default, the container does not have access privileges to the sound device, so this needs to be setup from the host node (assuming “100” is the actual container ID):

Cloning the sound devices

The following step involves recreating the /dev/snd layout from the host node in the container. Let’s first see what the layout looks like on the host node:

This will give an output similar to:

It is important that the same device IDs are being recreated in the container. I.e., the device ID for seq is 116,3 in the above example.

Enter the container and start and issue the following commands, depending on the output given on the host node:

At this point you have cloned copy of the host node’s sound devices and are ready to be used.

Please note that the application that wishes to use the sound devices require the proper privileges. The easiest method is to add the UID to the audio group. For example, if Skype runs under uid “skype”, issue this command:

Installing Xorg Server

There are various X server variants that can be installed in the container, especially if no video output is required. The most popular one is undoubtedly Xvfb.

I have opted for using the Xorg Server with a dummy video, mouse and keyboard driver instead (as this was dedicated server without any of these devices). This section details how I have installed it on Debian-based distributions.

Prior to installation

First step, inside a container, is to soft-link TTY1 to TTY0:

This assumes you are accessing the container using vzctl, not SSH !

If nscd is installed, remove this first:

Download and install packages

Next we install the required packages for Xorg and some device drivers, incuding ALSA for sound support:

Edit the configuration

The last step is configuring Xorg, by editing the /etc/X11/xorg.conf file as following:

Section "Device"
Identifier "Dummy Video"
Driver "dummy"
Section "Monitor"
Identifier "Configured Monitor"
Section "Screen"
Identifier "Default Screen"
Monitor "Configured Monitor"
Device "Dummy Video"
Section "ServerLayout"
Identifier "Default Layout"
Screen "Default Screen"
InputDevice "Dummy Input"

You can now start X instances using:

where <DISPLAY#> is the display to be used (without the brackets, or omit entirely for default settings). X-based applications will now be able to run on any of these displays. For example, to run Skype (for Skypiax) on a specific display and under UID “skype”:

Remote access using Nomachine NX

Even though you are using a virtual framebuffer (such as with Xvfb) or dummy video driver, you will still be able to do visual tasks on the server. One method is to use an X forwarding tunnel (ssh -X). I prefer to use Nomachine’s NX server instead.

To install the Nomachine NX server on a Debian-based distribution, issue the following command:

This assumes you are running a 32-bits version of Linux and the versions listed above are still correct. Please verify this at Nomachine’s website and change as appropriate before issuing the command.

Now you are ready to connect to your Xorg server using Nomachine’s NX Client and do visual tasks (ie., browse the internet if a browser is installed).


Myatu’s Tech Blog, from the site that has been wasting bits…

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store