1 # SPDX-License-Identifier: LGPL-2.1+
3 # This file is part of systemd.
5 # systemd is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU Lesser General Public License as published by
7 # the Free Software Foundation; either version 2.1 of the License, or
8 # (at your option) any later version.
11 Description=Container %i
12 Documentation=man:systemd-nspawn(1)
13 PartOf=machines.target
14 Before=machines.target
15 After=network.target systemd-resolved.service
16 RequiresMountsFor=/var/lib/machines
19 # Make sure the DeviceAllow= lines below can properly resolve the 'block-loop' expression (and others)
20 ExecStartPre=-/sbin/modprobe -abq tun loop dm-mod
21 ExecStart=@bindir@/systemd-nspawn --quiet --keep-unit --boot --link-journal=try-guest --network-veth -U --settings=override --machine=%i
24 RestartForceExitStatus=133
31 # Enforce a strict device policy, similar to the one nspawn configures when it
32 # allocates its own scope unit. Make sure to keep these policies in sync if you
35 DeviceAllow=/dev/net/tun rwm
36 DeviceAllow=char-pts rw
38 # nspawn itself needs access to /dev/loop-control and /dev/loop, to implement
39 # the --image= option. Add these here, too.
40 DeviceAllow=/dev/loop-control rw
41 DeviceAllow=block-loop rw
42 DeviceAllow=block-blkext rw
44 # nspawn can set up LUKS encrypted loopback files, in which case it needs
45 # access to /dev/mapper/control and the block devices /dev/mapper/*.
46 DeviceAllow=/dev/mapper/control rw
47 DeviceAllow=block-device-mapper rw
50 WantedBy=machines.target