How to tell when running virtualized? SOLVED

This is for discussing general topics about how to use VirtualBox.
Post Reply
alterkacker
Posts: 2
Joined: 25. Nov 2009, 01:33
Primary OS: MS Windows XP
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, Linux

How to tell when running virtualized? SOLVED

Post by alterkacker »

I have Ubuntu installed natively on my hard drive, and would like to run it either natively or hosted in VBox under Windows using a raw hard disk. I have it working mostly just fine, but would like to find a way for the the Ubuntu guest to be able to determine whether it's running hosted or natively at boot time. I've seen the 'guestproperty' settings but that's only available once the VM is running. I know I could use two different sections in the Grub menu.lst file and pass some keyword on the boot line, but I'd like it to be automatic. Ideas?

Thanks!

BTW, I just switched to VirtualBox from VMWare and love it! It's amazing that software of this quality is available for free.
Last edited by alterkacker on 25. Nov 2009, 03:24, edited 1 time in total.
MarkCranness
Volunteer
Posts: 875
Joined: 10. Oct 2009, 06:27
Primary OS: MS Windows 7
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows Server 2008 R2; Ubuntu 11.04; Windows 2000 Server; Windows XP

Re: How to tell when running virtualized?

Post by MarkCranness »

You might find the source for dmidecode (assuming it is open source) and see how they query the DMI BIOS settings. Then check the returned value for a VirtualBox specific string. Or pipe the output of dmidecode into some sort of shell search (grep?)
alterkacker
Posts: 2
Joined: 25. Nov 2009, 01:33
Primary OS: MS Windows XP
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, Linux

Re: How to tell when running virtualized?

Post by alterkacker »

Perfect, Mark!

When running native:
dmidecode -s bios-vendor > Dell Inc.

When running under VBox:
dmidecode -s bios-vendor > innotek GmbH

So a simple grep will tell me what I want. Thanks, I don't know if I ever would have thought of that.
Post Reply