3

I have Linux, AIX, SunOs & HP-UX machines, I want to detect if the machine is virtual or not. So far I found this article which helped me get this information on Linux:

dmesg | grep -i virtual    //On Linux Machines

But I also need commands for AIX, HP-UX & SunOs. Any help?

Bart De Vos
  • 17,761
  • 6
  • 62
  • 81
AabinGunz
  • 131
  • 1
  • 5
  • That `dmesg` Linux trick only works if the kernel buffer that holds `dmesg` messages hasn't been overwritten by more recent messages. If you do any kind of `iptables` logging, those log messages will wipe out your `dmesg` boot messages fairly quickly. Some systems save the initial `dmesg` output under `/var/log/` and you might find it there. – Ian D. Allen Aug 04 '15 at 14:14

5 Answers5

3

Try http://people.redhat.com/~rjones/virt-what/. Correct me if I'm mistaken, but I think Red Hat uses this in their Satellite to detect and group virtualized systems.

weeheavy
  • 4,039
  • 1
  • 27
  • 41
2

The definition of 'virtual' is too loose. If we assume that for AIX you mean any AIX image which is an LPAR (or a micro-partition, or any other terminology IBM chooses) then you can use uname -L, for example,

nonlpar# umame -L
-1 NULL

lparhost# uname -L
5 lparhost

If you mean WPAR, you can use uname -W and a result of 0 means you're not in a WPAR, a result of anything higher than 0 is a WPAR.

If you mean, does the AIX instance rely on a VIO server, then there's no solid reliable mechanism for knowing that other than looking at the devices and working out if they're presented via VIO servers.

It's worth remembering that for pSeries hardware running AIX, just about everything these days is an LPAR, and so essentially virtual, even if it's the only OS instance using the hardware.

EightBitTony
  • 9,211
  • 1
  • 32
  • 46
1

In HP-UX there are different level of virtualization and different command to know if your system is virtualized.

  1. Integrity Virtual Machine Guest

    If you execute the following command in a IVM Guest you obtain:

     # hpvminfo 
     hpvminfo: Running inside an HPVM guest.
    

    If you execute the following command in a NO "IVM Guest" you obtain:

     # hpvminfo 
     hpvminfo: Running inside an HPVM host.
    

    or # hpvminfo sh: hpvminfo: not found.

  2. HP Virtual Partition

    If you execute the following command in a vpar you obtain:

     # hpvminfo 
     hpvminfo: Running inside an HPVM guest.
     # vparstatus -w
     The current virtual partition is <VPAR NAME>.
    

    If you execute the following command in a NO vpar you obtain:

     # vparstatus 
     sh: vparstatus:  not found.
    
NoNoNo
  • 1,939
  • 14
  • 19
0

Is it possible that virtual machines produce "fishy" cpu info?

In Aix try using lscfg on a known virtual machine and you may be able to find that the CPU information hints that the computer is virtual. This will largely contingent on the virtualizer, but its worth a go.

Mikhail
  • 204
  • 2
  • 12
-1

For an x86 virtual machine, simply run a program that invokes the official mechanisms for detecting x86 virtual machines. I'd provide examples, but I don't know any off the top of my head. I use my own tools. Thomas Liske's imvirt shows promise according to its doco, but I haven't used it or seen the source code.

Whether this also applies to your SunOS machines depends from whether that is x86 Solaris or truly SunOS. ☺ Detecting the existence of a virtual machine involves stuff that is specific to the processor instruction set architecture, not to the operating system. So "I have AIX and HP/UX machines." is less useful than, say, "I have PowerPC and Itanium machines.".

JdeBP
  • 3,970
  • 17
  • 17