Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there any way for me to identify which OpenVZ container I am in, from inside the container? I am working on a setup where OpenVZ machines shall boot the same (read-only) disk image, so I can not configure them individually in the file system. I need a unique identification for each of the virtual servers, to be used by scripts running inside the OpenVZ containers.

(I'm running Debian Lenny, BTW.)

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

Every container in an OpenVZ host has a unique Container ID, also known as its VEID. From within a container, you should be able to read its VEID like this:

awk '{print $1}' /proc/vz/veinfo

This ID should be constant for a given container, since it is associated with the container's .conf file that configures it for OpenVZ.

share|improve this answer
add comment

My first idea would be that you can use the IP or MAC address of each VM to differentiate them and pass that value to your scripts.

share|improve this answer
    
Thank you for answer! HWaddr always looks loke this in the OpenVZ containers: "00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00". The unique identifier will be used to configure networking (and other init.d stuff prior networking is configured), so in my situation, IP address will not work neither. :( –  Alfred Godoy Apr 15 '12 at 23:00
    
Another tought, the Hard drive is supposed to have a uuid field which should be different for each VM, but in any case you can get the IP first and then use that to personalize each container later. –  jhcaiced Apr 15 '12 at 23:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.