Home Ubuntu How to fix the “Read-Only File System” error on Ubuntu

How to fix the “Read-Only File System” error on Ubuntu

One of the most common errors that Ubuntu users encounter is the "Read-Only File System" error. This error can occur for various reasons, such as file system corruption, hardware failure, or software bugs.

by Arun Kumar
fix ubuntu read only file system error

I‘ve encountered the dreaded “Read-Only File System” error on more than one occasion. It can be quite frustrating, especially when you are in the middle of an important task. Luckily, I’ve developed some tried and tested strategies to fix this error, which I’m excited to share with you today. In this article, we will delve into the causes of the error, troubleshooting tips, and ways to prevent it from happening again. So, let’s get started!

Understanding the “Read-Only File System” error

The “Read-Only File System” error occurs when the Linux kernel, in our case Ubuntu, mounts the file system in read-only mode.

fosslinux@test:~$ sudo service apache2 start
[sudo] password for username:
sudo: unable to open /var/lib/sudo/username/1: Read-only file system
* Starting web server apache2 (30)Read-only file system: apache2: could not open error log file /var/log/apache2/error.log.
Unable to open logs
Action 'start' failed.
The Apache error log may have more information.

This mode prevents users from making any modifications to the file system, including adding, deleting, or modifying files. While this can be a useful feature for protecting sensitive data, it becomes problematic when you need to make changes and are unable to do so.

Causes of the error

The error can be triggered by various factors, such as:

  • File System Corruption: When the file system is corrupted, Ubuntu might choose to mount it as read-only to prevent further damage.
  • Improper System Shutdown: Abrupt power loss or an unclean system shutdown can lead to a read-only file system.
  • Hardware Issues: Faulty hard drives or damaged sectors can cause the file system to switch to read-only mode.
  • Incorrect File System Configuration: Mistakes in the /etc/fstab file or other configuration files can result in a read-only file system.

Troubleshooting tips and tricks

To address the “Read-Only File System” error on Ubuntu, follow these steps:

1) Restart your system!

Sometimes, a simple restart can fix the issue. However, don’t rely on this as a permanent solution.

2) Check for file system errors

Use the ‘fsck’ command to check for and fix any file system errors. Before running ‘fsck’, ensure that the affected partition is not mounted. Open a terminal and run the following command:

sudo fsck -Af

This will check the file system for errors and attempt to repair them if possible.

3) Remount the file system with read-write permissions

You can try remounting the file system with read-write permissions using the ‘mount’ command:

sudo mount -o remount,rw /dev/sdXY /mount_point

Replace ‘sdXY’ with your partition identifier and ‘/mount_point’ with the appropriate mount point.

4) Examine the /etc/fstab file

The /etc/fstab file is a configuration file in Linux systems, including Ubuntu, that contains information about filesystems and how they should be mounted during the boot process. It stands for “file system table.” Each line in the /etc/fstab file represents a filesystem, including its mount point, filesystem type, mount options, and other parameters.

To examine the /etc/fstab file and check for any misconfigurations or incorrect entries, follow these steps:

Open a terminal window.

To view the contents of the /etc/fstab file, use the cat command:

cat /etc/fstab

Carefully examine each line in the /etc/fstab file. Each line has six fields, separated by spaces or tabs:

  • Field 1: The device or filesystem UUID (Universally Unique Identifier). This can be a device file like /dev/sda1 or a UUID like UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
  • Field 2: The mount point, which is the directory where the filesystem will be mounted, such as /, /home, or /var.
  • Field 3: The filesystem type, like ext4, btrfs, xfs, or swap.
  • Field 4: Mount options, which are comma-separated values that determine how the filesystem should be mounted. Examples include defaults, noatime, and errors=remount-ro.
  • Field 5: A value used by the dump utility to determine if the filesystem should be backed up. This is usually set to 0 (disabled) or 1 (enabled).
  • Field 6: A value used by the fsck utility to determine the order in which filesystems should be checked. The root filesystem / should have a value of 1, while other filesystems should have a value of 2 or higher.

Here’s an example of a typical /etc/fstab entry:

UUID=12345678-1234-1234-1234-123456789abc / ext4 errors=remount-ro 0 1

If you find any incorrect entries or misconfigurations, open the /etc/fstab file in a text editor with root privileges. You can use the nano text editor in the terminal:

sudo nano /etc/fstab

Make the necessary changes, and then save the file by pressing Ctrl + X, followed by Y, and then Enter.

Once you have made changes to the /etc/fstab file, reboot your system to ensure that the new configuration is applied:

sudo reboot

Remember to be cautious while editing the /etc/fstab file, as incorrect configurations can lead to an unbootable system. Always make a backup of the original file before making any changes.

5) Check disk space

If the file system is full, it may become read-only. Open a terminal and run the following command:

df -h

This will display the disk usage for all mounted file systems. Check if any file system is full and try freeing up some space by deleting unnecessary files.

6) Check the file system type

If the file system is not supported in read-write mode, it may become read-only. Open a terminal and run the following command:

mount | grep "^/dev"

This will display the file systems currently mounted. Check the file system type and ensure it supports read-write mode.

7) Check hardware health

If none of the above steps work, the issue may be due to hardware issues such as a failing hard drive or a damaged file system. You can try running a hardware diagnostic tool or seek the help of a professional.

Use ‘smartmontools’ to check the health of your hard drive. If there are any hardware issues, you might need to replace the drive. Refer to our comprehensive guide: Using Smartmontools in Linux to check the health of your HDDs or SSDs

Preventing the error from occurring again

To minimize the chances of encountering the “Read-Only File System” error, follow these best practices:

a. Regularly update your system: Keep your Ubuntu system up-to-date to avoid potential bugs and issues.

b. Backup your data: Always keep a backup of your important data to avoid data loss in case of file system corruption.

c. Use a UPS: A UPS (Uninterruptible Power Supply) can help prevent abrupt power loss and system shutdowns, reducing the risk of file system corruption.

d. Perform regular system checks: Regularly run ‘fsck’ and ‘smartmontools’ to monitor the health of your file system and hardware. Address any issues as soon as they are detected.

e. Properly shut down your system: Always follow the proper shutdown procedure for your Ubuntu system to avoid potential file system issues.


The “Read-Only File System” error on Ubuntu can be a frustrating experience, but with the right troubleshooting techniques, it can be resolved. Understanding the root causes and applying the tips and tricks mentioned in this article will help you fix the error and prevent it from happening again. As a seasoned Ubuntu user, I can assure you that these steps have worked for me countless times, and I hope they work for you as well. Remember, the key to maintaining a healthy system is regular updates, backups, and system checks. Happy troubleshooting!

You may also like

Leave a Comment



FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

Follow Us


©2016-2023 FOSS LINUX



“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.