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 │ │ powervm │ IBM PowerVM │
61 │ │ │ hypervisor - comes │
62 │ │ │ as firmware with │
63 │ │ │ some IBM POWER │
64 │ │ │ servers │
65 │ ├────────────────┼─────────────────────┤
66 │ │ xen │ Xen hypervisor │
67 │ │ │ (only domU, not │
68 │ │ │ dom0) │
69 │ ├────────────────┼─────────────────────┤
70 │ │ bochs │ Bochs Emulator │
71 │ ├────────────────┼─────────────────────┤
72 │ │ uml │ User-mode Linux │
73 │ ├────────────────┼─────────────────────┤
74 │ │ parallels │ Parallels Desktop, │
75 │ │ │ Parallels Server │
76 │ ├────────────────┼─────────────────────┤
77 │ │ bhyve │ bhyve, FreeBSD │
78 │ │ │ hypervisor │
79 │ ├────────────────┼─────────────────────┤
80 │ │ qnx │ QNX hypervisor │
81 │ ├────────────────┼─────────────────────┤
82 │ │ acrn │ ACRN hypervisor[1] │
83 ├──────────┼────────────────┼─────────────────────┤
84 │Container │ openvz │ OpenVZ/Virtuozzo │
85 │ ├────────────────┼─────────────────────┤
86 │ │ lxc │ Linux container │
87 │ │ │ implementation by │
88 │ │ │ LXC │
89 │ ├────────────────┼─────────────────────┤
90 │ │ lxc-libvirt │ Linux container │
91 │ │ │ implementation by │
92 │ │ │ libvirt │
93 │ ├────────────────┼─────────────────────┤
94 │ │ systemd-nspawn │ systemd's minimal │
95 │ │ │ container │
96 │ │ │ implementation, see │
97 │ │ │ systemd-nspawn(1) │
98 │ ├────────────────┼─────────────────────┤
99 │ │ docker │ Docker container │
100 │ │ │ manager │
101 │ ├────────────────┼─────────────────────┤
102 │ │ podman │ Podman[2] container │
103 │ │ │ manager │
104 │ ├────────────────┼─────────────────────┤
105 │ │ rkt │ rkt app container │
106 │ │ │ runtime │
107 │ ├────────────────┼─────────────────────┤
108 │ │ wsl │ Windows Subsystem │
109 │ │ │ for Linux[3] │
110 │ ├────────────────┼─────────────────────┤
111 │ │ proot │ proot[4] userspace │
112 │ │ │ chroot/bind mount │
113 │ │ │ emulation │
114 └──────────┴────────────────┴─────────────────────┘
115
116 If multiple virtualization solutions are used, only the "innermost" is
117 detected and identified. That means if both machine and container
118 virtualization are used in conjunction, only the latter will be
119 identified (unless --vm is passed).
120
121 Windows Subsystem for Linux is not a Linux container, but an
122 environment for running Linux userspace applications on top of the
123 Windows kernel using a Linux-compatible interface. WSL is categorized
124 as a container for practical purposes. Multiple WSL environments share
125 the same kernel and services should generally behave like when being
126 run in a container.
127
129 The following options are understood:
130
131 -c, --container
132 Only detects container virtualization (i.e. shared kernel
133 virtualization).
134
135 -v, --vm
136 Only detects hardware virtualization.
137
138 -r, --chroot
139 Detect whether invoked in a chroot(2) environment. In this mode, no
140 output is written, but the return value indicates whether the
141 process was invoked in a chroot() environment or not.
142
143 --private-users
144 Detect whether invoked in a user namespace. In this mode, no output
145 is written, but the return value indicates whether the process was
146 invoked inside of a user namespace or not. See user_namespaces(7)
147 for more information.
148
149 -q, --quiet
150 Suppress output of the virtualization technology identifier.
151
152 --list
153 Output all currently known and detectable container and VM
154 environments.
155
156 -h, --help
157 Print a short help text and exit.
158
159 --version
160 Print a short version string and exit.
161
163 If a virtualization technology is detected, 0 is returned, a non-zero
164 code otherwise.
165
167 systemd(1), systemd-nspawn(1), chroot(2), namespaces(7)
168
170 1. ACRN hypervisor
171 https://projectacrn.org
172
173 2. Podman
174 https://podman.io
175
176 3. Windows Subsystem for Linux
177 https://docs.microsoft.com/en-us/windows/wsl/about
178
179 4. proot
180 https://proot-me.github.io/
181
182
183
184systemd 246 SYSTEMD-DETECT-VIRT(1)