Is there any way to tell if the host that a script is running on is a VirtualBox guest VM? Ideally I'm looking for a cross-platform way. I would think this is next to impossible unless, maybe, something in the Guest Additions provides this.

link|improve this question

57% accept rate
feedback

2 Answers

up vote 2 down vote accepted

Did some poking around and under Linux, dmidecode | less produces:

# dmidecode 2.10
SMBIOS 2.5 present.
5 structures occupying 256 bytes.
Table at 0x000E1000.

Handle 0x0000, DMI type 0, 20 bytes
BIOS Information
        Vendor: innotek GmbH
        Version: VirtualBox

And the Windows equivalent (thanks to Andrew Koester for the pointer)

C:\> wmic bios get smbiosbiosversion
SMBIOSBIOSVersion
VirtualBox

There is a Solaris equivalent, but I can't test it because I only have access to Sparc machines. But, for completeness, here it is: /usr/sbin/smbios

link|improve this answer
feedback

In Windows, you can query for the BIOS information with WMI. http://msdn.microsoft.com/en-us/library/aa394077%28VS.85%29.aspx

I don't believe you're going to find a cross-platform solution, at least without going all the way down and reading it directly out of low-level memory. (In this case, you might be interested in the source code to dmidecode)

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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