Home » Fixes » rm: cannot remove ‘file.txt’: Read-only file system on BTRFS

rm: cannot remove ‘file.txt’: Read-only file system on BTRFS

Basic Information

Recently we were experiencing an error on an OpenSuse Linux and BTRFS.

OpenSuse is a popular Linux and comes by default with the BTRFS (B-tree FS) file system. The BTRFS file system is a modern file system with many advantages compared to the old EXT4.

For clarification: A file system basically manages the way how your data is stored on a hard disk drive. A hard disk drive can be spitted into partitions and every partition gets its own file system. As I wrote in our case it is BTRFS.

The basic management like setting permissions and ownership of files and directories is similar on all the Linux file systems – also on BTRFS. Normally a user doesn’t have to care much about the file system type.

Our problem with BTRFS showed up as follows:


The Problem

Recently we started up an OpenSuse PC with a BTRFS file system and we wanted to erase the file “file.txt” with the “rm” command as you can see here:

rm file.txt
rm: cannot remove 'file.txt': Read-only file system

You are seeing in the second line the error message we got.

A further analysis showed up that the device /dev/sde1 was keeping the file which we wanted to erase.
As a symptom of the problem we were identifying that /dev/sde1 was mounted as “read-only” volume.

Because the partition is mounted as “read-only” we cannot erase, create or modify any file on /dev/sde1 – also not our “file.txt” !


The Fix

1. Boot a Linux Live System

Since the device /dev/sde1 was occupied by the installed OpenSuse Linux and could not be unmounted I decide to boot my PC with a Ubuntu Live System. I choose “Try Ubuntu” and I got a fully working system with graphical user interface.

2. Open a Terminal and Check BTRFS

We assume that the file system is mounted “read-only” because of a file system defect. We have to execute the following command:

sudo btrfs check /dev/sde1

3. Reboot

Although now error was recognized by the check we rebooted the system. And: The device /dev/sde1 wan now mounted as rw (read write). We could successfully erase, create and modify all the files on our BTRFS partition again.


Conclusion

The task was successfully closed. Keep in mind that there could be a serious hardware issue with the hard disk drive. It could be the case that the problem appears again. There are other Linux tools to check the integrity of the hard disk drive and maybe the very last solution for the problem could be a hard disk drive replacement.


Leave a comment

Your email address will not be published. Required fields are marked *

consulting picture

WordPress Cookie Notice by Real Cookie Banner