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.
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
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
I use the code on line #260 here: https://github.com/maxexcloo/Minimal/blob/master/minimal.sh
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.No longer exists in containers on a CentOS 6 node
I was wrong, user_beancounters is still there.
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 theregrep 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.
Yep, and also nothing in a real machine.
@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 examplegrep ' / simfs' /proc/mounts