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

Startup fails with "unshare: mount ... on ... failed: Invalid argument" #292

Closed
nzbr opened this issue Sep 20, 2023 · 5 comments
Closed
Labels
bug Something isn't working

Comments

@nzbr
Copy link
Member

nzbr commented Sep 20, 2023

Bug description

When trying to start NixOS-WSL, it fails with an error like

[ERROR] systemd startup failed!
[ERROR] stderr:
unshare: mount /proc/455/ns/mnt on /run/nixos-wsl/ns/mount failed: Invalid argument
+ grep -q binfmt_misc /proc/filesystems
+ mount -t binfmt_misc binfmt_misc /proc/sys/fs/binfmt_misc
+ exec systemd
[ERROR] stdout:

To Reproduce

Update WSL to the new 2.0.0.0 release and try to start NixOS using syschdemd

Resolution

Run the following commands to update to the latest NixOS-WSL version and switch to native systemd:

wsl -d NixOS -e /nix/var/nix/profiles/system/sw/bin/bash

This shoudl give you a root shell in the NixOS distro. From there run:

/nix/var/nix/profiles/system/activate
. /etc/set-environment

Now update NixOS-WSL by running

rm -rf /etc/nixos/nixos-wsl
curl -L https://api.github.com/repos/nix-community/nixos-wsl/tarball/main | tar -xzv
mv nix-community-NixOS-WSL-* /etc/nixos/nixos-wsl
nix-channel --add https://nixos.org/channels/nixos-23.05 nixos
nix-channel --update

Use an Editor (nano/vim) to edit /etc/nixos/configuration.nix and set the option

    wsl.nativeSystemd = true;

Save the file and run (this will print some errors, but that's fine)

nixos-rebuild switch

After that, exit back to your windows shell and run

wsl -t NixOS
wsl -d NixOS

If this gives you a shell as the default user, everything should be working again

@nzbr nzbr added bug Something isn't working wontfix This will not be worked on labels Sep 20, 2023
@nzbr nzbr pinned this issue Sep 20, 2023
@fc1943s
Copy link

fc1943s commented Sep 22, 2023

almost! error at the end of rebuild: (tried with an old installation and a fresh install)
image

@K900
Copy link
Contributor

K900 commented Sep 30, 2023

That's a warning, not an error.

@K900
Copy link
Contributor

K900 commented Sep 30, 2023

The actual issue is fixed on main, so I'll close the issue, but leave it pinned for visibility.

@K900 K900 closed this as completed Sep 30, 2023
@nzbr
Copy link
Member Author

nzbr commented Sep 30, 2023

Wouldn't it still fail with syschdemd? I'd not say it's fixed but rather no longer relevant (therefore the wontfix label)

@K900
Copy link
Contributor

K900 commented Sep 30, 2023

I fixed it on main.

@nzbr nzbr removed the wontfix This will not be worked on label Sep 30, 2023
@nzbr nzbr unpinned this issue Oct 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants