Warning - moving a wsl2 distribution without admin breaks it
wsl --manage <distribution> --move <target>happily starts without admin permissions but fails midway, leaving a broken installation behind. Luckily it's easy to roll back by moving theext4.vhdxfile back to the original location. Use the export-import mechanism instead, since that actually works...
I was trying to set up VLLM with docker on my WSL Ubuntu when I ran out of disk space. I'd forgotten that I never completed the move to a larger disk, so this seemed like a good time to start:
wsl --shutdown
wsl --manage ubuntu --move D:\me\wsl
Everything appears to work, until
Access is denied. Error code: Wsl/Service/MoveDistro/E_ACCESSDENIED
Wait, what? If this shit requires admin permissions, why not prompt it at the start?
wsl
Failed to attach disk 'C:\Users\me\AppData\Local\wsl{db572166-6340-4108-ba8f-a0703be57406}\ext4.vhdx' to WSL2: The system cannot find the file specified.
Oh, did I just destroy my dev environment? (Note to self - higher priority on the cloud-init thing...)
wsl --mount D:\me\wsl\ext4.vhdx
Failed to attach disk 'D:\me\wsl\ext4.vhdx' to WSL2: Error: 0x80040315 Error code: Wsl/Service/AttachDisk/MountDisk/WSL_E_ELEVATION_NEEDED_TO_MOUNT_DISK
Right, that's the reason, probably.
Luckily it was easy enough to rollback by copying the vhdx file back to the location the original error message mentioned, but gotta say, cold sweat wasn't far as I envisioned tomorrow starting with setting up the dev env from scratch...
Update - admin doesn't work either
Wow. I jumped to admin session:
wsl --manage ubuntu --move D:\me\wsl
There is no distribution with the supplied name.
wat
wsl --list
Windows Subsystem for Linux has no installed distributions.
Right.
The admin wsl context is separate from the local user context. I don't know how it should be setup for the --move to work, but I give up at this point.
The older export-import worked at least:
wsl --shutdown
wsl --export Ubuntu D:\backup\ubuntu.tar
wsl --unregister Ubuntu
wsl --import Ubuntu D:\me\wsl D:\backup\ubuntu.tar --version 2
wsl --set-default Ubuntu
Thoughts, comments? Send me an email!