microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
16.95k stars 798 forks source link

Core OS changes in Debian Bookworm break under WSL 1 #8927

Open seanthegeek opened 1 year ago

seanthegeek commented 1 year ago

Version

Microsoft Windows [Version 10.0.22000.978]

WSL Version

Kernel Version

Linux 4.4.0-22000-Microsoft

Distro Version

Debian Bookworm

Other Software

No response

Repro Steps

  1. Start with an install of Debian Bullseye
  2. (attempt to) upgrade to Debian Bookworm

Expected Behavior

All system-critical/essential/default packages should upgrade correctly.

Actual Behavior

The installation of usrmerge fails. This bug effectively breaks the entire install of Debian Bookworm on WSL 1.0, because usrmerge is now a required dependency of the essential/system-critical package init-system-helpers, as of version 1.65~exp1 through the current version (1.65.2) of that package.

Diagnostic Logs

Setting up usrmerge (31) ... mv: cannot move '/lib/x86_64-linux-gnu/security' to '/usr/lib/x86_64-linux-gnu/security': Permission denied

FATAL ERROR: mv --no-clobber /lib/x86_64-linux-gnu/security /usr/lib/x86_64-linux-gnu/security: rc=1

You can try correcting the errors reported and running again /usr/lib/usrmerge/convert-usrmerge until it will complete without errors. Do not install or update other Debian packages until the program has been run successfully.

E: usrmerge failed. dpkg: error processing package usrmerge (--configure): installed usrmerge package post-installation script subprocess returned error exit status 1 Errors were encountered while processing: usrmerge E: Sub-process /usr/bin/dpkg returned an error code (1)

seanthegeek commented 1 year ago

Debian bug report https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1020971

seanthegeek commented 1 year ago

Debian bug closed with this note


I've talked with both the internal team and the Debian maintainer of
the WSL image. This is a WSL 1.0 specific issue, and there's not much
we can do in usrmerge about it, as it's related to the underlying
filesystem that we can't touch anyway.

The Debian stable WSL image in the store will be updated shortly to be
merged-usr out of the box, so this won't happen again for new
installations, and on upgrade to bookworm it will be a no-op. Older
installations on WSL 1.0 will have to remove and reinstall, unless a
workaround is found, but for that please use the upstream bug tracker
as here we really can't figure out what the problem is.

Also please note that it would be a good idea to just move to WSL 2.0
for all use cases at this point.

Hence, setting the forwarded address and closing.

-- 
Kind regards,
Luca Boccassi
bluca commented 1 year ago

A new upload to the store has been done by the maintainer, and the Debian image is now merged-usr by default. Users on WSL 1.0 can uninstall and reinstall to fix this problem.

firewave commented 1 year ago

This also applies to Kali Linux which is based on Debian:

Setting up usrmerge (33) ...
mv: cannot move '/lib/x86_64-linux-gnu/security' to '/usr/lib/x86_64-linux-gnu/security': Permission denied

FATAL ERROR:
mv --no-clobber /lib/x86_64-linux-gnu/security /usr/lib/x86_64-linux-gnu/security: rc=1

It just broke with the latest updates from last night though.

firewave commented 1 year ago

The WSL1 Kali Linux now changed to

Setting up systemd (252-2) ...
systemd-machine-id-setup: error while loading shared libraries: libsystemd-shared-251.so: cannot open shared object file: No such file or directory
firewave commented 1 year ago

I was able to bypass the libsystemd-shared-251.so issue by re-adding the older files to the system and getting past that.

Then I ran into the issue that files exist in /lib/x86_64-linux-gnu and /usr/lib/x86_64-linux-gnu which I was able resolve by getting rid of the ones in /usr/lib.

That got me back to the initial issue.

It is extremely weird since it was able to copy/move several files between those folders already. There's no security folder in /usr/lib/x86_64-linux-gnu yet.

firewave commented 1 year ago

I was able to work around the issue by doing

sudo mkdir -p /usr/lib/x86_64-linux-gnu/security
sudo chown root:root /usr/lib/x86_64-linux-gnu/security
sudo chmod 755 /usr/lib/x86_64-linux-gnu/security

That leads to a different error:

FATAL ERROR:
Can't rename /lib: Permission denied at /usr/lib/usrmerge/convert-usrmerge line 286.

Running /usr/lib/usrmerge/convert-usrmerge again doesn't report that error anymore and was able to finish.

After that I was finally able to update the system again.

It did report the following though:

dpkg: warning: This system uses merged-usr-via-aliased-dirs, going behind dpkg's
dpkg: warning: back, breaking its core assumptions. This can cause silent file
dpkg: warning: overwrites and disappearances, and its general tools misbehavior.
dpkg: warning: See <https://wiki.debian.org/Teams/Dpkg/FAQ#broken-usrmerge>.

That suggests to run dpkg-fsys-usrunmess which seems to have cleaned everything up.

bluca commented 1 year ago

That suggests to run dpkg-fsys-usrunmess which seems to have cleaned everything up.

No, that further breaks it, it means you won't be able to upgrade to bookworm. Delete the image and install it from scratch.

Biswa96 commented 1 year ago

Is it possible to use the Linux distribution in WSL2 instead of WSL1?

firewave commented 1 year ago

No, that further breaks it, it means you won't be able to upgrade to bookworm. Delete the image and install it from scratch.

I am using Kali which is rolling so I am possibly already on a bookworm-ish state.

Vebryn commented 1 year ago

A new upload to the store has been done by the maintainer, and the Debian image is now merged-usr by default. Users on WSL 1.0 can uninstall and reinstall to fix this problem.

Still not working, I remove my Debian image using wsl unregister then uninstall it from start menu. Then, I download new image from https://aka.ms/wsl-debian-gnulinux.

I got a fresh Debian 11. After editing sources.list and upgrade:

Preparing to unpack .../archives/usrmerge_35_all.deb ...
Unpacking usrmerge (35) ...
Setting up usrmerge (35) ...
mv: cannot move '/lib/x86_64-linux-gnu/security' to '/usr/lib/x86_64-linux-gnu/security': Permission denied

FATAL ERROR:
mv --no-clobber /lib/x86_64-linux-gnu/security /usr/lib/x86_64-linux-gnu/security: rc=1

You can try correcting the errors reported and running again
/usr/lib/usrmerge/convert-usrmerge until it will complete without errors.
Do not install or update other Debian packages until the program
has been run successfully.

E: usrmerge failed.
dpkg: error processing package usrmerge (--configure):
 installed usrmerge package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 usrmerge
E: Sub-process /usr/bin/dpkg returned an error code (1)
seanthegeek commented 1 year ago

Is it possible to use the Linux distribution in WSL2 instead of WSL1?

Not in some cases. WSL2 requires Hyper-V. Some Virtual desktop systems like AWS WorkSpaces can't run a hypervisor like Hyper-V, because the system itself is a VM.

zhangboyang commented 7 months ago

Here is a pure WSL1 workaround: https://github.com/microsoft/WSL/issues/4279#issuecomment-1846822075