systemd-detect-virt

systemd-detect-virt detects execution in a virtualized environment. It identifies the virtualization technology and can distinguish full machine virtualization from container virtualization. systemd-detect-virt exits with a return value of 0 (success) if a virtualization technology is detected, and non-zero (error) otherwise. By default, any type of virtualization is detected, and the options --container and --vm can be used to limit what types of virtualization are detected.

When executed without --quiet will print a short identifier for the detected virtualization technology. The following technologies are currently identified:

TypeIDProduct
vmqemuQEMU software virtualization, without KVM
vmkvmLinux KVM kernel virtual machine, in combination with QEMU. Not used for other virtualizers using the KVM interfaces, such as Oracle VirtualBox or Amazon EC2 Nitro, see below.
vmamazonAmazon EC2 Nitro using Linux KVM
vmzvms390 z/VM
vmvmwareVMware Workstation or Server, and related products
vmmicrosoftHyper-V, also known as Viridian or Windows Server Virtualization
vmoracleOracle VM VirtualBox (historically marketed by innotek and Sun Microsystems), for legacy and KVM hypervisor
vmpowervmIBM PowerVM hypervisor — comes as firmware with some IBM POWER servers
vmxenXen hypervisor (only domU, not dom0)
vmbochsBochs Emulator
vmumlUser-mode Linux
vmparallelsParallels Desktop, Parallels Server
vmbhyvebhyve, FreeBSD hypervisor
vmqnxQNX hypervisor
vmacrnACRN hypervisor
vmappleApple virtualization framework
vmsreLMHS SRE hypervisor
vmgoogleGoogle Compute Engine
containeropenvzOpenVZ/Virtuozzo
containerlxcLinux container implementation by LXC
containerlxc-libvirtLinux container implementation by libvirt
containersystemd-nspawnsystemd’s minimal container implementation, see systemd-nspawn(1) manual page
containerdockerDocker container manager
containerpodmanPodman container manager
containerrktrkt app container runtime
containerwslWindows Subsystem for Linux
containerprootproot userspace chroot/bind mount emulation
containerpouchPouch Container Engine

If multiple virtualization solutions are used, only the “innermost” is detected and identified. That means if both machine and container virtualization are used in conjunction, only the latter will be identified (unless --vm is passed).

Options

OptionDescription
-c, --containerOnly detects container virtualization (i.e. shared kernel virtualization).
-v, --vmOnly detects hardware virtualization.
-r, --chrootDetect whether invoked in a chroot environment. In this mode, no output is written, but the return value indicates whether the process was invoked in a chroot() environment or not.
-q, --quietSuppress output of the virtualization technology identifier.
--listOutput all currently known and detectable container and VM environments.