diff --git a/man/systemd-remount-fs.service.xml b/man/systemd-remount-fs.service.xml index 988a617406296..0c1562142fdf3 100644 --- a/man/systemd-remount-fs.service.xml +++ b/man/systemd-remount-fs.service.xml @@ -50,6 +50,13 @@ For a longer discussion of kernel API file systems see API File Systems. + + Note: systemd-remount-fs.service is usually pulled in by + systemd-fstab-generator8, + hence it is also affected by the kernel command line option fstab=, which may be used + to disable the generator. It may also pulled in by + systemd-gpt-auto-generator8, + which is affected by systemd.gpt_auto and other options. @@ -57,7 +64,9 @@ systemd1, fstab5, - mount8 + mount8, + systemd-fstab-generator8, + systemd-gpt-auto-generator8 diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index cebfed25cb290..b5084c955c943 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -890,6 +890,8 @@ static int run(const char *dest, const char *dest_early, const char *dest_late) /* If running in the initrd also parse the /etc/fstab from the host */ if (in_initrd()) r3 = parse_fstab(true); + else + r3 = generator_enable_remount_fs_service(arg_dest); } return r < 0 ? r : r2 < 0 ? r2 : r3; diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c index d9e29c47f374c..09c0bcba2da20 100644 --- a/src/gpt-auto-generator/gpt-auto-generator.c +++ b/src/gpt-auto-generator/gpt-auto-generator.c @@ -467,13 +467,13 @@ static int add_root_rw(DissectedPartition *p) { return 0; } + (void) generator_enable_remount_fs_service(arg_dest); + path = strjoina(arg_dest, "/systemd-remount-fs.service.d/50-remount-rw.conf"); (void) mkdir_parents(path, 0755); r = write_string_file(path, "# Automatically generated by systemd-gpt-generator\n\n" - "[Unit]\n" - "ConditionPathExists=\n\n" /* We need to turn off the ConditionPathExist= in the main unit file */ "[Service]\n" "Environment=SYSTEMD_REMOUNT_ROOT_RW=1\n", WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_NOFOLLOW); @@ -678,6 +678,9 @@ static int add_root_mount(void) { return r; } + /* Note that we do not need to enable systemd-remount-fs.service here. If + * /etc/fstab exists, systemd-fstab-generator will pull it in for us. */ + return add_mount( "root", "/dev/gpt-auto-root", diff --git a/src/shared/generator.c b/src/shared/generator.c index ce8305c236649..55bd024f9e9cd 100644 --- a/src/shared/generator.c +++ b/src/shared/generator.c @@ -499,6 +499,12 @@ int generator_hook_up_growfs( return generator_add_symlink(dir, where_unit, "wants", unit); } +int generator_enable_remount_fs_service(const char *dir) { + /* Pull in systemd-remount-fs.service */ + return generator_add_symlink(dir, SPECIAL_LOCAL_FS_TARGET, "wants", + SYSTEM_DATA_UNIT_PATH "/" SPECIAL_REMOUNT_FS_SERVICE); +} + void log_setup_generator(void) { log_set_prohibit_ipc(true); log_setup_service(); diff --git a/src/shared/generator.h b/src/shared/generator.h index e2209657cd623..fa002a91143ad 100644 --- a/src/shared/generator.h +++ b/src/shared/generator.h @@ -50,6 +50,8 @@ int generator_hook_up_growfs( const char *where, const char *target); +int generator_enable_remount_fs_service(const char *dir); + void log_setup_generator(void); /* Similar to DEFINE_MAIN_FUNCTION, but initializes logging and assigns positional arguments. */ diff --git a/units/meson.build b/units/meson.build index d69508467fb34..3820585051d52 100644 --- a/units/meson.build +++ b/units/meson.build @@ -186,8 +186,7 @@ in_units = [ ['systemd-quotacheck.service', 'ENABLE_QUOTACHECK'], ['systemd-random-seed.service', 'ENABLE_RANDOMSEED', 'sysinit.target.wants/'], - ['systemd-remount-fs.service', '', - 'local-fs.target.wants/'], + ['systemd-remount-fs.service', ''], ['systemd-resolved.service', 'ENABLE_RESOLVE', join_paths(pkgsysconfdir, 'system/dbus-org.freedesktop.resolve1.service') + ' ' + join_paths(pkgsysconfdir, 'system/multi-user.target.wants/')], diff --git a/units/systemd-remount-fs.service.in b/units/systemd-remount-fs.service.in index 2e5b75ec03b61..4f4304d68e208 100644 --- a/units/systemd-remount-fs.service.in +++ b/units/systemd-remount-fs.service.in @@ -16,7 +16,6 @@ Conflicts=shutdown.target After=systemd-fsck-root.service Before=local-fs-pre.target local-fs.target shutdown.target Wants=local-fs-pre.target -ConditionPathExists=/etc/fstab [Service] Type=oneshot