Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

How to Fix "Read-only file system" error when I run something as sudo and try to make a folder/file?

Writer Andrew Mclaughlin

When I try to save something or rename a file/folder it say this error " Read-only file system" or run something as root in the terminal it say this error

sudo: unable to open /var/lib/sudo/"My User Name"/0: Read-only file system
W: Not using locking for read only lock file /var/lib/dpkg/lock
E: Unable to write to /var/cache/apt/
E: The package lists or status file could not be parsed or opened.

When I make a Folder the error dialog in the details with Nautilus is this:

Error creating directory: Read-only file system

I would show you I picture of it but it isn't even letting my save onto my flash drive. Please help me.

1

6 Answers

This worked for me:

First, run this command with sudo permission:

sudo fsck -n -f

Then reboot the machine

8

When the system enters a read-only state, it does so to prevent damage to the system. Make sure your HDD is working properly and/or backup your data before doing anything.

I suggest to boot a live USB/DVD, open GParted, and use the check/repair feature.

This is the command to enable writing:

sudo mount -o rw,remount /
9

If you are dual booting Windows with Ubuntu and you do not have any error in dmesg, then the problem could very well be caused by Windows.

In Windows go to Control Panel → Power Options and disable Fast Startup. Now boot into Ubuntu.

7

When accessing an HDD from different OS (Windows & Linux) the disk could contain an unclean file system. So the metadata cached in the OS, deny mounting the disk

To try to correct the mistakes, identify the path of your partition disk in the Disk app (i.e: /dev/sdb1) and use ntfsfix.

sudo ntfsfix /dev/sdb1

If the disk is not mounted automatically, so:

$ sudo mkdir /media/[mount point]
$ sudo mount -o rw /dev/sdb1 /media/[mount point]

If you get the error Read-only file system then you should delete the following directories from Windows:

  • .Tash-1000
  • $

In Git Bash as Admin:

Identify your disk. In my case is /f

$ cd /f
$ rm -R \$ && rm -R .Tash-1000

GL

In my case, I have a common drive between Windows and Ubuntu.

On Ubuntu, I had installed trash-cli and had trashed some files.
When I booted in Windows, I did some defragmentation on that drive.
But when I went back to Ubuntu, then it started giving me Read-only file system error on any write operation.

After reading @Braian Coronel's answer, I went back to Windows and permanently deleted .Trash-1000 folder which solved my issue.

If someone using dual OS(Ubuntu, Windows) like me, NTFS filesystem is the main reason of this problem. Inspect the path of disk like "/dev/sda3", unmount the disk and run:

sudo ntfsfix /dev/sda3