WSL: WSL2: Read-only file system error
Environment
Windows build number: Microsoft Windows NT 10.0.19041.0
Your Distribution version: Debian 10
Whether the issue is on WSL 2 and/or WSL 1: WSL2
Steps to reproduce
Doing anything to write to disk is coming up as an error. Command ‘touch test’ results in
touch: cannot touch 'test': Read-only file system
I suspect WSL2 thinks disk space is gone, but my C drive (which houses WSL2) still has 700 gigabytes left. Doing a sudo dmesg -w results in:
[ 692.744590] EXT4-fs warning (device sdd): ext4_dirent_csum_verify:368: inode #47595: comm node: No space for directory leaf checksum. Please run e2fsck -D.
[ 692.744591] EXT4-fs error (device sdd): ext4_find_entry:1466: inode #47595: comm node: checksumming directory block 0
[ 733.895260] WSL2: Performing memory compaction.
When I run bash e2fsck -D I just get the help menu for e2fsck.
Some extra info:
When running df, this is my result (C drive is 1 tb ssd and D drive is 1 tb hdd):
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sdd 263174212 10611100 239124956 5% /
tmpfs 3043512 257168 2786344 9% /mnt/wsl
/dev/sdc 263174212 752864 248983192 1% /mnt/wsl/docker-desktop-data/isocache
none 3043512 12 3043500 1% /mnt/wsl/docker-desktop/shared-sockets/host-services
/dev/sdb 263174212 121136 249614920 1% /mnt/wsl/docker-desktop/docker-desktop-proxy
/dev/loop0 377078 377078 0 100% /mnt/wsl/docker-desktop/cli-tools
tools 976185600 224656324 751529276 24% /init
none 3041104 0 3041104 0% /dev
none 3043512 4 3043508 1% /run
none 3043512 0 3043512 0% /run/lock
none 3043512 0 3043512 0% /run/shm
none 3043512 0 3043512 0% /run/user
tmpfs 3043512 0 3043512 0% /sys/fs/cgroup
C:\ 976185600 224656324 751529276 24% /mnt/c
D:\ 964249596 949545532 14704064 99% /mnt/d
Expected behavior
I was able to use WSL perfectly fine until yesterday. Now anything writing to disk results in this error.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 2
- Comments: 16
I was able to resolve this issue by taking the following steps:
open PowerShell and run:
wsl --shutdownopen WSL, repeat if steps 1,2 if the issue persists
Spiritually same #4833. From inside WSL, try:
…For the device, use the root ext4 filesystem (
/) returned bymount | grep ext4. It looks like/dev/sddfor you but it might vary.Thanks a lot! This worked for me:
@therealkenc I think that fixed it! Just for future reference for anyone else, the
-poption didn’t work, and it told me to do it manually, so I instead passed a-yand e2fsck was able to fix my drive corruption. I had read that issue you linked and tried it, but was trying to do it on my /dev/sdb drive. Oops. I really appreciate your help!I know this is old, but I ran into the same error message and it turned out my disk was full.
I used this article to move my Ubuntu installation to a different drive.
Hey guys, I’m having the same error message, but when I run the
sudo e2fsck /dev/sdd -yas suggested I just get the following message:Any idea what I should try next?
Inconsistent mount &
/etc/fstabI started seeing the
Read-only file systemerror messages and discovered that my mounted root drive device did not match the one specified in/etc/fstab.What was interesting was that I could write for a minute or 2 but over time it would start throwing the errors.
Earlier mistake
A couple of months ago I had modified my
/etc/fstabby hand it was originally:I had modified it to directly refer to
/dev/sdabecause there was no labeled device in my system. I do not know where the labelcloudimg-rootfscame from. My WSL2 disk was originally created with WSL1, maybe they labeled the disk that way? Then WSL2 took it away?This worked fine for a while, but then I recently started getting the
Read-only file systemerror messages.At this point I noticed that my root drive had changed to
/dev/sdc& I still referred to/dev/sdain/etc/fstab.Fix
I remembered my modification of
/etc/fstab& I remembered that it referred to aLABEL, not the drive./etc/fstabto refer to the new root fs drive:/dev/sdc / ext4 defaults 0 0mount&/etc/fstabare consistent after reboot. At this point I was able to write to the filesystem without any errors./dev/sdc):sudo e2label /dev/sdc "ROOTFS"/etc/fstabto refer to my new label:LABEL=ROOTFS / ext4 defaults 0 0Now because the label stays the same between reboots,
fstabshould have no trouble. All Good!I just ran into this today, and
followed by
wsl --shutdowndidn’t resolve the issue.Another command I tried that didn’t work was
sudo fsck -fy /dev/sdc, andsudo badblocks -v /dev/sdcsaid that there were 0 issues.I needed to restart my Windows 10 PC to install updates, and doing that worked!
I don’t know if just a regular restart, without installing updates, would have solved the problem.
$ sudo e2fsck /dev/sdd -yis what worked for me. Remember to make sure to find which drive you need to do it on (was sdd for me). I later found out the problem was due to the VSCode Live Share extension, so removing that and performing the above command may fix your issue. Good luck!Hi Hadhemi,
I did manage to solve the problem, but interestingly it turned out the issue was with my docker compose file, not with WSL. The issue was that I had set a volume of the file to read only on a different pc, after I had already built the image and all writing was finished. Then I tried to rebuild on a different computer so the write steps weren’t done, but the read-only flag was still there. That was actually what caused my problem. If your problem is the same as mine, then check your docker compose for read only flags and try removing them. Hope that helps!
Best, Brian