Previously, we talked about how to detect how to detect whether an instance is running within a Virtualized OS instance or not. Sometime We Need to Know Type of Virtualization Cloud Server or VPS is Using. Here Are Some Commands to Detect Type of Virtualization. Need is sometimes to detect OpenVZ like container based virtualization, which essentially should cost lesser than KVM, Xen etc.
Why Type These Commands to Detect Type of Virtualization?
The reason as said – to detect OpenVZ like container based virtualization to detect the cheating of selling container based virtualization as OpenVZ like virtualization has limitations. Readers may read OpenVZ vs KVM Virtualization in this context.
List of Commands to Detect Type of Virtualization?
If we want to find out whether GNU/Linux instance is running inside a virtualized environment, there are various methods we can try, which depending on the type of hypervisor used. Processor manufacturer, files in some directories, virtualized NIC driver name, boot sequence can reveal some clues.
---
dmidecode
1 | dmidecode -s system-manufacturer |
On a physical server, the above command will return the name of the hardware manufacturer and on a virtual machine running hypervisor-based virtualization, it will show the name of virtualization technology. If we run the command on Aruba Cloud, it will return :
1 | VMware, Inc. |
The command can detect hypervisor-based virtualization like QEMU, Xen, VirtualBox, VMware. If command run on server running container based virtualization like Virtuozzo/OpenVZ, it will return no output. Also, we can run :
1 | dmidecode -s system-product-name |
which returns this on on Aruba Cloud :
1 | VMware Virtual Platform |
systemd
1 | systemd-detect-virt |
On a physical server, the above command will return none
and on a virtual machine, it will show the name of virtualization technology.
virt-what
1 | systemd-detect-virt |
virt-what
is a package usually installed, if not you can install it with command like yum install virt-what
, apt install virt-what
. We can detect QEMU, KVM, VMware, Hyper-V, VirtualBox, OpenVZ/Virtuozzo, Xen, LXC, Parallels, etc virtualization. If we run the command on Aruba Cloud, it will return :
1 | VMware |
dmesg
1 | dmesg | grep -i virtual |
The above command will return details of the machine, it will show the name of virtualization technology. If we run the command on Aruba Cloud, it will return :
1 2 3 4 5 6 | [ 0.000000] DMI: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 04/14/2014 [ 0.000000] Booting paravirtualized kernel on bare hardware [ 0.745869] systemd[1]: Detected virtualization vmware. [ 0.778983] systemd[1]: Starting Setup Virtual Console... [ 4.274791] scsi 0:0:0:0: Direct-Access VMware Virtual disk 1.0 PQ: 0 ANSI: 2 [ 4.449864] ata2.00: ATAPI: VMware Virtual IDE CDROM Drive, 00000001, max UDMA/33 |
/dev/disk/by-id/
1 | ls -1 /dev/disk/by-id/ |
The above command will give hints of the underlying technology. If we run the command on Aruba Cloud, it will return :
1 2 3 4 5 6 7 | ata-VMware_Virtual_IDE_CDROM_Drive_10000000000000000001 dm-name-vg-lv_root dm-name-vg-lv_swap dm-uuid-LVM-gEjaWGmvkck5FDdtB09fA44VCYk5619J1ZT9Xj3MZx5gG7Q7Lgb3xUjMVImHXDzJ dm-uuid-LVM-gEjaWGmvkck5FDdtB09fA44VCYk5619JTvyt4e11m4kzsVdPY9VIPDUefxUM7Tl6 lvm-pv-uuid-TaS0Yf-pb5W-uW20-4qpm-okqv-y1KY-HAf1TO lvm-pv-uuid-ZltsYs-V501-Z2uY-28Z5-1ed1-v7VQ-Zh1yAH |
open-vm-tools
1 | https://github.com/vmware/open-vm-tools |
imvirt
1 | imvirt |
imvirt
is availble as Debian package and can detect VirtualBox, VMware, QEMU/KVM (experimental), Xen (para and non-para virtualized), OpenVZ/Virtuozzo, Parallels Workstation, UML, any HVM providing CPUID 0x40000000 detection.
This is not exactly enough. There is always some way to deliberately fool these tools even if used in combination.
Tagged With booting paravirtualized kernel on bare hardware , pc core type detected: 440Bx vmware , systemd-detect-virt run windows