5

I have a set of machines and want to know how to find out if a given machine is virtualized or not. Any commands?

1
  • 2
    Do you know what kind of virtualization technology they would be running on?
    – Chris S
    Jun 21, 2010 at 12:40

9 Answers 9

4

If Solaris is running in a container/zone/branded zone, the command "uname -v" will say "Generic_Virtual"

4

It may depend on the virtualization used, but if you are using the "Oracle VM for SPARC" (previously known as LDOMs) the "virtinfo" tool (in the core SUNcsu package) provides the information you're after.

For example:

user@server1> virtinfo
Domain role: LDoms control I/O service root

user@server2> virtinfo
Domain role: LDoms guest

user@zone > virtinfo

virtinfo can only be run from the global zone

user@M4000 > virtinfo
Virtual machines are not supported

user@x3650 > virtinfo
command not found

Be aware that this command's Interface Stability is classified as "Uncommited" and might be subject to modifications to the next minor release.

3

For zones Only:

Top of the heap

[ "`/usr/bin/zonename`" = 'global' ] && echo "im global"

In a zone

[ ! "`/usr/bin/zonename`" = 'global' ] && echo "im in a zone"

More general purpose

If you want something more full-featured, something like this (please help with edits/feedback/flames for other hypervisors; and yes, currently many edge-cases)....

/usr/sbin/prtconf -dv | /usr/bin/egrep -i '(vmw|qemu|xen|hyper-v|openvz|virtualbox|oracle vm|parallels|virtuoso)' >/dev/null

Credit: http://compgroups.net/comp.unix.solaris/how-to-detect-if-solaris-is-running-as-a-gu/281238

1
  • This doesn't [appear to] work for Solaris 10 (and earlier?) running as a guest using Oracle's "ldom" stuff. prtconf -d isn't a valid option. The closest I see is prtconf -bpv but I don't see what I would expect to see. Nevertheless, it's useful so +1. Oct 7, 2017 at 20:07
2

use the prtdiag command. If you are in a zone you can see the error message prtdiag can only buy run in the global zone

if the command works you are in a real machine (real or ldom)

1

Does Solaris have something like lspci or /proc/cpuinfo?

Here are some examples of how other tools solve the detection:

http://github.com/reductivelabs/facter/blob/master/lib/facter/util/virtual.rb

http://imvirt.svn.sourceforge.net/viewvc/imvirt/trunk/perl/lib/ImVirt/VMD/

2
  • On my KVM Solaris 10 VM, facter gets the "virtual" fact totally wrong. It does report manufacturer and productname as "Bochs", not sure how reliable that is.
    – Not Now
    Oct 12, 2011 at 0:23
  • prtconf -dv ... see also answer of yours truly.
    – user31170
    Oct 16, 2012 at 1:49
1

There is no single way to figure out if you are running a virtualized Solaris or not. Solaris can run on various kinds of containers (native or branded zones) regardless of the architecture. On x86/x64, Solaris can also run at least on top of VirtualBox, VMware, Xen, Parallels and probably several more. On SPARC, LDOMs on T series and Physical domains on M series

1

Have a look at this Perl library: http://search.cpan.org/~doneill/Sys-Detect-Virtualization-0.105/lib/Sys/Detect/Virtualization.pm

If you want to dive into the assembly way of detecting it: http://talhatariq.wordpress.com/2006/05/14/detecting-virtualization-2/

And this overview of things to look for when doing it manually: http://www.dmo.ca/blog/detecting-virtualization-on-linux/ .

HTH

0

psrinfo will give you some answers about your processor:

$ psrinfo -v
Status of virtual processor 0 as of: 07/09/10 10:41:32
  on-line since 06/01/04 13:30:59.
  The sparcv9 processor operates at 1002 MHz,
        and has a sparcv9 floating point processor.

Check out this link, it may give you more informations.

2
  • 1
    Most hypervisors pass the CPU through directly to the VM, so it would report a normal processor either way.
    – Chris S
    Jul 12, 2010 at 22:19
  • damn! solaris is a bit new to me, and I though this could help...
    – petrus
    Jul 12, 2010 at 22:30
-2

The cfgadm command works on all Solaris systems EXCEPT non-global Zones:

cfgadm > /dev/null 2>&1

if [ $? -ne 0 ]; then
#cfgadm command failed, must be a non-global zone:
echo "This is a non-global zone".
fi

You must log in to answer this question.

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