Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Detect OpenVZ & LEB scripts

TigersWayTigersWay Member
edited August 2011 in Help

Hi,

Trying to "improve" or complete some fork of the famous LEB script, I would like to confirm the virtualization system, or at least detect not-true virtualization: OpenVZ. But for now, I can only check on a non-virtualized server, a vmware instance and some openvz vps...

grep envID /proc/self/status should return non-zero envID for OpenVZ and OpenVZ only. Is that correct?

Thanks

Comments

  • maxexcloomaxexcloo Member
    edited August 2011
  • BoltersdriveerBoltersdriveer Member, LIR
    edited August 2011

    On OpenVZ VPS:

    [root@tnm ~]# grep envID /proc/self/status

    envID: 113

    On non-OpenVZ server:

    [root@eclipse ~]# grep envID /proc/self/status

    envID: 0

  • What @maxexcloo said. OpenVZ VPS would have /proc/bc or /proc/user_beancounters set. Just check for their existence.

  • miTgiBmiTgiB Member
    edited August 2011

    LowEndAdmin said: OpenVZ VPS would have /proc/bc or /proc/user_beancounters set

    No longer exists in containers on a CentOS 6 node

    [root@ovz03 ~]# vzctl enter 710
    entered into CT 710
    root@ns101 [/]# cat /proc/bc
    cat: /proc/bc: No such file or directory
    root@ns101 [/]# cat /proc/bean_counters
    cat: /proc/bean_counters: No such file or directory
    root@ns101 [/]# uname -a
    Linux ns101.hostigation.com 2.6.32-042stab031.1 #1 SMP Fri Aug 12 21:20:56 MSD 2011 i686 i686 i386 GNU/Linux
    root@ns101 [/]#
    

    I was wrong, user_beancounters is still there.

    Thanked by 2TigersWay vld
  • In my version of lowendscript https://github.com/Keith2/lowendscript

    I'm creating a conf file, if using OpenVZ is defined here instead of detecting it.

  • @miTgiB -- yeah. I have a Hostigation VPS and /proc/user_beancounters is definitely there :)

    Thanked by 1TigersWay
  • dmmcintyre3dmmcintyre3 Member
    edited August 2011

    grep envID /proc/self/status returns:



    Nothing on a KVM VPS with standard kernel

    envID: 0 on a real server with openvz kernel

    envID: 110 on a VPS on that server.

  • dmmcintyre3 said: Nothing on a KVM VPS with standard kernel

    Yep, and also nothing in a real machine.

  • dmmcintyre3dmmcintyre3 Member
    edited August 2011

    @maxexcloo: your script incorrectly identifies my old laptop as a OpenVZ VPS. (since it's running the OpenVZ kernel, those files exist outside of VPSs too)

  • Any idea's how I could fix that?
    I don't have much of an idea right now :|

  • There are other directories that might be on an OpenVZ. For example /proc/vz. An empty /boot (although it could be easily populated with junks). Also the rootfs is usually mounted as simfs (not always the case though). For example

    grep ' / simfs' /proc/mounts

Sign In or Register to comment.