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

Most upvoted comments

I was able to resolve this issue by taking the following steps:

  1. open WSL and run:
sudo e2fsck /dev/sdb -y
sudo e2fsck /dev/sdb -p
  1. open PowerShell and run: wsl --shutdown

  2. open WSL, repeat if steps 1,2 if the issue persists

Spiritually same #4833. From inside WSL, try:

$ sudo e2fsck /dev/sdd -p

…For the device, use the root ext4 filesystem (/) returned by mount | grep ext4. It looks like /dev/sdd for you but it might vary.

Thanks a lot! This worked for me:

  1. I got the drive name with: $ mount | grep ext4
  2. My drive’s name was “/dev/sdb” so I then ran: $ sudo e2fsck /dev/sdb -y

@therealkenc I think that fixed it! Just for future reference for anyone else, the -p option didn’t work, and it told me to do it manually, so I instead passed a -y and 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 -y as suggested I just get the following message:

e2fsck 1.45.5 (07-Jan-2020)
/dev/sdd is mounted.
e2fsck: Cannot continue, aborting.

Any idea what I should try next?

Inconsistent mount & /etc/fstab

I started seeing the Read-only file system error messages and discovered that my mounted root drive device did not match the one specified in /etc/fstab.

$ mount | grep ext4
/dev/sdc on / type ext4 (rw,relatime,discard,errors=remount-ro,data=ordered)
$ cat /etc/fstab
/dev/sda    /        ext4   defaults        0 0

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/fstab by hand it was originally:

$ cat /etc/fstab
LABEL=cloudimg-rootfs    /        ext4   defaults        0 0

I had modified it to directly refer to /dev/sda because there was no labeled device in my system. I do not know where the label cloudimg-rootfs came 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 system error messages.

At this point I noticed that my root drive had changed to /dev/sdc & I still referred to /dev/sda in /etc/fstab.

Fix

I remembered my modification of /etc/fstab & I remembered that it referred to a LABEL, not the drive.

  1. In the 2 minute window, I changed /etc/fstab to refer to the new root fs drive: /dev/sdc / ext4 defaults 0 0
  2. Restart wsl
  3. verify the drive letters between mount & /etc/fstab are consistent after reboot. At this point I was able to write to the filesystem without any errors.
  4. add label to my root fs drive (in my case /dev/sdc): sudo e2label /dev/sdc "ROOTFS"
  5. Verify label was changed
$ sudo blkid -o list
device                     fs_type     label        mount point                    UUID
-----------------------------------------------------------------------------------------------------------------------
/dev/sda                   ext4                     (in use)
/dev/sdb                   swap                     [SWAP]                         4906c2f2-XXX-YYY-ZZZ-aa65bf88a5c3
/dev/sdc                   ext4        ROOTFS       /                              3255683f-XXX-YYY-ZZZ-b4c1041e2a62
  1. change /etc/fstab to refer to my new label: LABEL=ROOTFS / ext4 defaults 0 0
  2. restart wsl
  3. verify that I can now write to the root file system.

Now because the label stays the same between reboots, fstab should have no trouble. All Good!

I just ran into this today, and

sudo e2fsck /dev/sdb -y
sudo e2fsck /dev/sdb -p

followed by wsl --shutdown didn’t resolve the issue.

Another command I tried that didn’t work was sudo fsck -fy /dev/sdc, and sudo badblocks -v /dev/sdc said 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.

@sali0 can you show me full commands to fix the error? I also have same problem when i build a image from a dockerfile in wsl2.

$ sudo e2fsck /dev/sdd -y is 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