Fix: add systemd unit to make /mnt/wsl recursive slave before umount#41086
Open
chemwolf6922 wants to merge 5 commits into
Open
Fix: add systemd unit to make /mnt/wsl recursive slave before umount#41086chemwolf6922 wants to merge 5 commits into
chemwolf6922 wants to merge 5 commits into
Conversation
2 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a WSL2 systemd shutdown regression where unmounts under /mnt/wsl in one systemd-enabled distro can propagate across shared mount peer groups and break other running distros (notably Docker Desktop’s WSL integration). It does so by generating/enabling a systemd unit that switches /mnt/wsl to rslave propagation during shutdown, preventing unmount propagation to other namespaces.
Changes:
- Generate and enable a
wsl-mnt-guard.serviceunit to runmount --make-rslave /mnt/wslon shutdown (ExecStop) before unmount propagation can escape the terminating distro. - Add a Windows UnitTests regression test that creates a shared mount under
/mnt/wsl, terminates a peer systemd distro, and verifies the mount remains available.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/linux/init/init.cpp |
Generates and enables a new systemd unit (wsl-mnt-guard) to prevent shutdown unmount propagation from escaping the distro. |
test/windows/UnitTests.cpp |
Adds a regression test to ensure a /mnt/wsl shared mount survives termination of a peer systemd-enabled distro. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of the Pull Request
Systemd globally unmounts shared mounts under /mnt/wsl during graceful shutdown.
This PR adds a systemd unit to set /mnt/wsl as recursive slave during shutdown before unmounting to avoid the unmount from propagating to other namespaces.
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed
Add regression test:
UnitTests::UnitTests::SharedMountSurvivesDistroTermination