From 9e5f0f92915b777308797294c6e103e430957b5d Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Thu, 14 Mar 2013 13:12:10 +0100 Subject: Make initrd.target the default target in the initrd First, rename root-fs.target to initrd-root-fs.target to clarify its usage. Mount units with "x-initrd-rootfs.mount" are now ordered before initrd-root-fs.target. As we sometimes construct /sysroot mounts in /etc/fstab in the initrd, we want these to be mounted before the initrd-root-fs.target is active. initrd.target can be the default target in the initrd. (normal startup) : : v basic.target | ______________________/| / | | sysroot.mount | | | v | initrd-root-fs.target | | | v | initrd-parse-etc.service (custom initrd services) | | v | (sysroot-usr.mount and | various mounts marked | with fstab option | x-initrd.mount) | | | v | initrd-fs.target | | \______________________ | \| v initrd.target | v initrd-cleanup.service isolates to initrd-switch-root.target | v ______________________/| / | | initrd-udevadm-cleanup-db.service | | (custom initrd services) | | | \______________________ | \| v initrd-switch-root.target | v initrd-switch-root.service | v switch-root --- src/fstab-generator/fstab-generator.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/fstab-generator') diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index b4fb1344e6..cf85d3189a 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -199,6 +199,12 @@ static bool mount_in_initrd(struct mntent *me) { streq(me->mnt_dir, "/usr"); } +static bool mount_is_rootfs(struct mntent *me) { + assert(me); + + return hasmntopt(me, "x-initrd-rootfs.mount"); +} + static int add_mount(const char *what, const char *where, const char *type, const char *opts, int passno, bool noauto, bool nofail, bool automount, bool isbind, const char *pre, const char *post, const char *source) { @@ -434,6 +440,9 @@ static int parse_fstab(const char *prefix, bool initrd) { if (initrd) { post = SPECIAL_INITRD_FS_TARGET; pre = NULL; + } else if (mount_is_rootfs(me)) { + post = SPECIAL_INITRD_ROOT_FS_TARGET; + pre = NULL; } else if (mount_is_network(me)) { post = SPECIAL_REMOTE_FS_TARGET; pre = SPECIAL_REMOTE_FS_PRE_TARGET; @@ -525,7 +534,7 @@ static int parse_new_root_from_proc_cmdline(void) { log_debug("Found entry what=%s where=/sysroot type=%s", what, type); r = add_mount(what, "/sysroot", type, opts, 0, false, false, false, - false, NULL, SPECIAL_ROOT_FS_TARGET, "/proc/cmdline"); + false, NULL, SPECIAL_INITRD_ROOT_FS_TARGET, "/proc/cmdline"); return (r < 0) ? r : 0; } -- cgit v1.2.3-54-g00ecf