core20 icon indicating copy to clipboard operation
core20 copied to clipboard

Add a finalrd script to move filesystems

Open valentindavid opened this issue 4 years ago • 1 comments

/mnt/run/base contains the snap file that is mounted on /. For that reason it is not possible to unmount /mnt/run/base until we have switched root to the shutdown ramfs.

At this point before we move /sysroot/mnt/run/base out of /sysroot so that systemd-shutdown is able to unmount all filesystems.

systemd-shutdown allows hooks. But they are called right after systemd-shutdown. That means we cannot run a hook after the root switch and before systemd-shutdown. For that reason the finalrd hook replaces systemd-shutdown in the ramfs by a wrapper.

This solution is not elegant. In the long term we should try to make systemd-shutdown always move all sub mount points before trying to unmount.

Also, there is still an error message when systemd tries to umount /mnt/run/base before switching root. There does not seem to be anyway to make mnt-run-base.mount perpetual.

valentindavid avatar Dec 01 '21 16:12 valentindavid

Note there also snapcore/snapd#11119 to at least help systemd-shutdown to remount /mnt/run/base read-only. But there are still error messages.

valentindavid avatar Dec 01 '21 16:12 valentindavid

We fixed it in systemd in https://github.com/systemd/systemd/pull/25168 . So it will be fixed in uc24. And along this there is https://github.com/snapcore/core-base/pull/93 and https://github.com/snapcore/core-base/pull/83 which we could backport. On snapd side there was also https://github.com/snapcore/snapd/pull/11119 But this PR should not be merged. So I am closing this.

valentindavid avatar Apr 03 '24 08:04 valentindavid