1

Is there a way to tell whether a host is a physical one or a VM and which virtual container it is running out of (e.g. VirtualBox or VMWare)? I was wondering if that info may be in /etc some place.

amphibient
  • 12,472
  • 18
  • 64
  • 88

2 Answers2

1

you can install the facter package, and then

facter virtual

will tell you if it is a virtual.

or you can use dmidecode to examine your system. look for Product Name in the output.

johnshen64
  • 516
  • 2
  • 4
  • I did run facter on my machine and I get facter virtual vmware_server

    But this is a real ubuntu machine. I do have a vmware machine turned off here. Am I missunderstanding the usage of facter?

    – vfbsilva Aug 21 '13 at 14:53
  • yeah in this case, it is telling you that it is a virtual machine host (not a vm, which will just say vmware). what is the Product Name if you run dmidecode? In my experience, dmidecode is more intuitive to understand. – johnshen64 Aug 21 '13 at 14:56
  • yes, it worked on my Ubuntu VM – amphibient Aug 21 '13 at 14:57
  • @johnshen64 no idea: dmidecode | grep product returns empty – vfbsilva Aug 21 '13 at 14:59
  • use grep -i, as you are using difference cases than the string that I listed. thanks! – johnshen64 Aug 21 '13 at 15:03
  • @johnshen64 what does it mean? Product Name: POS-MIG31AE Product Name: POS-MIG31AE – vfbsilva Aug 21 '13 at 15:05
  • that is a physical machine and what you see is the motherboard name: http://browser.primatelabs.com/geekbench2/1021447, you would see something like virtual or vmware etc. if it were a vm. – johnshen64 Aug 21 '13 at 15:17
1

There is usually no information in /etc that you can use to detect if the host is running as a VM.

But you can look at the hardware in /proc and /sys or (better) use tools like lspci.

The easiest way, however, is to use imvirt, which does exactly what you need. It supports lots of different VMs. At least in Debian-based distributions you can install it via the package manager.

jofel
  • 26,758