[systemd-devel] auto-unmount via BindsTo= is annoying

Andrei Borzenkov arvidjaar at gmail.com
Sat Apr 4 22:38:22 PDT 2015


В Sat, 4 Apr 2015 12:55:34 +0300
Mantas Mikulėnas <grawity at gmail.com> пишет:

> On Sat, Apr 4, 2015 at 7:37 AM, Andrei Borzenkov <arvidjaar at gmail.com>
> wrote:
> 
> > В Fri, 3 Apr 2015 21:19:24 +0300
> > Mantas Mikulėnas <grawity at gmail.com> пишет:
> >
> > > Previously udev used to undo mounts when a device *disappeared;* when
> > > systemd took over the task, it started unmounting things as soon as it
> > > noticed that the device *doesn't exist right now.* While similar, the new
> > > behavior can be annoying, since it also triggers if the device never
> > > existed in the first place. For example:
> > >
> > > ~ My fstab has "/dev/mapper/luks-backups → /mnt/backup". I want to mount
> > > another disk there (which has a different label), but even though `mount
> > > /dev/sdb1 /mnt/backup` succeeds, the directory remains empty and won't
> > show
> > > up in `findmnt`.
> > >
> > > After a few retries I check dmesg and notice systemd saying that
> > > "mnt-backup.mount is bound to an inactive device; stopping". Which means,
> > > if my fstab says disk X is mounted there, systemd won't let me mount
> > > anything else but disk X at that location.
> > >
> > > ~ I had to boot to emergency mode due to reasons, and attempted to mount
> > > /boot & /boot/efi in order to fix something. Since my fstab had
> > > "/dev/disk/by-partlabel/boot → /boot", any attempts to mount anything at
> > > /boot get immediately undone – emergency mode has no udev, so I get
> > > "boot.mount is bound to an inactive device; stopping" all over again.
> > >
> >
> > Do these commits help?
> >
> > commit 628c89cc68ab96fce2de7ebba5933725d147aecc
> > Author: Lennart Poettering <lennart at poettering.net>
> > Date:   Fri Feb 27 21:55:08 2015 +0100
> >
> >     core: rework device state logic
> >
> > commit 496068a8288084ab3ecf8b179a8403ecff1a6be8
> > Author: Martin Pitt <martin.pitt at ubuntu.com>
> > Date:   Fri Mar 13 08:35:59 2015 +0100
> >
> >     core: don't change removed devices to state "tentative"
> >
> 
> Nope, this is already on 093c2cfe3b1.
> 
> 

I think the problem is dependent on unit load state (without claiming
to fully understand how and when systemd evicts unit from cache).

When mount unit is not in cache, systemd creates *new* definition and
sets BindsTo current device where filesystem is currently mounted.

If mount unit is present in cache, it already has some BindsTo. When
systemd processes mountinfo it apparently neither removes old nor adds
new BindsTo for new device. Which makes check kick in later.

When system stops in emergency mode due to device not present, mount
unit is kept loaded. Unfortunately, the only way to check for it is

systemctl -a | grep

because any attempt to explicitly list specific unit will trigger its
loading, screwing up its Load state.

I see multiple issues here

a) it would be helpful if systemctl status/show could differentiate
between unit loaded due to this systemctl call and unit having been
loaded before. May be "--do-no-load" flag to systemctl or something
like this.

b) when systemd finds out that What is different in mountinfo, it
should remove BindsTo for old What. May be it should really simply
always drop old mount unit (present in cache) and build new one from
scratch. Or push old definition (to support stacked mounts).

c) The resulting unit should be clearly marked as different from
definition on disk. I.e.

bor at opensuse:~/src/systemd> systemctl status boot.mount
boot.mount - /boot
   Loaded: loaded (/etc/fstab)
   Active: active (mounted) since Пт 2015-03-27 11:09:08 MSK; 1 weeks 1 days ago
    Where: /boot
     What: /dev/sda1

bor at opensuse:~/src/systemd> sudo mount /dev/mapper/
control           system-docker     system-root       
system-datastore  system-home       system-swap       
bor at opensuse:~/src/systemd> sudo mount /dev/mapper/system-docker /boot
root's password:
bor at opensuse:~/src/systemd> systemctl status boot.mount
boot.mount - /boot
   Loaded: loaded (/etc/fstab)
                   ^^^^^^^^^^^
   Active: active (mounted) since Пт 2015-03-27 11:09:08 MSK; 1 weeks 1 days ago
    Where: /boot
     What: /dev/mapper/system-docker
           ^^^^^^^^^^^^^^^^^^^^^^^^^

That is obviously wrong. What is mounted now comes *NOT*
from /etc/fstab, and it should not be claiming it.


More information about the systemd-devel mailing list