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

Fix mount propagation #85

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions static/usr/lib/core/remount-core-fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

FILESYSTEMS=(
/run/mnt/base
/run/mnt/data
/run/mnt/gadget
/run/mnt/kernel
/run/mnt/snapd
/run/mnt/ubuntu-boot
/run/mnt/ubuntu-save
/run/mnt/ubuntu-seed
/writable
)

for fs in "${FILESYSTEMS[@]}"; do
if mountpoint -q "${fs}"; then
mount --make-private "${fs}"
fi
done
16 changes: 16 additions & 0 deletions static/usr/lib/systemd/system/remount-core-fs.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=Reset propagation of initial mount points
DefaultDependencies=no
Before=local-fs-pre.target
Before=local-fs.target
Copy link
Member

Choose a reason for hiding this comment

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

Is this needed? local-fs-pre.target is expected to happen before afaiu.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is in case something happens with local-fs-pre.target, like something making it fail.

Note that I used roughly the same dependencies as systemd-remount-fs.service.

Before=shutdown.target
Wants=local-fs-pre.target
Copy link
Member

Choose a reason for hiding this comment

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

local-fs-pre.target is pulled already by local-fs.target

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No. It only has After=. Typically the -pre targets are only added if needed.

Copy link
Member

Choose a reason for hiding this comment

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

I see, thanks

Conflicts=shutdown.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/lib/core/remount-core-fs

[Install]
Copy link
Member

Choose a reason for hiding this comment

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

Install section is not needed and it looks like in general we don't add it unless it is the case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I know. I am not sure how I feel about the way we do it. We put everything in /usr/lib/systemd because /etc/systemd/system is writable. But we can always symlink to /dev/null in /etc to mask services installed in /usr. So the reason we use /usr/lib/systemd does not completely work.

I have added the Install section as indication of where it is expected to be installed. And in that way, we could one day move to another approach than what we are doing.

I can remove it.

Copy link
Member

Choose a reason for hiding this comment

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

I actually prefer it to stay as I agree it is better to have it as a hint on where the service is expected. But then we should enforce it in next changes as good practice.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have created #86 so we only use install sections and generate the symlinks.

WantedBy=local-fs.target