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

2015-02-16 Thread Lennart Poettering
On Fri, 13.02.15 23:15, Lorenzo Pistone (blaffabla...@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
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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

2015-02-13 Thread Tom Gundersen
On Fri, Feb 13, 2015 at 11:15 PM, Lorenzo Pistone
blaffabla...@gmail.com wrote:
 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.

I don't know all the details of your setup, so take this with a pinch of salt:

Usually it is the task of whomever set up / in the first place to tear
it down. So if your initrd sets upd the ndb device, you might want to
have a logic similar to what dracut does where you would jump back
into the initrd at shutdown and cleanly tear stuff down from there.

HTH,

Tom
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel