| 1 |
<?xml version='1.0'?> <!--*-nxml-*--> |
| 2 |
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
| 3 |
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> |
| 4 |
<!-- SPDX-License-Identifier: LGPL-2.1-or-later --> |
| 5 |
|
| 6 |
<refentry id="systemd-dissect" conditional='HAVE_BLKID' |
| 7 |
xmlns:xi="http://www.w3.org/2001/XInclude"> |
| 8 |
|
| 9 |
<refentryinfo> |
| 10 |
<title>systemd-dissect</title> |
| 11 |
<productname>systemd</productname> |
| 12 |
</refentryinfo> |
| 13 |
|
| 14 |
<refmeta> |
| 15 |
<refentrytitle>systemd-dissect</refentrytitle> |
| 16 |
<manvolnum>1</manvolnum> |
| 17 |
</refmeta> |
| 18 |
|
| 19 |
<refnamediv> |
| 20 |
<refname>systemd-dissect</refname> |
| 21 |
<refname>mount.ddi</refname> |
| 22 |
<refpurpose>Dissect Discoverable Disk Images (DDIs)</refpurpose> |
| 23 |
</refnamediv> |
| 24 |
|
| 25 |
<refsynopsisdiv> |
| 26 |
<cmdsynopsis> |
| 27 |
<command>systemd-dissect</command> <arg choice="opt" rep="repeat">OPTIONS</arg> <arg choice="plain"><replaceable>IMAGE</replaceable></arg> |
| 28 |
</cmdsynopsis> |
| 29 |
<cmdsynopsis> |
| 30 |
<command>systemd-dissect</command> <arg choice="opt" rep="repeat">OPTIONS</arg> <arg>--mount</arg> <arg choice="plain"><replaceable>IMAGE</replaceable></arg> <arg choice="plain"><replaceable>PATH</replaceable></arg> |
| 31 |
</cmdsynopsis> |
| 32 |
<cmdsynopsis> |
| 33 |
<command>systemd-dissect</command> <arg choice="opt" rep="repeat">OPTIONS</arg> <arg>--umount</arg> <arg choice="plain"><replaceable>PATH</replaceable></arg> |
| 34 |
</cmdsynopsis> |
| 35 |
<cmdsynopsis> |
| 36 |
<command>systemd-dissect</command> <arg choice="opt" rep="repeat">OPTIONS</arg> <arg>--attach</arg> <arg choice="plain"><replaceable>IMAGE</replaceable></arg> |
| 37 |
</cmdsynopsis> |
| 38 |
<cmdsynopsis> |
| 39 |
<command>systemd-dissect</command> <arg choice="opt" rep="repeat">OPTIONS</arg> <arg>--detach</arg> <arg choice="plain"><replaceable>PATH</replaceable></arg> |
| 40 |
</cmdsynopsis> |
| 41 |
<cmdsynopsis> |
| 42 |
<command>systemd-dissect</command> <arg choice="opt" rep="repeat">OPTIONS</arg> <arg>--list</arg> <arg choice="plain"><replaceable>IMAGE</replaceable></arg> |
| 43 |
</cmdsynopsis> |
| 44 |
<cmdsynopsis> |
| 45 |
<command>systemd-dissect</command> <arg choice="opt" rep="repeat">OPTIONS</arg> <arg>--mtree</arg> <arg choice="plain"><replaceable>IMAGE</replaceable></arg> |
| 46 |
</cmdsynopsis> |
| 47 |
<cmdsynopsis> |
| 48 |
<command>systemd-dissect</command> <arg choice="opt" rep="repeat">OPTIONS</arg> <arg>--with</arg> <arg choice="plain"><replaceable>IMAGE</replaceable></arg> <arg choice="opt" rep="repeat"><replaceable>COMMAND</replaceable></arg> |
| 49 |
</cmdsynopsis> |
| 50 |
<cmdsynopsis> |
| 51 |
<command>systemd-dissect</command> <arg choice="opt" rep="repeat">OPTIONS</arg> <arg>--copy-from</arg> <arg choice="plain"><replaceable>IMAGE</replaceable></arg> <arg choice="plain"><replaceable>PATH</replaceable></arg> <arg choice="opt"><replaceable>TARGET</replaceable></arg> |
| 52 |
</cmdsynopsis> |
| 53 |
<cmdsynopsis> |
| 54 |
<command>systemd-dissect</command> <arg choice="opt" rep="repeat">OPTIONS</arg> <arg>--copy-to</arg> <arg choice="plain"><replaceable>IMAGE</replaceable></arg> <arg choice="opt"><replaceable>SOURCE</replaceable></arg> <arg choice="plain"><replaceable>PATH</replaceable></arg> |
| 55 |
</cmdsynopsis> |
| 56 |
<cmdsynopsis> |
| 57 |
<command>systemd-dissect</command> <arg choice="opt" rep="repeat">OPTIONS</arg> <arg>--make-archive</arg> <arg choice="plain"><replaceable>IMAGE</replaceable></arg> <arg choice="opt"><replaceable>TARGET</replaceable></arg> |
| 58 |
</cmdsynopsis> |
| 59 |
<cmdsynopsis> |
| 60 |
<command>systemd-dissect</command> <arg choice="opt" rep="repeat">OPTIONS</arg> <arg>--discover</arg> |
| 61 |
</cmdsynopsis> |
| 62 |
<cmdsynopsis> |
| 63 |
<command>systemd-dissect</command> <arg choice="opt" rep="repeat">OPTIONS</arg> <arg>--validate</arg> <arg choice="plain"><replaceable>IMAGE</replaceable></arg> |
| 64 |
</cmdsynopsis> |
| 65 |
<cmdsynopsis> |
| 66 |
<command>systemd-dissect</command> <arg choice="opt" rep="repeat">OPTIONS</arg> <arg>--shift</arg> <arg choice="plain"><replaceable>IMAGE</replaceable></arg> <arg choice="plain"><replaceable>UIDBASE</replaceable></arg> |
| 67 |
</cmdsynopsis> |
| 68 |
</refsynopsisdiv> |
| 69 |
|
| 70 |
<refsect1> |
| 71 |
<title>Description</title> |
| 72 |
|
| 73 |
<para><command>systemd-dissect</command> is a tool for introspecting and interacting with file system OS |
| 74 |
disk images, specifically Discoverable Disk Images (DDIs). It supports four different operations:</para> |
| 75 |
|
| 76 |
<orderedlist> |
| 77 |
<listitem><para>Show general OS image information, including the image's |
| 78 |
<citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry> data, |
| 79 |
machine ID, partition information and more.</para></listitem> |
| 80 |
|
| 81 |
<listitem><para>Mount an OS image to a local directory. In this mode it will dissect the OS image and |
| 82 |
mount the included partitions according to their designation onto a directory and possibly |
| 83 |
sub-directories.</para></listitem> |
| 84 |
|
| 85 |
<listitem><para>Unmount an OS image from a local directory. In this mode it will recursively unmount |
| 86 |
the mounted partitions and remove the underlying loop device, including all the partition sub-devices. |
| 87 |
</para></listitem> |
| 88 |
|
| 89 |
<listitem><para>Copy files and directories in and out of an OS image.</para></listitem> |
| 90 |
</orderedlist> |
| 91 |
|
| 92 |
<para>The tool may operate on three types of OS images:</para> |
| 93 |
|
| 94 |
<orderedlist> |
| 95 |
<listitem><para>OS disk images containing a GPT partition table envelope, with partitions marked |
| 96 |
according to the <ulink url="https://uapi-group.org/specifications/specs/discoverable_partitions_specification">UAPI.2 Discoverable Partitions |
| 97 |
Specification</ulink>.</para></listitem> |
| 98 |
|
| 99 |
<listitem><para>OS disk images containing just a plain file-system without an enveloping partition |
| 100 |
table. (This file system is assumed to be the root file system of the OS.)</para></listitem> |
| 101 |
|
| 102 |
<listitem><para>OS disk images containing a GPT or MBR partition table, with a single |
| 103 |
partition only. (This partition is assumed to contain the root file system of the OS.)</para></listitem> |
| 104 |
</orderedlist> |
| 105 |
|
| 106 |
<para>OS images may use any kind of Linux-supported file systems. In addition they may make use of LUKS |
| 107 |
disk encryption, and contain Verity integrity information. Note that qualifying OS images may be booted |
| 108 |
with <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s |
| 109 |
<option>--image=</option> switch, and be used as root file system for system service using the |
| 110 |
<varname>RootImage=</varname> unit file setting, see |
| 111 |
<citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para> |
| 112 |
|
| 113 |
<para>Note that the partition table shown when invoked without command switch (as listed below) does not |
| 114 |
necessarily show all partitions included in the image, but just the partitions that are understood and |
| 115 |
considered part of an OS disk image. Specifically, partitions of unknown types are ignored, as well as |
| 116 |
duplicate partitions (i.e. more than one per partition type), as are root and <filename>/usr/</filename> |
| 117 |
partitions of architectures not compatible with the local system. In other words: this tool will display |
| 118 |
what it operates with when mounting the image. To display the complete list of partitions use a tool such |
| 119 |
as <citerefentry |
| 120 |
project='man-pages'><refentrytitle>fdisk</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para> |
| 121 |
|
| 122 |
<para>The <command>systemd-dissect</command> command may be invoked as <command>mount.ddi</command> in |
| 123 |
which case it implements the <citerefentry |
| 124 |
project='man-pages'><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry> "external |
| 125 |
helper" interface. This ensures disk images compatible with <command>systemd-dissect</command> can be |
| 126 |
mounted directly by <command>mount</command> and <citerefentry |
| 127 |
project='man-pages'><refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum></citerefentry>. For |
| 128 |
details see below.</para> |
| 129 |
|
| 130 |
<xi:include href="vpick.xml" xpointer="image"/> |
| 131 |
</refsect1> |
| 132 |
|
| 133 |
<refsect1> |
| 134 |
<title>Commands</title> |
| 135 |
|
| 136 |
<para>If neither of the command switches listed below are passed the specified disk image is opened and |
| 137 |
general information about the image and the contained partitions and their use is shown.</para> |
| 138 |
|
| 139 |
<variablelist> |
| 140 |
<varlistentry> |
| 141 |
<term><option>--mount</option></term> |
| 142 |
<term><option>-m</option></term> |
| 143 |
|
| 144 |
<listitem><para>Mount the specified OS image to the specified directory. This will dissect the image, |
| 145 |
determine the OS root file system — as well as possibly other partitions — and mount them to the |
| 146 |
specified directory. If the OS image contains multiple partitions marked with the <ulink |
| 147 |
url="https://uapi-group.org/specifications/specs/discoverable_partitions_specification">UAPI.2 Discoverable Partitions Specification</ulink> |
| 148 |
multiple nested mounts are established. This command expects two arguments: a path to an image file |
| 149 |
and a path to a directory where to mount the image.</para> |
| 150 |
|
| 151 |
<para>To unmount an OS image mounted like this use the <option>--umount</option> operation.</para> |
| 152 |
|
| 153 |
<para>When the OS image contains LUKS encrypted or Verity integrity protected file systems |
| 154 |
appropriate volumes are automatically set up and marked for automatic disassembly when the image is |
| 155 |
unmounted.</para> |
| 156 |
|
| 157 |
<para>The OS image may either be specified as path to an OS image stored in a regular file or may |
| 158 |
refer to block device node (in the latter case, the block device must be the "whole" device, i.e. not |
| 159 |
a partition device). (The other supported commands described here support this, too.)</para> |
| 160 |
|
| 161 |
<para>All mounted file systems are checked with the appropriate <citerefentry |
| 162 |
project='man-pages'><refentrytitle>fsck</refentrytitle><manvolnum>8</manvolnum></citerefentry> |
| 163 |
implementation in automatic fixing mode, unless explicitly turned off (<option>--fsck=no</option>) or |
| 164 |
read-only operation is requested (<option>--read-only</option>).</para> |
| 165 |
|
| 166 |
<para>Note that this functionality is also available in <citerefentry |
| 167 |
project='man-pages'><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry> via a |
| 168 |
command such as <command>mount -t ddi myimage.raw targetdir/</command>, as well as in <citerefentry |
| 169 |
project='man-pages'><refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum></citerefentry>. For |
| 170 |
details, see below.</para> |
| 171 |
|
| 172 |
<xi:include href="version-info.xml" xpointer="v247"/></listitem> |
| 173 |
</varlistentry> |
| 174 |
|
| 175 |
<varlistentry> |
| 176 |
<term><option>-M</option></term> |
| 177 |
|
| 178 |
<listitem><para>This is a shortcut for <option>--mount --mkdir</option>.</para> |
| 179 |
|
| 180 |
<xi:include href="version-info.xml" xpointer="v247"/></listitem> |
| 181 |
</varlistentry> |
| 182 |
|
| 183 |
<varlistentry> |
| 184 |
<term><option>--umount</option></term> |
| 185 |
<term><option>-u</option></term> |
| 186 |
|
| 187 |
<listitem><para>Unmount an OS image from the specified directory. This command expects one argument: |
| 188 |
a directory where an OS image was mounted.</para> |
| 189 |
|
| 190 |
<para>All mounted partitions will be recursively unmounted, and the underlying loop device will be |
| 191 |
removed, along with all its partition sub-devices.</para> |
| 192 |
|
| 193 |
<xi:include href="version-info.xml" xpointer="v252"/></listitem> |
| 194 |
</varlistentry> |
| 195 |
|
| 196 |
<varlistentry> |
| 197 |
<term><option>-U</option></term> |
| 198 |
|
| 199 |
<listitem><para>This is a shortcut for <option>--umount --rmdir</option>.</para> |
| 200 |
|
| 201 |
<xi:include href="version-info.xml" xpointer="v252"/></listitem> |
| 202 |
</varlistentry> |
| 203 |
|
| 204 |
<varlistentry> |
| 205 |
<term><option>--attach</option></term> |
| 206 |
|
| 207 |
<listitem><para>Attach the specified disk image to an automatically allocated loopback block device, |
| 208 |
and print the path to the loopback block device to standard output. This is similar to an invocation |
| 209 |
of <command>losetup --find --show --partscan</command>, but will validate the image as DDI before |
| 210 |
attaching, and derive the correct sector size to use automatically. Moreover, it ensures the |
| 211 |
per-partition block devices are created before returning and attempts to enable direct IO mode, if |
| 212 |
possible. Takes a path to a disk image file.</para> |
| 213 |
|
| 214 |
<para>If combined with <option>--quiet</option> output of the block device name is suppressed.</para> |
| 215 |
|
| 216 |
<xi:include href="version-info.xml" xpointer="v254"/></listitem> |
| 217 |
</varlistentry> |
| 218 |
|
| 219 |
<varlistentry> |
| 220 |
<term><option>--detach</option></term> |
| 221 |
|
| 222 |
<listitem><para>Detach the specified disk image from a loopback block device. This undoes the effect |
| 223 |
of <option>--attach</option> above. This expects either a path to a loopback block device as an |
| 224 |
argument, or the path to the backing image file. In the latter case, it will automatically determine |
| 225 |
the right device to detach.</para> |
| 226 |
|
| 227 |
<xi:include href="version-info.xml" xpointer="v254"/></listitem> |
| 228 |
</varlistentry> |
| 229 |
|
| 230 |
<varlistentry> |
| 231 |
<term><option>--list</option></term> |
| 232 |
<term><option>-l</option></term> |
| 233 |
|
| 234 |
<listitem><para>Prints the paths of all the files and directories in the specified OS image or |
| 235 |
directory to standard output.</para> |
| 236 |
|
| 237 |
<xi:include href="version-info.xml" xpointer="v253"/></listitem> |
| 238 |
</varlistentry> |
| 239 |
|
| 240 |
<varlistentry> |
| 241 |
<term><option>--mtree</option></term> |
| 242 |
|
| 243 |
<listitem><para>Generates a BSD |
| 244 |
<citerefentry project='die-net'><refentrytitle>mtree</refentrytitle><manvolnum>8</manvolnum></citerefentry> |
| 245 |
compatible file manifest of the specified disk image or directory. This is useful for comparing image |
| 246 |
contents in detail, including inode information and other metadata. While the generated manifest will |
| 247 |
contain detailed inode information, it currently excludes extended attributes, file system |
| 248 |
capabilities, MAC labels, |
| 249 |
<citerefentry project='man-pages'><refentrytitle>chattr</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
| 250 |
file flags, |
| 251 |
<citerefentry project='url'><refentrytitle url='https://btrfs.readthedocs.io/en/latest/btrfs-man5.html'>btrfs</refentrytitle><manvolnum>5</manvolnum></citerefentry> |
| 252 |
subvolume information, and various other file metadata. File content information is shown via a |
| 253 |
SHA256 digest. Additional fields might be added in future. Note that inode information such as link |
| 254 |
counts, inode numbers and timestamps is excluded from the output on purpose, as it typically |
| 255 |
complicates reproducibility.</para> |
| 256 |
|
| 257 |
<xi:include href="version-info.xml" xpointer="v253"/></listitem> |
| 258 |
</varlistentry> |
| 259 |
|
| 260 |
<varlistentry> |
| 261 |
<term><option>--with</option></term> |
| 262 |
|
| 263 |
<listitem><para>Runs the specified command with the specified OS image mounted. This will mount the |
| 264 |
image to a temporary directory, switch the current working directory to it, and invoke the specified |
| 265 |
command line as child process. Once the process ends it will unmount the image again, and remove the |
| 266 |
temporary directory. If no command is specified a shell is invoked. The image is mounted writable, |
| 267 |
use <option>--read-only</option> to switch to read-only operation. The invoked process will have the |
| 268 |
<varname>$SYSTEMD_DISSECT_ROOT</varname> environment variable set, containing the absolute path name |
| 269 |
of the temporary mount point, i.e. the same directory that is set as the current working |
| 270 |
directory. It will also have the <varname>$SYSTEMD_DISSECT_DEVICE</varname> environment variable set, |
| 271 |
containing the absolute path name of the loop device the image was attached to.</para> |
| 272 |
|
| 273 |
<xi:include href="version-info.xml" xpointer="v253"/></listitem> |
| 274 |
</varlistentry> |
| 275 |
|
| 276 |
<varlistentry> |
| 277 |
<term><option>--copy-from</option></term> |
| 278 |
<term><option>-x</option></term> |
| 279 |
|
| 280 |
<listitem><para>Copies a file or directory from the specified OS image or directory into the |
| 281 |
specified location on the host file system. Expects three arguments: a path to an image file or |
| 282 |
directory, a source path (relative to the image's root directory) and a destination path (relative to |
| 283 |
the current working directory, or an absolute path, both outside of the image). If the destination |
| 284 |
path is omitted or specified as dash (<literal>-</literal>), the specified file is written to |
| 285 |
standard output. If the source path in the image file system refers to a regular file it is copied to |
| 286 |
the destination path. In this case, access mode, extended attributes and timestamps are copied as |
| 287 |
well, but file ownership is not. If the source path in the image refers to a directory, it is copied |
| 288 |
to the destination path, recursively with all containing files and directories, merging into existing |
| 289 |
directories and updating already existing files. In this case, the file ownership is copied too.</para> |
| 290 |
|
| 291 |
<xi:include href="version-info.xml" xpointer="v247"/></listitem> |
| 292 |
</varlistentry> |
| 293 |
|
| 294 |
<varlistentry> |
| 295 |
<term><option>--copy-to</option></term> |
| 296 |
<term><option>-a</option></term> |
| 297 |
|
| 298 |
<listitem><para>Copies a file or directory from the specified location in the host file system into |
| 299 |
the specified OS image or directory. Expects three arguments: a path to an image file or directory, a |
| 300 |
source path (relative to the current working directory, or an absolute path, both outside of the |
| 301 |
image) and a destination path (relative to the image's root directory). If the source path is omitted |
| 302 |
or specified as dash (<literal>-</literal>), the data to write is read from standard input. If the |
| 303 |
source path in the host file system refers to a regular file, it is copied to the destination path. |
| 304 |
In this case, access mode, extended attributes and timestamps are copied as well, but file ownership |
| 305 |
is not. If the source path in the host file system refers to a directory it is copied to the |
| 306 |
destination path, recursively with all containing files and directories, merging into existing |
| 307 |
directories and updating already existing files.. In this case, the file ownership is copied too.</para> |
| 308 |
|
| 309 |
<para>As with <option>--mount</option> file system checks are implicitly run before the copy |
| 310 |
operation begins.</para> |
| 311 |
|
| 312 |
<xi:include href="version-info.xml" xpointer="v247"/></listitem> |
| 313 |
</varlistentry> |
| 314 |
|
| 315 |
<varlistentry> |
| 316 |
<term><option>--make-archive</option></term> |
| 317 |
|
| 318 |
<listitem><para>Generates an archive file from the specified disk image. Expects two arguments: the |
| 319 |
path to the disk image and optionally the output archive file path. If the latter is omitted the |
| 320 |
archive is written to standard output. The archive file format is determined automatically from the |
| 321 |
specified output archive file name, e.g. any path suffixed with <literal>.tar.xz</literal> will |
| 322 |
result in an xz compressed UNIX tarball (if the path is omitted an uncompressed UNIX tarball is |
| 323 |
created). See |
| 324 |
<citerefentry project='die-net'><refentrytitle>libarchive</refentrytitle><manvolnum>3</manvolnum></citerefentry> |
| 325 |
for a list of supported archive formats and compression schemes.</para> |
| 326 |
|
| 327 |
<xi:include href="version-info.xml" xpointer="v256"/></listitem> |
| 328 |
</varlistentry> |
| 329 |
|
| 330 |
<varlistentry> |
| 331 |
<term><option>--discover</option></term> |
| 332 |
|
| 333 |
<listitem><para>Show a list of DDIs in well-known directories. This will show machine, portable |
| 334 |
service and system/configuration extension disk images in the usual directories |
| 335 |
<filename>/usr/lib/machines/</filename>, <filename>/usr/lib/portables/</filename>, |
| 336 |
<filename>/usr/lib/confexts/</filename>, <filename>/var/lib/machines/</filename>, |
| 337 |
<filename>/var/lib/portables/</filename>, <filename>/var/lib/extensions/</filename> and so |
| 338 |
on.</para> |
| 339 |
|
| 340 |
<xi:include href="version-info.xml" xpointer="v253"/></listitem> |
| 341 |
</varlistentry> |
| 342 |
|
| 343 |
<varlistentry> |
| 344 |
<term><option>--validate</option></term> |
| 345 |
|
| 346 |
<listitem><para>Validates the partition arrangement of a disk image (DDI), and ensures it matches the |
| 347 |
image policy specified via <option>--image-policy=</option>, if one is specified. This parses the |
| 348 |
partition table and probes the file systems in the image, but does not attempt to mount them (nor to |
| 349 |
set up disk encryption/authentication via LUKS/Verity). It does this taking the configured image |
| 350 |
dissection policy into account. Since this operation does not mount file systems, this command – |
| 351 |
unlike all other commands implemented by this tool – requires no privileges other than the ability to |
| 352 |
access the specified file. Prints "OK" and returns zero if the image appears to be in order and |
| 353 |
matches the specified image dissection policy. Otherwise, prints an error message and returns |
| 354 |
non-zero.</para> |
| 355 |
|
| 356 |
<xi:include href="version-info.xml" xpointer="v254"/></listitem> |
| 357 |
</varlistentry> |
| 358 |
|
| 359 |
<varlistentry> |
| 360 |
<term><option>--shift</option></term> |
| 361 |
|
| 362 |
<listitem><para>Recursively iterates through all inodes of the specified image and shifts the UIDs |
| 363 |
and GIDs the inodes are owned by into the specified UID range. Takes an image path and a UID base as |
| 364 |
parameter. The UID base can be specified numerically (in which case it must be a multiple of 65536, |
| 365 |
and either 0 or within the container or foreign UID range, as per <ulink |
| 366 |
url="https://systemd.io/UIDS-GIDS/">Users, Groups, UIDs and GIDs on systemd Systems</ulink>), or as |
| 367 |
the symbolic identifier <literal>foreign</literal> which is shorthand to the foreign UID base. This |
| 368 |
command is useful for preparing directory container images for unprivileged use. Note that this |
| 369 |
command is intended for images that use the 16bit UIDs/GIDs range only, and it always ignores the |
| 370 |
upper 16bit of the current UID/GID ownership, combining the lower 16 bit with the target UID |
| 371 |
base.</para> |
| 372 |
|
| 373 |
<para>Use <command>systemd-dissect --shift /some/container/tree foreign</command> to shift a |
| 374 |
container image into the foreign UID range, or <command>systemd-dissect --shift /some/container/tree |
| 375 |
0</command> to shift it to host UID range.</para> |
| 376 |
|
| 377 |
<xi:include href="version-info.xml" xpointer="v258"/></listitem> |
| 378 |
</varlistentry> |
| 379 |
|
| 380 |
<xi:include href="standard-options.xml" xpointer="help" /> |
| 381 |
<xi:include href="standard-options.xml" xpointer="version" /> |
| 382 |
</variablelist> |
| 383 |
|
| 384 |
</refsect1> |
| 385 |
|
| 386 |
<refsect1> |
| 387 |
<title>Options</title> |
| 388 |
|
| 389 |
<para>The following options are understood:</para> |
| 390 |
|
| 391 |
<variablelist> |
| 392 |
<varlistentry> |
| 393 |
<term><option>--read-only</option></term> |
| 394 |
<term><option>-r</option></term> |
| 395 |
|
| 396 |
<listitem><para>Operate in read-only mode. By default, <option>--mount</option> will establish |
| 397 |
writable mount points. If this option is specified they are established in read-only mode |
| 398 |
instead.</para> |
| 399 |
|
| 400 |
<xi:include href="version-info.xml" xpointer="v247"/></listitem> |
| 401 |
</varlistentry> |
| 402 |
|
| 403 |
<varlistentry> |
| 404 |
<term><option>--fsck=no</option></term> |
| 405 |
|
| 406 |
<listitem><para>Turn off automatic file system checking. By default, when an image is accessed for |
| 407 |
writing (by <option>--mount</option> or <option>--copy-to</option>) the file systems contained in the |
| 408 |
OS image are automatically checked using the appropriate <citerefentry |
| 409 |
project='man-pages'><refentrytitle>fsck</refentrytitle><manvolnum>8</manvolnum></citerefentry> |
| 410 |
command, in automatic fixing mode. This behavior may be switched off using |
| 411 |
<option>--fsck=no</option>.</para> |
| 412 |
|
| 413 |
<xi:include href="version-info.xml" xpointer="v247"/></listitem> |
| 414 |
</varlistentry> |
| 415 |
|
| 416 |
<varlistentry> |
| 417 |
<term><option>--growfs=no</option></term> |
| 418 |
|
| 419 |
<listitem><para>Turn off automatic growing of accessed file systems to their partition size, if |
| 420 |
marked for that in the GPT partition table. By default, when an image is accessed for writing (by |
| 421 |
<option>--mount</option> or <option>--copy-to</option>) the file systems contained in the OS image |
| 422 |
are automatically grown to their partition sizes, if bit 59 in the GPT partition flags is set for |
| 423 |
partition types that are defined by the <ulink |
| 424 |
url="https://uapi-group.org/specifications/specs/discoverable_partitions_specification">UAPI.2 Discoverable Partitions Specification</ulink>. This |
| 425 |
behavior may be switched off using <option>--growfs=no</option>. File systems are grown automatically |
| 426 |
on access if all of the following conditions are met:</para> |
| 427 |
<orderedlist> |
| 428 |
<listitem><para>The file system is mounted writable</para></listitem> |
| 429 |
<listitem><para>The file system currently is smaller than the partition it is contained in (and thus can be grown)</para></listitem> |
| 430 |
<listitem><para>The image contains a GPT partition table</para></listitem> |
| 431 |
<listitem><para>The file system is stored on a partition defined by the Discoverable Partitions Specification</para></listitem> |
| 432 |
<listitem><para>Bit 59 of the GPT partition flags for this partition is set, as per specification</para></listitem> |
| 433 |
<listitem><para>The <option>--growfs=no</option> option is not passed.</para></listitem> |
| 434 |
</orderedlist> |
| 435 |
|
| 436 |
<xi:include href="version-info.xml" xpointer="v249"/> |
| 437 |
</listitem> |
| 438 |
</varlistentry> |
| 439 |
|
| 440 |
<varlistentry> |
| 441 |
<term><option>--mkdir</option></term> |
| 442 |
|
| 443 |
<listitem><para>If combined with <option>--mount</option> the directory to mount the OS image to is |
| 444 |
created if it is missing. Note that the directory is not automatically removed when the disk image is |
| 445 |
unmounted again.</para> |
| 446 |
|
| 447 |
<xi:include href="version-info.xml" xpointer="v247"/></listitem> |
| 448 |
</varlistentry> |
| 449 |
|
| 450 |
<varlistentry> |
| 451 |
<term><option>--rmdir</option></term> |
| 452 |
|
| 453 |
<listitem><para>If combined with <option>--umount</option> the specified directory where the OS image |
| 454 |
is mounted is removed after unmounting the OS image.</para> |
| 455 |
|
| 456 |
<xi:include href="version-info.xml" xpointer="v252"/></listitem> |
| 457 |
</varlistentry> |
| 458 |
|
| 459 |
<varlistentry> |
| 460 |
<term><option>--discard=</option></term> |
| 461 |
|
| 462 |
<listitem><para>Takes one of <literal>disabled</literal>, <literal>loop</literal>, |
| 463 |
<literal>all</literal>, <literal>crypto</literal>. If <literal>disabled</literal> the image is |
| 464 |
accessed with empty block discarding turned off. If <literal>loop</literal> discarding is enabled if |
| 465 |
operating on a regular file. If <literal>crypt</literal> discarding is enabled even on encrypted file |
| 466 |
systems. If <literal>all</literal> discarding is unconditionally enabled.</para> |
| 467 |
|
| 468 |
<xi:include href="version-info.xml" xpointer="v247"/></listitem> |
| 469 |
</varlistentry> |
| 470 |
|
| 471 |
<varlistentry> |
| 472 |
<term><option>--in-memory</option></term> |
| 473 |
|
| 474 |
<listitem><para>If specified an in-memory copy of the specified disk image is used. This may be used |
| 475 |
to operate with write-access on a (possibly read-only) image, without actually modifying the original |
| 476 |
file. This may also be used in order to operate on a disk image without keeping the originating file |
| 477 |
system busy, in order to allow it to be unmounted.</para> |
| 478 |
|
| 479 |
<xi:include href="version-info.xml" xpointer="v253"/></listitem> |
| 480 |
</varlistentry> |
| 481 |
|
| 482 |
<varlistentry> |
| 483 |
<term><option>--root-hash=</option></term> |
| 484 |
<term><option>--root-hash-sig=</option></term> |
| 485 |
<term><option>--verity-data=</option></term> |
| 486 |
|
| 487 |
<listitem><para>Configure various aspects of Verity data integrity for the OS image. Option |
| 488 |
<option>--root-hash=</option> specifies a hex-encoded top-level Verity hash to use for setting up the |
| 489 |
Verity integrity protection. Option <option>--root-hash-sig=</option> specifies the path to a file |
| 490 |
containing a PKCS#7 signature for the hash. This signature is passed to the kernel during activation, |
| 491 |
which will match it against signature keys available in the kernel keyring. Option |
| 492 |
<option>--verity-data=</option> specifies a path to a file with the Verity data to use for the OS |
| 493 |
image, in case it is stored in a detached file. It is recommended to embed the Verity data directly |
| 494 |
in the image, using the Verity mechanisms in the <ulink |
| 495 |
url="https://uapi-group.org/specifications/specs/discoverable_partitions_specification">UAPI.2 Discoverable Partitions Specification</ulink>. |
| 496 |
</para> |
| 497 |
|
| 498 |
<xi:include href="version-info.xml" xpointer="v247"/></listitem> |
| 499 |
</varlistentry> |
| 500 |
|
| 501 |
<varlistentry> |
| 502 |
<term><option>--usr-hash=</option></term> |
| 503 |
<term><option>--usr-hash-sig=</option></term> |
| 504 |
|
| 505 |
<listitem><para>Similar to <option>--root-hash=</option> and <option>--root-hash-sig=</option>, but |
| 506 |
specifies hash and signature for the <filename>/usr/</filename> partition. Note that either the |
| 507 |
options for the root partition may be used or the ones for the <filename>/usr/</filename>, but not |
| 508 |
both in combination.</para> |
| 509 |
|
| 510 |
<xi:include href="version-info.xml" xpointer="v258"/></listitem> |
| 511 |
</varlistentry> |
| 512 |
|
| 513 |
<varlistentry> |
| 514 |
<term><option>--loop-ref=</option></term> |
| 515 |
|
| 516 |
<listitem><para>Configures the "reference" string the kernel shall report as backing file for the |
| 517 |
loopback block device. While this is supposed to be a path or filename referencing the backing file, |
| 518 |
this is not enforced and the kernel accepts arbitrary free-form strings, chosen by the user. Accepts |
| 519 |
arbitrary strings up to a length of 63 characters. This sets the kernel's |
| 520 |
<literal>.lo_file_name</literal> field for the block device. Note this is distinct from the |
| 521 |
<filename>/sys/class/block/loopX/loop/backing_file</filename> attribute file that always reports a |
| 522 |
path referring to the actual backing file. The latter is subject to mount namespace translation, the |
| 523 |
former is not.</para> |
| 524 |
|
| 525 |
<para>This setting is particularly useful in combination with the <option>--attach</option> command, |
| 526 |
as it allows later referencing the allocated loop device via |
| 527 |
<filename>/dev/disk/by-loop-ref/…</filename> symlinks. Example: first, set up the loopback device |
| 528 |
via <command>systemd-dissect attach --loop-ref=quux foo.raw</command>, and then reference it in a |
| 529 |
command via the specified filename: <command>cfdisk /dev/disk/by-loop-ref/quux</command>. |
| 530 |
</para> |
| 531 |
|
| 532 |
<xi:include href="version-info.xml" xpointer="v254"/></listitem> |
| 533 |
</varlistentry> |
| 534 |
|
| 535 |
<varlistentry> |
| 536 |
<term><option>--loop-ref-auto</option></term> |
| 537 |
|
| 538 |
<listitem><para>Similar to <option>--loop-ref=</option>, but automatically derive the reference |
| 539 |
string from the specified backing filename, truncating it if necessary.</para> |
| 540 |
|
| 541 |
<xi:include href="version-info.xml" xpointer="v258"/></listitem> |
| 542 |
</varlistentry> |
| 543 |
|
| 544 |
<varlistentry> |
| 545 |
<term><option>--mtree-hash=no</option></term> |
| 546 |
|
| 547 |
<listitem><para>If combined with <option>--mtree</option>, turns off inclusion of file hashes in the |
| 548 |
mtree output. This makes the <option>--mtree</option> faster when operating on large images. |
| 549 |
</para> |
| 550 |
|
| 551 |
<xi:include href="version-info.xml" xpointer="v254"/></listitem> |
| 552 |
</varlistentry> |
| 553 |
|
| 554 |
<varlistentry> |
| 555 |
<term><option>--copy-ownership=</option></term> |
| 556 |
|
| 557 |
<listitem><para>Controls whether file ownership (user and group) is preserved when copying files |
| 558 |
with <option>--copy-from</option> or <option>--copy-to</option>. Takes a boolean, or <option>auto</option>. |
| 559 |
If <literal>yes</literal>, ownership is always preserved. If <literal>no</literal>, ownership is never |
| 560 |
preserved and the current user's UID/GID is used instead. If not specified or <option>auto</option>, |
| 561 |
ownership is preserved when copying directory trees, but not when copying individual regular files. |
| 562 |
</para> |
| 563 |
|
| 564 |
<xi:include href="version-info.xml" xpointer="v260"/></listitem> |
| 565 |
</varlistentry> |
| 566 |
|
| 567 |
<varlistentry> |
| 568 |
<term><option>--system</option></term> |
| 569 |
<term><option>--user</option></term> |
| 570 |
|
| 571 |
<listitem><para>When used together with <option>--discover</option> controls whether to search for |
| 572 |
images installed system-wide or in the user's directories in <varname>$HOME</varname>. If neither |
| 573 |
switch is specified, will search within both scopes.</para> |
| 574 |
|
| 575 |
<xi:include href="version-info.xml" xpointer="v258"/></listitem> |
| 576 |
</varlistentry> |
| 577 |
|
| 578 |
<varlistentry> |
| 579 |
<term><option>--all</option></term> |
| 580 |
|
| 581 |
<listitem><para>If combined with <option>--discover</option>, also shows images that start with a |
| 582 |
dot, i.e. hidden images.</para> |
| 583 |
|
| 584 |
<xi:include href="version-info.xml" xpointer="v258"/></listitem> |
| 585 |
</varlistentry> |
| 586 |
|
| 587 |
<varlistentry> |
| 588 |
<term><option>--quiet</option></term> |
| 589 |
<term><option>-q</option></term> |
| 590 |
|
| 591 |
<listitem><para>If combined with <option>--attach</option>, suppresses output of the used loopback |
| 592 |
block device path.</para> |
| 593 |
|
| 594 |
<xi:include href="version-info.xml" xpointer="v258"/></listitem> |
| 595 |
</varlistentry> |
| 596 |
|
| 597 |
<xi:include href="standard-options.xml" xpointer="image-policy-open" /> |
| 598 |
<xi:include href="standard-options.xml" xpointer="image-filter" /> |
| 599 |
<xi:include href="standard-options.xml" xpointer="no-pager" /> |
| 600 |
<xi:include href="standard-options.xml" xpointer="no-legend" /> |
| 601 |
<xi:include href="standard-options.xml" xpointer="json" /> |
| 602 |
</variablelist> |
| 603 |
</refsect1> |
| 604 |
|
| 605 |
<refsect1> |
| 606 |
<title>Exit status</title> |
| 607 |
|
| 608 |
<para>On success, 0 is returned, a non-zero failure code otherwise. If the <option>--with</option> |
| 609 |
command is used the exit status of the invoked command is propagated.</para> |
| 610 |
</refsect1> |
| 611 |
|
| 612 |
<refsect1> |
| 613 |
<title>Invocation as <command>/sbin/mount.ddi</command></title> |
| 614 |
|
| 615 |
<para>The <command>systemd-dissect</command> executable may be symlinked to |
| 616 |
<filename>/sbin/mount.ddi</filename>. If invoked through that it implements <citerefentry |
| 617 |
project='man-pages'><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry>'s |
| 618 |
"external helper" interface for the (pseudo) file system type <literal>ddi</literal>. This means |
| 619 |
conformant disk images may be mounted directly via</para> |
| 620 |
|
| 621 |
<programlisting># mount -t ddi myimage.raw targetdir/</programlisting> |
| 622 |
|
| 623 |
<para>in a fashion mostly equivalent to:</para> |
| 624 |
|
| 625 |
<programlisting># systemd-dissect --mount myimage.raw targetdir/</programlisting> |
| 626 |
|
| 627 |
<para>Note that since a single DDI may contain multiple file systems it should later be unmounted with |
| 628 |
<command>umount -R targetdir/</command>, for recursive operation.</para> |
| 629 |
|
| 630 |
<para>This functionality is particularly useful to mount DDIs automatically at boot via simple |
| 631 |
<filename>/etc/fstab</filename> entries. For example:</para> |
| 632 |
|
| 633 |
<programlisting>/path/to/myimage.raw /images/myimage/ ddi defaults 0 0</programlisting> |
| 634 |
|
| 635 |
<para>When invoked this way the mount options <literal>ro</literal>, <literal>rw</literal>, |
| 636 |
<literal>discard</literal>, <literal>nodiscard</literal> map to the corresponding options listed above |
| 637 |
(i.e. <option>--read-only</option>, <option>--discard=all</option>, |
| 638 |
<option>--discard=disabled</option>). Mount options are <emphasis>not</emphasis> generically passed on to |
| 639 |
the file systems inside the images.</para> |
| 640 |
</refsect1> |
| 641 |
|
| 642 |
<refsect1> |
| 643 |
<title>Examples</title> |
| 644 |
|
| 645 |
<example> |
| 646 |
<title>Generate a tarball from an OS disk image (<option>--with</option>)</title> |
| 647 |
|
| 648 |
<programlisting># systemd-dissect --with foo.raw tar cz . >foo.tar.gz</programlisting> |
| 649 |
</example> |
| 650 |
|
| 651 |
<para>or alternatively just:</para> |
| 652 |
|
| 653 |
<example> |
| 654 |
<title>Generate a tarball from an OS disk image (<option>--make-archive</option>)</title> |
| 655 |
|
| 656 |
<programlisting># systemd-dissect --make-archive foo.raw foo.tar.gz</programlisting> |
| 657 |
</example> |
| 658 |
</refsect1> |
| 659 |
|
| 660 |
<refsect1> |
| 661 |
<title>See Also</title> |
| 662 |
<para><simplelist type="inline"> |
| 663 |
<member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 664 |
<member><citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 665 |
<member><citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry></member> |
| 666 |
<member><citerefentry><refentrytitle>systemd.v</refentrytitle><manvolnum>7</manvolnum></citerefentry></member> |
| 667 |
<member><ulink url="https://uapi-group.org/specifications/specs/discoverable_partitions_specification">UAPI.2 Discoverable Partitions Specification</ulink></member> |
| 668 |
<member><citerefentry project='man-pages'><refentrytitle>mount</refentrytitle><manvolnum>8</manvolnum></citerefentry></member> |
| 669 |
<member><citerefentry project='man-pages'><refentrytitle>umount</refentrytitle><manvolnum>8</manvolnum></citerefentry></member> |
| 670 |
<member><citerefentry project='man-pages'><refentrytitle>fdisk</refentrytitle><manvolnum>8</manvolnum></citerefentry></member> |
| 671 |
</simplelist></para> |
| 672 |
</refsect1> |
| 673 |
|
| 674 |
</refentry> |