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?

1
  • 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. Aug 4, 2015 at 14:14

5 Answers 5

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.

1
  • 1
    Only since RHEL 5.7, just a side-note.
    – mveroone
    Jan 9, 2014 at 9:17
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.

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.
    
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.

-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.".

1
  • Any examples, i dont know much about virtualization
    – AabinGunz
    Nov 21, 2011 at 9:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .