Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a finalrd script to move filesystems #124

Conversation

valentindavid
Copy link
Contributor

/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.

`/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
Copy link
Contributor Author

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.

# systemd-shutdown has hooks, but they are run either before
# switch, or after unmounts.
# It would be better to make systemd-shutdown smarter and move
# all found mounts before trying to unmount them.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

somehow i would rather try to fix this in systemd-shutdown itself, instead of adding all of this into core20. Given that systemd-shutdown is C and can execute all of these things.

or for example, if some else can be done as a finalrd hook easier.

For example, can we have finalrd/core.finalrd hook that simply does umount --lazy /run/mnt/* ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I will try to change systemd-shutdown to move filesystems in sub mount points. It should be an acceptable improvement for upstream.

The issue with --lazy is that it does not give you an error if it does not manage to unmount before shutdown. At least I am not aware of any way to check the active detached mounts. If only we had that, we could just mark run-mnt-base.mount as LazyUmount=yes, and verify it was really unmounted in a system-shutdown hook after systemd-shutdown has umounted /sysroot.

@valentindavid
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants