How to Fix the WSL2 “Read-only file system” Error
You sit down to work, type something innocent like touch file, and WSL answers:
touch: cannot touch 'file': Read-only file system
Or Windows is more polite about it:
An error occurred mounting the distribution disk, it was mounted read-only as a fallback.
A wsl --shutdown sometimes clears it. A full Windows reboot often does. Neither is a permanent fix. The Linux ext4 filesystem inside ext4.vhdx detected errors — usually from an unclean shutdown — and remounted itself read-only to protect the data. You have to repair the filesystem.
Repair the VHDX properly
1. Shut everything down
wsl --shutdown
Also fully quit Docker Desktop if it is running. Anything that still has a handle on the VHDX will block the next steps.
2. Find your VHDX path
(Get-ChildItem -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss |
Where-Object { $_.GetValue("DistributionName") -eq 'Ubuntu' }).GetValue("BasePath") + "\ext4.vhdx"
Swap 'Ubuntu' for your distro name if it is something else.
3. Mount the VHDX bare
wsl --mount "C:\Users\YourUser\AppData\Local\wsl\{xxx-xxx}\ext4.vhdx" --vhd --bare
Use the path from step 2. --bare attaches the virtual disk without mounting a filesystem, which is what you want before running e2fsck.
4. Install a temporary recovery distro
You cannot run e2fsck against a disk that the same distro is sitting on. A second distro is required because of the sharing violation.
wsl --install -d Debian
Skip this if you already have another working distro.
5. Identify the correct disk
wsl -d Debian lsblk
Look for the large disk (often 1T) that has no mount point. That is the one you just attached. Commonly /dev/sdd.
6. Run the filesystem check and repair
wsl -d Debian -u root e2fsck -f -y /dev/sdd
Replace sdd with the device you identified. Back up the VHDX before this step if you have anything you cannot afford to lose.
7. Unmount and test
wsl --unmount
wsl -d Ubuntu
Verify it worked
Inside Ubuntu:
mount | grep ' / '
You should see rw instead of ro.
Afterwards
After a successful repair you can remove the temporary distro:
wsl --unregister DebianKeep a regular
wsl --exportbackup going forward.
This sequence permanently fixes the underlying corruption instead of just clearing the temporary read-only state.
— Mícheál.