OpenSUSE On Windows WSL2 with systemd working

I am trying to get my OpenSUSE 15.4 WSL to work on Windows with systemd.

The Guides for getting systemd working on WSL is using Ubuntu.
It works on my Ubuntu WSL, but not on my OpenSUSE WSL

svmoe@AAP-CND2081462:~$ cat /etc/wsl.conf
[boot]
systemd=true

When OpenSUSE WSL starts I get this error

Catastrophic failure
Error code: Wsl/Service/CreateInstance/E_UNEXPECTED
[process exited with code 4294967295 (0xffffffff)]

Is there any way I can recover this? Without removing OpenSUSE and reinstalling it?
That is what I had to do last time.

Try installing wsl_systemd pattern

zypper install -t pattern wsl_systemd

Mount Leap vhdx in another WSL instance or Hyper-V VM and remove systemd=true, then try installing wsl_systemd pattern.

Mount Leap vhdx in another WSL instance

How do I do that?

I tried to use affuse based on these instructions
How to attach other vhdx files to WSL2? · Issue #4574 · microsoft/WSL · GitHub

djviking@AAP-CND2081462:~$ sudo affuse /mnt/c/Users/svmoe/AppData/Local/Packages/46932SUSE.openSUSELeap15.4_022rs5jcyhyac/LocalState/ext4.vhdx /mnt/opensuse/
Can't open image file: Invalid argument

I also tried this

PS C:\Users\svmoe> wsl --mount --vhd C:\Users\djviking\AppData\Local\Packages\46932SUSE.openSUSELeap15.4_022rs5jcyhyac\LocalState\ext4.vhdx --bare
Failed to attach disk '\\?\C:\Users\svmoe\AppData\Local\Packages\46932SUSE.openSUSELeap15.4_022rs5jcyhyac\LocalState\ext4.vhdx' to WSL2: The process cannot access the file because it is being used by another process.
Error code: Wsl/Service/AttachDisk/MountVhd/0x80070020

The wsl mount work, when I took a wsl --shutdown first.

PS C:\Users\djviking> wsl --shutdown
PS C:\Users\djvikling> wsl -d Ubuntu --mount --vhd C:\Users\svmoe\AppData\Local\Packages\46932SUSE.openSUSELeap15.4_022rs5jcyhyac\LocalState\ext4.vhdx --bare
The operation completed successfully.
PS C:\Users\djviking> wsl -d Ubuntu
djviking@AAP-CND2081462:/mnt/c/Users/svmoe$

Now. How do I access it?

I tried this guide to access and mount the OpenSUSE Leap in Ubuntu
[WSL2] Mount vhdx to WSL2 · Cody Bunch

However I was unable to remove the file /etc/wsl.conf

djviking@AAP-CND2081462:/mnt/opensuse/etc$ rm wsl.conf
rm: cannot remove 'wsl.conf': Read-only file system
djviking@AAP-CND2081462:/mnt/opensuse/etc$ sudo rm wsl.conf
rm: cannot remove 'wsl.conf': Permission denied

I needed to change -ro to -rw, but I am still unable to remove the file

djviking@AAP-CND2081462:~$ guestmount --add /mnt/c/Users/djviking/AppData/Local/Packages/46932SUSE.openSUSELeap15.4_022rs5jcyhyac/LocalState/ext4.vhdx --rw -i ./import/
libguestfs: warning: current user is not a member of the KVM group (group ID 109). This user cannot access /dev/kvm, so libguestfs may run very slowly. It is recommended that you 'chmod 0666 /dev/kvm' or add the current user to the KVM group (you might need to log out and log in again).
djviking@AAP-CND2081462:~$ sudo rm import/etc/wsl.conf
rm: cannot remove 'import/etc/wsl.conf': Permission denied

I have no idea what you are doing.

PS C:\Users\Administrator> wsl --mount --name Leap154 --vhd 'D:\WSL\Leap 15.4\ext4.vhdx'
The disk was successfully mounted as '/mnt/wsl/Leap154'.
Note: The location will be different if you have modified the automount.root setting in /etc/wsl.conf.
To unmount and detach the disk, run 'wsl.exe --unmount \\?\D:\WSL\Leap 15.4\ext4.vhdx'.
PS C:\Users\Administrator>

and in WSL distribution

andrei@tumbleweed:~> sudo touch /mnt/wsl/Leap154/etc/x
andrei@tumbleweed:~> sudo rm /mnt/wsl/Leap154/etc/x
1 Like

Using your mount command
then running Ubuntu WSL, I was able to delete the file

PS C:\Users\djviking> wsl --mount --name Leap154 --vhd C:\Users\djviking\AppData\Local\Packages\46932SUSE.openSUSELeap15.4_022rs5jcyhyac\LocalState\ext4.vhdx
The disk was successfully mounted as '/mnt/wsl/Leap154'.
Note: The location will be different if you have modified the automount.root setting in /etc/wsl.conf.
To unmount and detach the disk, run 'wsl.exe --unmount \\?\C:\Users\djviking\AppData\Local\Packages\46932SUSE.openSUSELeap15.4_022rs5jcyhyac\LocalState\ext4.vhdx'.