1SYSTEMD-DETECT-VIRT(1) systemd-detect-virt SYSTEMD-DETECT-VIRT(1)
2
3
4
6 systemd-detect-virt - Detect execution in a virtualized environment
7
9 systemd-detect-virt [OPTIONS...]
10
12 systemd-detect-virt detects execution in a virtualized environment. It
13 identifies the virtualization technology and can distinguish full
14 machine virtualization from container virtualization.
15 systemd-detect-virt exits with a return value of 0 (success) if a
16 virtualization technology is detected, and non-zero (error) otherwise.
17 By default, any type of virtualization is detected, and the options
18 --container and --vm can be used to limit what types of virtualization
19 are detected.
20
21 When executed without --quiet will print a short identifier for the
22 detected virtualization technology. The following technologies are
23 currently identified:
24
25 Table 1. Known virtualization technologies (both VM, i.e. full hardware
26 virtualization, and container, i.e. shared kernel virtualization)
27 ┌──────────┬────────────────┬─────────────────────┐
28 │Type │ ID │ Product │
29 ├──────────┼────────────────┼─────────────────────┤
30 │VM │ qemu │ QEMU software │
31 │ │ │ virtualization, │
32 │ │ │ without KVM │
33 │ ├────────────────┼─────────────────────┤
34 │ │ kvm │ Linux KVM kernel │
35 │ │ │ virtual machine, │
36 │ │ │ with whatever │
37 │ │ │ software, except │
38 │ │ │ Oracle Virtualbox │
39 │ ├────────────────┼─────────────────────┤
40 │ │ zvm │ s390 z/VM │
41 │ ├────────────────┼─────────────────────┤
42 │ │ vmware │ VMware Workstation │
43 │ │ │ or Server, and │
44 │ │ │ related products │
45 │ ├────────────────┼─────────────────────┤
46 │ │ microsoft │ Hyper-V, also known │
47 │ │ │ as Viridian or │
48 │ │ │ Windows Server │
49 │ │ │ Virtualization │
50 │ ├────────────────┼─────────────────────┤
51 │ │ oracle │ Oracle VM │
52 │ │ │ VirtualBox │
53 │ │ │ (historically │
54 │ │ │ marketed by innotek │
55 │ │ │ and Sun │
56 │ │ │ Microsystems), for │
57 │ │ │ legacy and KVM │
58 │ │ │ hypervisor │
59 │ ├────────────────┼─────────────────────┤
60 │ │ xen │ Xen hypervisor │
61 │ │ │ (only domU, not │
62 │ │ │ dom0) │
63 │ ├────────────────┼─────────────────────┤
64 │ │ bochs │ Bochs Emulator │
65 │ ├────────────────┼─────────────────────┤
66 │ │ uml │ User-mode Linux │
67 │ ├────────────────┼─────────────────────┤
68 │ │ parallels │ Parallels Desktop, │
69 │ │ │ Parallels Server │
70 │ ├────────────────┼─────────────────────┤
71 │ │ bhyve │ bhyve, FreeBSD │
72 │ │ │ hypervisor │
73 │ ├────────────────┼─────────────────────┤
74 │ │ qnx │ QNX hypervisor │
75 │ ├────────────────┼─────────────────────┤
76 │ │ acrn │ ACRN hypervisor[1] │
77 ├──────────┼────────────────┼─────────────────────┤
78 │Container │ openvz │ OpenVZ/Virtuozzo │
79 │ ├────────────────┼─────────────────────┤
80 │ │ lxc │ Linux container │
81 │ │ │ implementation by │
82 │ │ │ LXC │
83 │ ├────────────────┼─────────────────────┤
84 │ │ lxc-libvirt │ Linux container │
85 │ │ │ implementation by │
86 │ │ │ libvirt │
87 │ ├────────────────┼─────────────────────┤
88 │ │ systemd-nspawn │ systemd's minimal │
89 │ │ │ container │
90 │ │ │ implementation, see │
91 │ │ │ systemd-nspawn(1) │
92 │ ├────────────────┼─────────────────────┤
93 │ │ docker │ Docker container │
94 │ │ │ manager │
95 │ ├────────────────┼─────────────────────┤
96 │ │ podman │ Podman[2] container │
97 │ │ │ manager │
98 │ ├────────────────┼─────────────────────┤
99 │ │ rkt │ rkt app container │
100 │ │ │ runtime │
101 │ ├────────────────┼─────────────────────┤
102 │ │ wsl │ Windows Subsystem │
103 │ │ │ for Linux[3] │
104 └──────────┴────────────────┴─────────────────────┘
105
106 If multiple virtualization solutions are used, only the "innermost" is
107 detected and identified. That means if both machine and container
108 virtualization are used in conjunction, only the latter will be
109 identified (unless --vm is passed).
110
111 Windows Subsystem for Linux is not a Linux container, but an
112 environment for running Linux userspace applications on top of the
113 Windows kernel using a Linux-compatible interface. WSL is categorized
114 as a container for practical purposes. Multiple WSL environments share
115 the same kernel and services should generally behave like when being
116 run in a container.
117
119 The following options are understood:
120
121 -c, --container
122 Only detects container virtualization (i.e. shared kernel
123 virtualization).
124
125 -v, --vm
126 Only detects hardware virtualization.
127
128 -r, --chroot
129 Detect whether invoked in a chroot(2) environment. In this mode, no
130 output is written, but the return value indicates whether the
131 process was invoked in a chroot() environment or not.
132
133 --private-users
134 Detect whether invoked in a user namespace. In this mode, no output
135 is written, but the return value indicates whether the process was
136 invoked inside of a user namespace or not. See user_namespaces(7)
137 for more information.
138
139 -q, --quiet
140 Suppress output of the virtualization technology identifier.
141
142 --list
143 Output all currently known and detectable container and VM
144 environments.
145
146 -h, --help
147 Print a short help text and exit.
148
149 --version
150 Print a short version string and exit.
151
153 If a virtualization technology is detected, 0 is returned, a non-zero
154 code otherwise.
155
157 systemd(1), systemd-nspawn(1), chroot(2), namespaces(7)
158
160 1. ACRN hypervisor
161 https://projectacrn.org
162
163 2. Podman
164 https://podman.io
165
166 3. Windows Subsystem for Linux
167 https://docs.microsoft.com/en-us/windows/wsl/about
168
169
170
171systemd 243 SYSTEMD-DETECT-VIRT(1)