fix read only file system error on Ubuntu 1

How to Fix Read Only File System Error on Ubuntu

The “Read-only file system…” error is a file system-related error. This could happen in many circumstances for various causes. In this article, we will discuss how to fix read only file system error on Ubuntu.

A filesystem is a grouping of data (files and directories) kept on a storage device in Linux. The filesystem is used by your operating system to report the physical location and positioning of the files. The files would appear as invisible or random bits without the filesystem.

Each file system also has its own permissions, which control which users or groups can read and write files. The “Read-only file system” problem on Ubuntu will be fixed with this guide.

How to Fix Read Only File System Error on Ubuntu

read-only file system for Ubuntu

By default, Ubuntu has a read-only file system. It implies that the user cannot change or remove files from the system. It helps to safeguard system data and folders and stop unintentional removals. Linux distribution Ubuntu uses the read-only ShrinkFS file system.

This file system saves disk space. It can be used to keep executables, configuration files, and other information that shouldn’t be changed by the user. Linux distribution Ubuntu comes included with a read-only file system. The “Btrfs” file system aims to increase performance and dependability.

The read-only file system cannot be removed using rm.

An error warning will appear if you attempt to delete a read-only file system while the machine is running. It is thus because you cannot delete the file system, which is a component of the computer’s main operating system.

A read-only file system cannot be removed, and any attempts to rename or relocate it will fail with a read-only file system error message. It’s because the Rm command cannot alter a read-only file system’s permissions. Use the Remove-Item cmdlet to correctly remove a read-only file system.

Filesystem Access Rights

Linux is an OS that supports multiple users. Linux uses several security mechanisms to regulate which user has access to which area of the system. File permissions and ownership are one such functionality. It establishes the file’s owner and who has access to read, write, and execute the files.

Linux filesystems follow a similar principle. User permissions secure each filesystem by dictating who is permitted to carry out certain actions on the filesystem.

Because the target filesystem is a read-only filesystem, as the error says, it is rejecting write requests. If it’s intentional, you’ll need the system administrator’s written consent if you want to proceed. If that isn’t the case, then adhere to this advice.

Symptom

On a Linux system, the notification Read-only file system appears when you delete or change a file.

Potential Causes

These are some of the potential reasons:

  • After that, the file system enters read-only mode.
  • The mounted file system is read-only.
  • The hardware is broken, for instance, the disk has damaged sectors, or the RAID controller card is broken.

Precautions

  • Data loss could occur when file systems are repaired. Back up your files first.
  • Check for a hardware defect if your problem doesn’t fit into one of the following categories.

Solution

The filesystem’s permissions need to be fixed to resolve this problem. Several tools are available, depending on the type of filesystem.

These actions are usually best carried out from a live Ubuntu session. No other program will interfere with the process in this manner. As an alternative, you can start Ubuntu from a different installation. With that said, you may want to consider setting up Ubuntu on a USB drive.

Display Mounted File Systems

We shall first list the file systems that are already mounted. The mounted file systems can be listed using the mount command. Even though the output may be lengthy, only look for the lines about the root path and home path.

Syntax:

$ mount
This image shows the mount command on Ubuntu terminal.

The third line from the bottom is the line we are interested in when looking at this screenshot.

File System Remount to Fix Read Only Error on Ubuntu

Remounting the file system is the first thing to do when dealing with a read only file system error on Ubuntu. Because the file system might be mounted as read-only for various reasons that happen occasionally.

Remounting the file system will therefore make it mount normally. The following command can be used to remount specific file systems that are listed in the /etc/fstab configuration file. Naturally, root privileges are required for this action.

Syntax:

$ sudo mount -o remount /

Re-Mount Read-Write File System

By default, the file system is set up to be mounted as read-only. However, read-write mounts for these file systems are also an option. To mount, read and write, use the rw option.

Syntax:

$ sudo mount -oremount,rw /

Target Filesystem

Choose the filesystem you’ll be working with first. Use the following command to list all filesystems that are accessible:

Syntax:

$ sudo fdisk -l
fix read only file system error on Ubuntu

As an alternative, we can list every mounted filesystem using the findmnt tool:

Syntax:

$ findmnt
fix read only file system error on Ubuntu

Choose the target partition or device from the list. In this case, /dev/loop17 is my target device.

You can alternatively use the GNOME Disks tool if you want a graphical user interface:

fix read only file system error on Ubuntu

System Reboot to Fix Read Only Error on Ubutu

Rebooting the machine is another method to fix read only file system error on Ubuntu. A system reboot creates a new beginning where previous errors, which may be connected libraries, configuration, temporary changes, etc., are cleared.

Syntax:

$ sudo reboot
fix read only file system error on Ubuntu

Look For Errors In The File System on Ubuntu

Generally, when a computer reboots, the file system is checked for errors, and any found are corrected. However, this might not always be successful. Using the fsck command, mistakes can be specifically checked and automatically corrected.

Syntax:

$ sudo fsck.ext4 -f /dev/sda2

Remediating the File System on

The majority of Linux systems (including Ubuntu) provide fsck, a specific utility for repairing a Linux filesystem, after we’ve identified the filesystem and the appropriate time to repair it. Find out more about how to use fsck on Linux.

Run the following command to repair the filesystem:

Syntax:

$ sudo fsck -f /dev/loop17

If you’re using GNOME Disks, choose the filesystem, select “Repair Filesystem” from the drop-down menu, and then click the gear symbol.

Then restart the computer. Now, the filesystem ought to operate as anticipated.

Prevention of File System Error on Ubuntu

Every filesystem is susceptible to error and corruption. To promote general stability, we can cultivate the following habits:

  • Before turning off the machine, properly shut down your system. Data damage and numerous file system issues are frequently the results of improper shutdown.
  • Be sure to properly eject/unmount any portable storage from the system before removing it. If not, the filesystem might become corrupt (especially FAT-based file systems).
  • Keep an eye on the hard drive’s SMART information if you’re working with one. Before your hard disk dies, it may let you know whether the drive is on its last legs.
  • Keep a copy of your crucial files on a different drive so you won’t get locked out.

Final Remarks

In this tutorial, we show how to fix a filesystem that prevented write operations and turned Ubuntu into a “Read-only file system.” A few methods to lessen the possibility of filesystem corruption were also covered.

Some filesystems, like ZFS, are more resistant to corruption than others. It can handle large storage capacities and has built-in data integrity protection and data compression. Look into installing ZFS on Ubuntu.

If this guide helped you, please share it.

Leave a Reply
Related Posts