OpenVZ On Ubuntu Or Debian

As a SysAdmin I have been using OpenVZ since it was introduced, and trust me it has not always been this easy. I used to take care of 20 physical servers with yearly replacement of about 5 machines. Since some of the servers are running different Linux distributions and different hardware it was decided that to standardize all servers, OpenVZ was to be deployed so that all of them are running Debian stable.

OpenVZ is container-based virtualization for Linux and it only separates the different guest servers in terms of resources. This differ from other implementations such as VMware, Xen, and VirtualBox where these involve hardware virtualization. Because of this, the guests called VE or VPS have the same kernel version and can only run Linux. What distribution as guest? The choice is yours.

Undoubtedly most of you have heard of Virtuozzo – it’s running OpenVZ. As a matter of fact the company that produces Virtuozzo is the one funding and supporting the development of OpenVZ.

The fact that it can run any distribution you like means that you can study and learn how to maintain different distributions. Even the littlest difference can confuse a rookie SysAdmin, for example:

  • Debian apache’s init script is distributed as /etc/init.d/apache and /etc/init.d/apache2 while in CentOS it’s called /etc/init.d/httpd
  • In Debian to change init scripts and runlevels we use update-rc.d while in CentOS we use chkconfig even though they both do the same exact thing

There are many other differences in terms of implementation that I rather not discuss here.

Click on Continue Reading if you’re interested to read more…
Continue reading OpenVZ On Ubuntu Or Debian

innotek VirtualBox

During the course of my daily work, I sometimes need to run multiple OS at once. I used to rely a lot on VMware to run Debian and CentOS on my Windows notebook. The problem with the free VMware server is that it is damn slow, and at startup it takes a few minutes before the VMware authentication service finish working.

One day during a nicotine session my friend Haidir asked me “why don’t you use VirtualBox?”. Oh man! I recall bumping over some articles about VirtualBox in magazines but I guess it slipped my mind.

Starting from that day, bye VMware and hello VirtualBox!

I am surprised on the feel of VirtualBox – it is too light to be a fully functional virtualization product. But it is.

Comparing directly to VMware server (free version) VirtualBox does not introduce any kind of lag at all to my machine. CPU usage never reaches 100% with normal usage of the guest boxes:

VirtualBox running Debian and CentOS

I loooooove the shared folder feature. Sure, you’ll have to compile kernel modules for the virtualbox functions but it’s easy and you can always remove gcc and make later if you want.

A little note about networking, is that when you use only NAT networking with the host you will be able to do a “port forwarding” setup from the host (so that when you access a particular port on the host you are accessing the guest). Look for it in the documentation.


"C:\Program Files\innotek VirtualBox\VBoxManage" setextradata "CentOS" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/CentOSHTTP/Protocol" TCP
"C:\Program Files\innotek VirtualBox\VBoxManage" setextradata "CentOS" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/CentOSHTTP/GuestPort" 80
"C:\Program Files\innotek VirtualBox\VBoxManage" setextradata "CentOS" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/CentOSHTTP/HostPort" 80

In the commands above a port 80 on host is forwarded to port 80 on guest. Cool feature. However I want to demonstrate a hidden problem that might help some of you out there.

On my machine, IIS is running on port 80 (don’t ask me why). Meaning port 80 can’t be used by VirtualBox anymore. This will cause the virtual machine to crash when it tries to activate the network interface:

Virtual Box Crash Port In Use

(I purposely captured along the JIT message, normal users might see a normal Send Error to Microsoft dialog).

VirtualBox will display the virtual machine status as “Aborted”:

VirtualBox Aborted

What you can do next is decide on which port you really want to use on the host. In my case I can simply stop IIS on my host machine if I really want to use port 80.

This is neither a big issue with VirtualBox, nor is a critical defect – it’s just a bit annoying. Perhaps next versions can detect used port before powering on the virtual machine 🙂

But then again, I am using this for my personal work and learn environment. For serious use and production, you might want to consider vm ware hosting for a more reliable solution.

Checking Limits on OpenVZ / Virtuozzo

Do you use virtual server hosting for your websites? It’s commonly known as VPS. Most hosting companies now uses Virtuozzo, a proprietary operating system virtualization product produced by SWsoft, Inc.

The OpenVZ project is an open source community project supported by SWsoft and is intended to provide access to the code and ultimately for the open source community to test, develop and further the OS virtualization effort.

A couple of months ago when I have not tried OpenVZ, a friend asked me about a problem he is facing with his VPS which is hosting streaming videos and receiving millions of hits per day. He received errors such as:

  • cannot fork
  • Error running script: not enough memory
  • Fork failed

Now that I have deep knowledge in OpenVZ I know what causes the problem. The problem is that his running software and services were using resources more than allocated by the hosting company. If you are using such service, one good way to check is by executing this command:

# cat /proc/user_beancounters

The output would look like this:

   uid  resource           held    maxheld    barrier      limit    failcnt
  101:  kmemsize         473318     927071    2752512    2936012          0
        lockedpages           0          0         32         32          0
        privvmpages        1611      62436       4915       5357         40
        shmpages              1         31       8192       8192          0
        dummy                 0          0          0          0          0
        numproc               9         15         65         65          0
        physpages           887      32985          0 2147483647          0
        vmguarpages           0          0       6144 2147483647          0
        oomguarpages        888      32985       6144 2147483647          0
        numtcpsock            0          4         80         80          0
        numflock              1          3        100        110          0
        numpty                1          1         16         16          0
        numsiginfo            0          3        256        256          0
        tcpsndbuf             0       7856     319488     524288          0
        tcprcvbuf             0      95460     319488     524288          0
        othersockbuf       6660       8880     132096     336896          0
        dgramrcvbuf           0       8364     132096     132096          0
        numothersock          5          8         80         80          0
        dcachesize            0          0    1048576    1097728          0
        numfile             168        399       2048       2048          0
        dummy                 0          0          0          0          0
        dummy                 0          0          0          0          0
        dummy                 0          0          0          0          0
        numiptent            10         10        128        128          0

These info are important because it is most likely that you can’t see what configurations your VPS is running with.

Simple meanings of the columns:

  • resource – name of the resource
  • held – current usage
  • maxheld – max ever used
  • barrier – soft limit of the resource
  • limit – hard limit where the VPS will never use more
  • failcnt – fail count

The most important thing to see is the failcnt column, where in an ideal situation you should see only zeros. In this case, you see that privvmpages have failed 40 times because I on purposely lowered the memory allocated for the VPS and run some programs.

You will never be able to change the resource allocation from within the VPS but at least you know what your problem is and is a good point of discussion with the hosting company.

And oh yes, the values are in 4k blocks which means that if the setting is 4915 the actual value is 19660k (4915 * 4k). Of course this is only applicable for some, and not for countable values such as numpty.

Good luck!