[Users] Best way to detect whether I'm in VPS ?

Kirill Korotaev dev at sw.ru
Wed Mar 28 02:50:08 EDT 2007


In .c or in shell?

in shell:
- yes, /proc (.e.g `grep envID /proc/self/status` should return non-zero envID)
- /etc/fstab, /etc/mtab - i.e. disk partitions.
- pids... it is not guaranteed to work in future, but currently
  all VE pids have one property:
  (getpid() & 1024) == 1024
- empty dmesg on bootup
- others...

all this except for /proc are not guaranteed to work in future.

Thanks,
Kirill

> Hi folks,
> 
> 
> which is the best way for detecting whether I'm in an VPS while 
> n the boot process ?
> 
> One way could be checking for some special files in /proc
> (ie. beancountes), but this requires /proc to be already mounted.
> 
> Is there another way (maybe w/o /proc) ?
> 
> 
> thx



More information about the Users mailing list