Comment 6 for bug 1419623

Revision history for this message
Martin Pitt (pitti) wrote : Re: systemd unmounts partitions from fstab

I finally understand what's going on. This started a few weeks ago when we got lxcfs. What happens:

 - lxcfs' upstart job and systemd unit have this gem:
     sed -i "/^lxcfs \/var\/lib\/lxcfs fuse.lxcfs/d" /etc/mtab

   This will turn /etc/mtab into a file if it was a symlink to /proc/mounts. But these days we actually want it to be a symlink, as /etc/mtab as a static file is just a braindead and broken concept.

 - When systemd starts up, it parses existing mounts (via /etc/mtab) and creates mounts for them. This will include all the old mounts from the previous boot due to the previous issue. That's what triggers all these "dead -> mounted" transitions for all mounts right at the beginning of boot. But as the backing devices of them aren't discovered/there yet, but a mount unit is always bound to its underlying device unit, systemd cleans them up, i. e. stops them. This is usually meant for cleaning stale mounts from unplugged devices; it also makes sense here as these mounts indeed are not mounted at the moment.

 - Later on, the fstab generated mounts are actually being executed. But this races with the async mount cleanup handler from above, so depending on the particular machine, installed services, and current wind speed it may happen at a harmless (before the fstab mounts) or at a bad time (after the fstab mounts).

 - Even later, our debian-fixup.service transitions /etc/mtab from a file to a symlink. This is supposed to be an one-time migration, but lxcfs always reverts that during shutdown.