OpenVZ Forum


Home » Mailing lists » Users » Best way to detect whether I'm in VPS ?
Best way to detect whether I'm in VPS ? [message #11580] Tue, 27 March 2007 17:56 Go to next message
Enrico Weigelt is currently offline  Enrico Weigelt
Messages: 31
Registered: July 2006
Member
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
--
------------------------------------------------------------ ---------
Enrico Weigelt == metux IT service - http://www.metux.de/
------------------------------------------------------------ ---------
Please visit the OpenSource QM Taskforce:
http://wiki.metux.de/public/OpenSource_QM_Taskforce
Patches / Fixes for a lot dozens of packages in dozens of versions:
http://patches.metux.de/
------------------------------------------------------------ ---------
Re: Best way to detect whether I'm in VPS ? [message #11600 is a reply to message #11580] Wed, 28 March 2007 06:39 Go to previous message
dev is currently offline  dev
Messages: 1693
Registered: September 2005
Location: Moscow
Senior Member

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
Previous Topic: Problems w/ busybox's init in VPS
Next Topic: OpenVZ vs. vserver
Goto Forum:
  


Current Time: Sat Apr 27 13:01:02 GMT 2024

Total time taken to generate the page: 0.02379 seconds