okibcn / wslcompact

Compacts the size of the ever-growing WSL vhdx images.
https://github.com/okibcn/wslcompact
GNU General Public License v3.0
800 stars 19 forks source link

wsl corrupted after compacted #27

Open electroboyz opened 1 year ago

electroboyz commented 1 year ago

compacting was successful but wsl became corrupted, cant start it anymore tried to mount manually but every attempt failed. be careful before running this thing.

polarathene commented 1 year ago

wsl became corrupted

Not a specific WSL distro / disk?

If you get an unresponsive WSL experience and commands like wsl --shutdown no longer responds this isn't necessarily corruption. It can happen when the host filesystem runs out of disk space for example. If you free up disk-space it will still be unresponsive until you reboot the host system but can work again after that.

wslcompact is just providing a convenience for you, running the same commands you could do manually.


Since it's been 2 weeks, is WSL working for you now? Did you do anything specific to make it functional again? Or did you find that restarting your system resolved it like I mentioned?

TheNoFace commented 1 year ago

My Ubuntu 22.04 image is also corrupted after using wslcompact, resizing 466551 MB to 190242 MB.

Starting WSL gives following error:

<3>WSL (12) ERROR: CreateProcessEntryCommon:370: getpwuid(1000) failed 0
<3>WSL (12) ERROR: CreateProcessEntryCommon:374: getpwuid(0) failed 0
#

wsl --shutdown works fine, but restarting make no difference.

electroboyz commented 1 year ago

i fixed it by using fsck, mount the corrupted vhdx on other linux

Sent from my iPhone

On 8 Nov 2023, at 7:00 PM, TheNoFace @.***> wrote:



My Ubuntu 22.04 image is also corrupted after using wslcompact, resizing 466551 MB to 190242 MB.

WSL starts with following error:

<3>WSL (12) ERROR: CreateProcessEntryCommon:370: getpwuid(1000) failed 0 <3>WSL (12) ERROR: CreateProcessEntryCommon:374: getpwuid(0) failed 0 wsl --shutdown works fine, but restarting make no difference. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: ***@***.***>
TheNoFace commented 1 year ago

i fixed it by using fsck, mount the corrupted vhdx on other linux

In my case, fsck and e2fsck was not able to recover my system since wslcompact somehow corrupted necessary system script files with meaningless @^@^ strings.

Use Optimize-VHD for now. Check microsoft/WSL#10244

electroboyz commented 1 year ago

well noted.

Sent from my iPhone

On 9 Nov 2023, at 11:32 AM, TheNoFace @.***> wrote:



i fixed it by using fsck, mount the corrupted vhdx on other linux

In my case, fsck and e2fsck was now able to recover my system since wslcompact somehow corrupted necessary system script files with meaningless @^@^ strings.

Use Optimize-VHDhttps://learn.microsoft.com/en-us/powershell/module/hyper-v/optimize-vhd?view=windowsserver2022-ps for now. Check microsoft/WSL/#10244

— Reply to this email directly, view it on GitHubhttps://github.com/okibcn/wslcompact/issues/27#issuecomment-1803147159, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AVZAEOST7QP6YMBG4M2WGGTYDRME7AVCNFSM6AAAAAA6EEULR2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBTGE2DOMJVHE. You are receiving this because you authored the thread.Message ID: @.***>

dg-nvm commented 6 months ago

the core of this program is wsl --export ""$wsl_distro"" - | wsl --import wslcompact ""$tmp_folder"" - so I guess ask Microsoft why WSL did corrupt the export/import.