Giter Site home page Giter Site logo

Comments (2)

QAston avatar QAston commented on May 20, 2024

Looks like this was solved in another project by disabling some systemd services and explictly mounting binfmt_misc:
DamionGans/ubuntu-wsl2-systemd-script#15
https://github.com/DamionGans/ubuntu-wsl2-systemd-script/pull/17/files

It'd be great to have these changes ported here, as disabling the service alone doesn't fix the issue.

from subsystemctl.

QAston avatar QAston commented on May 20, 2024

I resolved the issue locally by mounting binfmt:

diff --git a/src/bottle.rs b/src/bottle.rs
index f04804a..cbb4768 100644
--- a/src/bottle.rs
+++ b/src/bottle.rs
@@ -243,6 +243,14 @@ fn exec_systemd2_child(systemd_bin: CString) -> Result<(), error::Error> {
     )
     .expect("proc mount failure");

+    nix::mount::mount(
+        Some(OsStr::new("binfmt_misc")),
+        OsStr::new("/proc/sys/fs/binfmt_misc"),
+        Some(OsStr::new("binfmt_misc")),
+        MsFlags::MS_NOSUID | MsFlags::MS_NODEV | MsFlags::MS_NOEXEC,
+        OS_NONE,
+    )
+    .expect("binfmt mount failure");
     nix::unistd::chdir("/").unwrap();
     nix::unistd::setgid(nix::unistd::Gid::from_raw(0)).unwrap();
     nix::unistd::setuid(nix::unistd::Uid::from_raw(0)).unwrap();

and disabling binfmt mount related services

sudo mkdir -p /etc/systemd/wsl2-incompatible/user/sockets.target.wants/ /lib/systemd/wsl2-incompatible/system/sysinit.target.wants/ /usr/lib/systemd/wsl2-incompatible/system/
# remove binfmt mounting done by systemd because it doesn't work and triggers 'too many simlinks error
sudo mv /lib/systemd/system/sysinit.target.wants/proc-sys-fs-binfmt_misc.automount /lib/systemd/wsl2-incompatible/system/sysinit.target.wants/
sudo mv /lib/systemd/system/sysinit.target.wants/systemd-binfmt.service /lib/systemd/wsl2-incompatible/system/sysinit.target.wants/
sudo mv /usr/lib/systemd/system/proc-sys-fs-binfmt_misc.automount /usr/lib/systemd/wsl2-incompatible/system/
sudo mv /usr/lib/systemd/system/proc-sys-fs-binfmt_misc.mount /usr/lib/systemd/wsl2-incompatible/system/

from subsystemctl.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.