December 17, 2014, 09:31:54 PM

News : LinuxSolved.com Linux Help Community Forum..


Author Topic: Runtime identification of virtualized environment  (Read 1108 times)

Offline velusamyg

  • New Member
  • Posts: 1
Runtime identification of virtualized environment
« on: January 05, 2012, 11:00:31 AM »
I am a new to Linux/ Virtual Box. I am writing an application which is supposed be run on Virtualized env and also on standalone linux machines and the app is supposed to do different task based on the environment .

I would like to identify on runtime, if my app is running on virtualized env (Virtual Box with guest OS as ubuntu and host OS as windows) OR if the app is running on standalone Linux (ubuntu) machine.

Is there any env / config file within the ubuntu OS which will tell me the details required.

Initially i considered, differentiation based on VBoxGuestAddition installable can help, but guestAddition installation is not mandatory on all VBox machine.

Is there any alternate way for this identification.

I am looking for some command or some unique file which will tell that my application is running in virtual box or not.

Any help in this regard will be very helpful.

Thanks,

Offline gauravbajaj

  • LST CareTaker
  • Experienced
  • *****
  • Posts: 658
Re: Runtime identification of virtualized environment
« Reply #1 on: January 05, 2012, 07:32:51 PM »
Are you using sun ( now oracle) owned virtualbox?

I dont know much abt it as I never worked on "Virtualbox" but i did work on other virtualization technologies like OVM and vmware.

Every OS/machine which is running on virtualized env( HVM or PVHVM) use some virtualized drivers to run on top of physical hardware.

If its running virtualized env then try checking the virtualized NIC/Disk drivers by running following.
1. Check /etc/modprobe.conf ( for modules) ...
2. Check dmesg ( grep for specific virtual modules), I think the module name is "vboxdrv" - not sure
3. try lsmod | grep -i vbox or lsmod| grep -i vboxdrv

If, the box is running on virtualized env , it should display the modules. If not then it means its not the virtual box  but the physical one.