Each file system also has its own set of permissions that manage which users/groups can perform read/write operations. This guide shows how to fix the read-only file system error on Ubuntu.”
File System Permissions
Linux is a multi-user operating system. To manage which user can access which part of the system, Linux implements various security features. One such feature is file permissions and ownership. It determines the owner of the file and who can read/write/execute it.
A similar concept applies to Linux file systems. Each file system is protected by user permissions that control who can perform what actions on the file system.
As the error suggests, the target file system is revoking write requests since it is a read-only file system. If it is intentional, you must ask the system administrator for written permission. If not, follow this guide.
The solution to this problem is to fix the file system permissions. Depending on the file system type, some tools are available.
In most situations, these procedures are better performed from a live Ubuntu session. That way, no other program will interfere with the process. Alternatively, you can boot from another Ubuntu installation. Check out how to install Ubuntu on a USB stick.
Determination of the target file system
First, determine the file system we will be working with. List all available file systems with the following command:
Alternatively, we can also use the findmnt tool to list all mounted file systems:
From the list, determine the target device/partition. In this example my target device is /dev/loop17.
If you prefer the GUI, you can also use the GNOME Disks utility:
Repairing the file system
After we determine the file system and time to repair, most Linux systems (including Ubuntu) come with it fsck, a dedicated tool for repairing a Linux file system. Learn more about usage fsck on Linux.
Run the following command to repair the file system:
If you are using GNOME hard drives, select the file system, click the gear icon and choose Repair File System.
Then restart the machine. The file system should now behave as expected.
Steps to avoid file system errors
No file system is immune to corruption and errors. However, we can develop certain habits to increase overall stability:
- Shut down your system properly before turning off the machine. Often, improper shutdown causes data corruption and leads to various file system errors.
- Before removing any portable storage, properly eject/unmount it from the system. Otherwise, it may corrupt the file system (especially FAT-based file systems).
- If you’re working with a hard drive, keep an eye on the drive’s SMART info. It can indicate if the drive is dying before you end up with a dead disk.
- Back up your important data to separate storage so you don’t get locked out.
In this guide, we have demonstrated that a file system is write-resistant, resulting in a “read-only file system” in Ubuntu. We also discussed some techniques to reduce the chances of file system corruption.
Certain file systems are more resistant to corruption than others, e.g example, ZFS. It comes with built-in data integrity protection and data compression and can handle large storage capacity. Check out how to set up ZFS on Ubuntu.
Have fun calculating!