[systemd-devel] [PATCH] Re: fstab mounts get unmounted during boot (.device unit bouncing?) -- solution

Lennart Poettering lennart at poettering.net
Thu Feb 12 02:22:34 PST 2015


On Thu, 12.02.15 10:40, Martin Pitt (martin.pitt at ubuntu.com) wrote:

> So right after we popped out of initramfs (which doesn't have an
> fstab, nor /etc/mtab, nor does it do anything else than mouting /
> read-only) we see all these mounts which can't possibly happen that
> early -- e. g. run-user-115.mount or /home/martin (which is on
> ecryptfs). So I finally discovered that a packaging bug in
> lxcfs turned /etc/mtab from a /proc/mounts symlink back into a file,
> and mount_load_proc_self_mountinfo() parsed that to instantiate all
> those mounts from the previous boot into mount unit, causing that
> effect.
> 
> So of course we'll fix that packaging bug, but there are still times
> when /etc/mtab might be a file; e. g. the first time you boot systemd
> after an upgrade.
> 
> To make systemd robust against this, I fixed
> mount_load_proc_self_mountinfo() to actually do what it intends to do,
> instead of loading /etc/mtab (which is still util-linux' default for
> mnt_table_parse_mtab()).

Urks, we never want to read /etc/mtab from PID 1, indeed. I am a bit
puzzled by mnt_table_parse_mtab() thiugh. The name suggests it parses
/etc/mtab files (which have the same format as /proc/self/mounts). But
Can we really just arse /proc/self/mountinfo to it, which has a very
different format?

Karel, can you elaborate on this?

I raelly want to keep /etc/mtab out of all codepaths in PID 1. What's
the right way to do that with libmnt? We want only the stuff from
/proc/self/mountinfo, plus the stuff from /run, merged into one!

Karel, is this patch by Martin what we should be doing?

> From 4d3bcd8cec801d7a2a773388ae281ca692a7f2d5 Mon Sep 17 00:00:00 2001
> From: Martin Pitt <martin.pitt at ubuntu.com>
> Date: Thu, 12 Feb 2015 10:30:00 +0100
> Subject: [PATCH] core/mount: ensure that we parse /proc/self/mountinfo
> 
> util-linux' mnt_table_parse_mtab() still defaults to parsing /etc/mtab. So if
> that is a file [1] , we parse outdated information during boot, leading to creating
> mount units for nonexisting mounts which later have to get cleaned up. The
> cleanup races with mounting them from fstab, which sometimes causes fstab
> mounts to get unmounted again during boot.
> 
> So explicitly specify the file that we actually want to parse.
> 
> [1] first boot after a distro upgrade, or a package bug, or administrators
>     configuring it explicitly for some reason
> 
> https://launchpad.net/bugs/1419623
> ---
>  src/core/mount.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/core/mount.c b/src/core/mount.c
> index f3977e6..61fd526 100644
> --- a/src/core/mount.c
> +++ b/src/core/mount.c
> @@ -1566,7 +1566,7 @@ static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) {
>          if (!tb || !itr)
>                  return log_oom();
>  
> -        r = mnt_table_parse_mtab(tb, NULL);
> +        r = mnt_table_parse_mtab(tb, "/proc/self/mountinfo");
>          if (r < 0)
>                  return r;
>  
> -- 
> 2.1.4
> 


Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list