[systemd-devel] Safe handling of root filesystem on shutdown

Lennart Poettering lennart at poettering.net
Wed Apr 11 08:40:56 PDT 2012


On Wed, 11.04.12 09:08, Daniel Drake (dsd at laptop.org) wrote:

Heya,

> On OLPC laptops we are seeing that ext4 complains on every boot that
> the filesystem wasn't cleanly unmounted.
> 
> Looking at systemd debug logs of a shutdown would seem to agree, I
> can't see where it attempts to remount / read-only as was done with
> sysvinit.
> 
> http://dev.laptop.org/~dsd/20120411/shutdown.txt
> 
> Can anyone point out how this is supposed to work - where is the code
> that looks after the / mount during shutdown/reboot?

So on shutdown after stopping all services we execute systemd-shutdown
as PID 1 replacing the normal systemd process. This is useful to drop
all references to files on disk, so that we can remount the disk r/o
even on upgrades.

systemd-shutdown is basically a single loop that tries to
umount/read-only mount all file systems it finds as long as this changes
the list of active mounts. This code also disables all swaps and detachs
DM/loop devices in the same loop.

> We do have a bit of a strange fs-layout, where our root fs is kept
> inside /versions/pristine/X on the root partition. The initramfs takes
> care of this with some bind-mount and chroot tricks so that it looks
> 'normal' afterwards, but maybe something along these lines is
> confusing systemd.

chroot()? Meh, you should not use chroot for these kinds of things...

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list