return 0;
}
+static bool attach_in_initrd(const char *name, const char *options) {
+ assert(name);
+
+ /* Imply x-initrd.attach in case the volume name is among those defined in the Discoverable Partition
+ * Specification for partitions that we require to be mounted during the initrd → host transition,
+ * i.e. for the root fs itself, and /usr/. This mirrors similar behaviour in
+ * systemd-fstab-generator. */
+
+ return fstab_test_option(options, "x-initrd.attach\0") ||
+ STR_IN_SET(name, "root", "usr");
+}
+
static int create_disk(
const char *name,
const char *device,
*tmp_fstype = NULL, *filtered_header = NULL, *headerdev_mount = NULL;
_cleanup_fclose_ FILE *f = NULL;
const char *dmname;
- bool noauto, nofail, swap, netdev, attach_in_initrd;
+ bool noauto, nofail, swap, netdev;
int r, detached_header, keyfile_can_timeout, tmp;
assert(name);
nofail = fstab_test_yes_no_option(options, "nofail\0" "fail\0");
swap = fstab_test_option(options, "swap\0");
netdev = fstab_test_option(options, "_netdev\0");
- attach_in_initrd = fstab_test_option(options, "x-initrd.attach\0");
keyfile_can_timeout = fstab_filter_options(options,
"keyfile-timeout\0",
fprintf(f, "After=remote-fs-pre.target\n");
/* If initrd takes care of attaching the disk then it should also detach it during shutdown. */
- if (!attach_in_initrd)
- fprintf(f, "Conflicts=umount.target\n");
+ if (!attach_in_initrd(name, options))
+ fprintf(f,
+ "Conflicts=umount.target\n"
+ "Before=umount.target\n");
if (keydev) {
_cleanup_free_ char *unit = NULL, *umount_unit = NULL;
if (path_startswith(u, "/dev/"))
fprintf(f,
"BindsTo=%s\n"
- "After=%s\n"
- "Before=umount.target\n",
+ "After=%s\n",
d, d);
else
/* For loopback devices, add systemd-tmpfiles-setup-dev.service