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 -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 :
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 :
dmidecode -s system-product-name
which returns this on on Aruba Cloud :
VMware Virtual Platform
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 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 :
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 :
[ 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: Detected virtualization vmware.
[ 0.778983] systemd: 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
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 :
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