Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSL2: Read-only file system error #6220

Closed
ind-igo opened this issue Nov 10, 2020 · 16 comments
Closed

WSL2: Read-only file system error #6220

ind-igo opened this issue Nov 10, 2020 · 16 comments

Comments

@ind-igo
Copy link

ind-igo commented Nov 10, 2020

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.

@therealkenc
Copy link
Collaborator

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.

@ind-igo
Copy link
Author

ind-igo commented Nov 11, 2020

@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!

@ind-igo ind-igo closed this as completed Nov 11, 2020
@cuongnguyengit
Copy link

cuongnguyengit commented Jan 21, 2021

@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.

@ind-igo
Copy link
Author

ind-igo commented Jan 22, 2021

@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!

@luisromeroaraya
Copy link

luisromeroaraya commented Jun 14, 2021

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

@toadslop
Copy link

toadslop commented Aug 1, 2021

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?

@Hadh
Copy link

Hadh commented Sep 14, 2021

@toadslop I have the same message as you, did you fix it?

@toadslop
Copy link

toadslop commented Sep 15, 2021 via email

@lowranceworks
Copy link

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

@jhoweaa jhoweaa mentioned this issue Nov 23, 2021
2 tasks
@codingmusician
Copy link

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.

@hamirmahal
Copy link

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.

@umangutkarsh
Copy link

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

Thanks a lot @luisromeroaraya . This worked for me.

@juni-vogt
Copy link

juni-vogt commented Apr 10, 2024

tune2fs didn't work for me -- I had to do sudo tune2fs -c 1 /dev/sdX and sudo reboot and restart ubuntu.
Where /dev/sdX is the one you get from mount | grep ext4

@brucejo75
Copy link

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!

@paradoxe-tech
Copy link

Hello, I'm facing the same problem as @brucejo75. With Ubuntu WSL, I can write files for a few minutes after startup and then Read-only file system errors start showing up. I've tried all the lines mentioned above, and labeled sucessfully ROOTFS the sdc part in /etc/fstab.

here is the output of $ sudo blkid -o list before the issue :

device                                          fs_type         label            mount point       
---------------------------------------------------------------------------------
/dev/sdb                                        swap                             [SWAP]               
/dev/sdc                                        ext4          ROOTFS        /
/dev/sda                                        ext4                               (in use)

I'm using WSL to download a specific conda package called Vina that cannot install properly on windows. Right after restarting WSL, I called these :

$ cd <adir>
$ conda install pytorch

Then, the installation started correctly until this error show up :

InvalidArchiveError("Error with archive /home/paradoxe/anaconda3/pkgs/mkl-2023.2.0-h84fe81f_50496.conda.  You probably need to delete and re-download or re-create this file.  Message was:\n\nfailed with error: [Errno 30] Read-only file system: '/home/paradoxe/anaconda3/pkgs/mkl-2023.2.0-h84fe81f_50496/lib/libmkl_gf_ilp64.so.2'")
InvalidArchiveError("Error with archive /home/paradoxe/anaconda3/pkgs/pytorch-2.3.0-cpu_py312h544eda6_0.conda.  You probably need to delete and re-download or re-create this file.  Message was:\n\nfailed with error: [Errno 30] Read-only file system: '/home/paradoxe/anaconda3/pkgs/pytorch-2.3.0-cpu_py312h544eda6_0/lib/python3.12/site-packages/torch/include/ATen/ops/digamma_compositeexplicitautogradnonfunctional_dispatch.h'")

Bus error

here is the output of $ sudo blkid -o list after the issue :

device                                          fs_type         label            mount point       
---------------------------------------------------------------------------------
/dev/sdb                                        swap                             [SWAP]               
/dev/sda                                        ext4                               (in use)

the $ mount | grep ext4 hasn't changed

/dev/sdc on / type ext4 (ro,relatime,discard,errors=remount-ro,data=ordered)
/dev/sdc on /mnt/wslg/distro type ext4 (ro,relatime,discard,errors=remount-ro,data=ordered)
/dev/sdc on /snap type ext4 (ro,relatime,discard,errors=remount-ro,data=ordered)

Additional information

When I tried chmod a+w /home/paradoxe/anaconda3/* I also got the Read-only file system
I don't think my disk is full, but I'm not sure about how to check it

I don't know what to do next, thanks in advance for the help 🤷

@brucejo75
Copy link

@paradoxe-tech, I would double check all the changes you made are consistent:

  • I do not see the UUIDs for your $ sudo blkid -o list output.
  • the output of mount says that /dev/sdc is ro not rw, before the trying to write is it rw?
  • what does fstab look like before and after the issue? It is possible something overwrites fstab.

Note: I am running with Ubuntu 20.04

Are you running WSL1 or WSL2? (WSL2 is recommended)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests