Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there any way to find out if the OS I'm running (actually installing) is running in a VMWare machine. I need to disable ntp settings if the automated install is done on a virtual machine but keep them enabled if installing on bare metal.

share|improve this question

8 Answers 8

The best idea would probably to look at the hardware. At least with VirtualBox you can easily determine that you are on a virtual machine, due to the names of some of the hardware devices (for example /sys/block/sda/device/model will say "VBOX HARDDISK").

Since all your machines are VMware, just pick one of those things and check that.

share|improve this answer
1  
that will work if i'm only using virtual harddrives. –  ulve Nov 2 '10 at 7:07
    
The Harddisk was just an example, check for other devices, maybe the harddisk controller or the graphics card (I don't have vmware here so I cannot check) –  tante Nov 2 '10 at 8:25
up vote 5 down vote accepted

Using dmidecode or lshw and greping seems to be to be the best way to find out.

share|improve this answer

Linux adds the hypervisor flag to /proc/cpuinfo if the kernel detects running on some sort of a hypervisor.

share|improve this answer

If all you need is a way to tell whether the OS/host is a virtualized host or not, just you have a perl module Sys::Detect::Virtualization and the script with it virtdetect. It does all the possible heuristics/guess detections and reports the detected OS environment. Give it a try.

http://search.cpan.org/dist/Sys-Detect-Virtualization/script/virtdetect

share|improve this answer

You could try Joanna Rutkowska's Red Pill This little program examines the IDTR (interrupt descriptor table register) using the SIDT instruction (x86 only), which apparently will be set differently by different VMMs.

share|improve this answer

well, the most intuitive way I always do is:

$ dmesg | grep -i vmware

share|improve this answer
    
nice - this works on virtual box: dmesg | grep -i vbox - ACPI: RSDP 000e0000 00024 (v02 VBOX ) –  Danny Staple May 9 '13 at 14:40

On Linux you can use the command virt-what

[root@myhost]# virt-what
vmware
share|improve this answer

Run:

$ dmesg |grep -i hypervisor
Hypervisor detected: KVM
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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