Are you have troubles solving 'rm cannot remove read-only file system'?
This article is for you.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to fix Linux system related issues.
In this context, you shall learn how to fix remove a file in Linux.
When this error occurs, you will see an error message such as this;
rm: cannot remove 'A': Read-only file system
You will easily notice this error when you run mount like as seen below;
/dev/sdb1 on /media/usbdisk type ext3 (rw)
Additionally, we discovered that ls -la /media/usbdisk gives the following report;
ls -la /media/usbdisk
total 36
drwxr-xr-x 5 root root 4096 April 31 2013 .
drwxrwxrwx 9 root root 4096 Dec 15 2012 ..
drwxrwxrwx 39 501 501 4096 Sept 20 09:04 development-backup
drwx—— 2 root root 16384 Mar 30 2011 lost+found
drwxr-xr-x 8 root 501 4096 Aug 19 00:00 officeshare-backup
Here the error message clearly says that the filesystem on which omitted is located is read-only. We cannot do anything to modify that filesystem, including removing files.
Let's see what our Support Experts suggest to resolve this problem.
Begin by checking the mount point of the filesystem by running df X. It would be probably /media/usbdisk.
Then we run the following command to remount the filesystem as read-write;
mount -o remount,rw /mount/point
This solved the problem.
However, if you receive any error for the above command then your filesystem is hosed in some way. You have to umount that partition and perform fsck for that partition;
umount /media/usbdisk
fsck /dev/sdb1
However, we suggest to find out why those files were set to read-only. This might indicate that you shouldn’t delete them.
Run the following command to see what options were specified when mounting that filesystem;
mount | grep /media/usbdisk
For an ext2/ext3/ext4 filesystem, if the options did not include ro (read-only) but include errors=remount-ro, then it means the filesystem was damaged and was automatically remounted as read-only to limit the damage. You will find more information in the kernel logs.
Check /var/log/messages and /var/log/syslog for mount events or possible filesystem corruption.
This article will guide you on how to fix 'rm cannot remove the read-only file system' error by simply removing files from the read-only file system.