The whole world is moving towards virtualization. Unless you maintain the inventory on CMDB , it is very difficult to find the server location and configuration. The hyper-visors like VMware vSphere, Microsoft Hyper-V, Xen and KVM supports Linux as virtual machine. If you have the proper CMDB for the virtual machine, you can easily find the hyper-visor for the VM and its location. Otherwise, you need to struggle little bit. Here we will examine such a scenario for Redhat Enterprise Linux 7 VM.
1. How to find the whether the system is physical machine or VM ?
Execute command called “virt-what” to know whether you are in physical machine or virtual machine .
[root@foundation1 ~]# virt-what [root@foundation1 ~]# [root@server1-UA ~]#echo $? 0 [root@server1-UA ~]#
If nothing is printed and the script exits with code 0 (no error), then it can mean either that the program is running on bare-metal or the program is running inside a type of virtual machine which we don’t know about or cannot detect.
2.If the system is virtual machine ,you will get the hyper-visor name like below.
[root@foundation1 ~]# virt-what vmware [root@foundation1 ~]#
The above output shows that VM is running on top of VMware hyper-visors. It can be vmware ESXi or VMware workstation/Fusion
3.If the host is running on top of Linux machine using KVM, you will get the output like below.
[root@server1-UA ~]#virt-what kvm [root@server1-UA ~]#
4.Xen virtual machines will display like below.
[root@server1-UA ~]# virt-what xen xen-domU [root@server1-UA ~]#
virt-what is a shell script which can be used to detect if the program is running in a virtual machine or not. virt-what supports a very large number of different hypervisor types, including common open source hypervisors (KVM, Xen, QEMU, VirtualBox), mainframe systems like IBM Systemz, LPAR, z/VM, hardware partitioning schemes like Hitachi Virtage, proprietary hypervisors like VMWare, Microsoft Hyper-V.
virt-what is already packaged in Fedora (13+), Red Hat Enterprise Linux (5.7+ and 6.1+), Debian, Ubuntu, ArchLinux and Gentoo. If you don’t have the utility , download the source and compile it . virt-what source is available here.
virt-what has been developed by Redhat community.
Hope this article is informative to you. Share it ! Comment it !! Be Sociable !!!