Check Virtualization type for a running Linux

Are you running VPS as a hosting solution? And do you want to know what kind of virtualization is it running on? Is it OpenVZ, V-server, Xen or UML, and how can I confirm this?
Since the hosting providers normally do not tell you these kind of detailed info, here we created a simple script:

# Check what kind of virtual machine for a running Linux. It supports (openvz/vserver/xen/uml).
# Please copy & save this script and run it as root.
# By Joseph Chen <> 2011-12-10

import sys, os
import re

def main():
    if os.getuid() != 0:
        print "It must be run as root"

    # Check OpenVZ/Virtuozzo
    if os.path.exists("/proc/vz"):
        if not os.path.exists("/proc/bc"):
            print "openvz container"
            print "openvz node"

    # Check V-server
    if os.path.exists("/proc/self/status"):
	s = open("/proc/self/status", "r")
	txt =

        reobj = re.compile(r"^(s_context|VxID):[[:blank:]]*[0-9]/")
        if reobj.match (txt):
            if os.path.exists("/proc/virtual"):
                print "vserver_host"
                print "vserver"

    # Check Xen
    if os.path.exists("/proc/xen/capabilities"):

	f = open("/proc/xen/capabilities", "r")
	text =

        if (len(text) > 0):
            print "xen dom0"
            print "xen domU"

    # Check User Mode Linux (UML)
    f = open("/proc/cpuinfo", "r"); t =; f.close()
    if (t.find("UML") > 0):
        print "uml"

if __name__=="__main__":

Here is a running example on a Xen dom0 node:

root@pekdev230:~ # python 
xen dom0

Note that, the check for vserver may not work since I didn’t get an environment for testing. Sorry about that, but if you any updates, please kindly let me know.

Share this post

Post Comment