[systemd-devel] Unmount / right before reboot/shutdown/kexec

Lennart Poettering lennart at poettering.net
Mon Feb 16 02:14:08 PST 2015


On Fri, 13.02.15 23:15, Lorenzo Pistone (blaffablaffa at gmail.com) wrote:

> Hello,
> the cloud provider I'm testing has rather strange setup. All volumes are
> provided through nbd, including /, and they have to be unmounted cleanly for
> reboot to work successfully, because the rebooted or kexec'd kernel will
> retry to attach them and if there host thinks there's already a connection
> mounting will fail. However, unmounting needs to happen as the very last
> thing before rebooting, because after that / will disappear. They currently
> have an unholy hack: they replace systemd-reboot.service with their own
> version that simply disconnects / and calls 'echo b > /proc/sysrq-trigger'.
> I believe this is far from the correct way of doing things (among the other
> things, an update of systemd replaces systemd-reboot.service). How can this
> be done more cleanly?
> 
> Please don't argue whether having / as a ndb device is a good thing. It is
> not my call.

Note that unmounting the root directory is only possible if you do not
have any binaries running that are located on it (since they keep the
root fs busy)

We support a scheme like this if the initrd is set up for it. The idea
here is basically that the initrd runs before the root fs is up, and
takes over again after the root fs is no longer used. It sets up the
rootfs and is also responsible to taking it down again. Since the
initrd brings its own file hierarchy and binaries it can unmount the
root fs without any limitations.

Dracut (and thus Fedora) among other initrds, makes use of this, and
unmounts the root fs at every shutdown.

For details about this interface see:

http://www.freedesktop.org/wiki/Software/systemd/InitrdInterface/

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list