UPWORK superadmin blog

Tips and Tricks for clients

Detecting OpenVZ environment

without comments

Reliably detecting if there is an OpenVZ Environment is pretty easy:

Just check for existance of /proc/user_beancounters.

But this will only tell you that OpenVZ is there. It won’t tell you, if you are inside an unprivileged Virtual Environment (VE) or on the privileged Hardware Node (HN or VE0).
Still an easy check:

Read /proc/$PID/status and check for “envID: $VEID”. $VEID will be 0 for the Hardware Node (hence the VE0 name). If it’s greater than 0, you are inside an unprivileged VE.

Facter 1.5.3 will probably have support for this.

Written by spectre

July 18th, 2012 at 4:08 pm

Posted in Tips and Tricks

Leave a Reply