26

I am trying to remove an rdiff backup folder as some problems occured during the backup and need to remove it's history and try again. However, when I run:

rm -r -f rdiff-backup-data 

I get the following on some of the files:

rm: cannot remove `X': Read-only file system

Here is what I get when I run mount:

/dev/sdb1 on /media/usbdisk type ext3 (rw)

So that shows the drive is rw?

ls -la /media/usbdisk gives the following:

[root@localhost v5]# ls -la /media/usbdisk
total 36
drwxr-xr-x  5 root root  4096 Mar 31  2010 .
drwxrwxrwx  9 root root  4096 Dec 15  2009 ..
drwxrwxrwx 39  501  501  4096 Aug 19 09:04 development-backup
drwx------  2 root root 16384 Mar 30  2010 lost+found
drwxr-xr-x  8 root  501  4096 Aug 19 00:00 officeshare-backup

Anyone know what is going on and how to fix it?

UPDATE

found out the drive was ro in /proc/mounts so ran the remount command mentioned below and got the following:

ext3_abort called.
EXT3-fs error (device sda1): ext3_remount: Abort forced by user
mount: block device LABEL=USBDISK1 is write-protected, mounting read-only
ext3_abort called.
EXT3-fs error (device sda1): ext3_remount: Abort forced by user
David
  • 829
  • 3
  • 13
  • 30

5 Answers5

15

You could try remounting the device and seeing where that leads

mount -o remount,rw /media/usbdisk

If that doesn't work then you'll probably need to fsck the device

umount /dev//media/usbdisk
fsck /dev/sdb1

You may need to use the -f option to umount for force it to be unmounted though.

user9517
  • 114,104
  • 20
  • 206
  • 289
  • Can you run fsck on a partition if other partitions are mounted and running? That won't cause any problems? I have read that its best to go into single-user mode and don't allow any changes. – David Aug 24 '11 at 09:10
  • You are safe to run fsck on unmounted devices. If it really bothers you though, as this is a USB device, you can always unplug it and use a different system to fsck it. – user9517 Aug 24 '11 at 09:19
14

Depending on the state of things, the output of mount may not reflect reality. You're far better of with cat /proc/mounts, which is guaranteed to show you the actual mount table, wherein you'll probably find that it's actually mounted read-only. You can fix this with mount -o remount,rw /mount/point. If that command errors out, then your filesystem is hosed in some way; a fsck (at the very least) is in order. You don't need to stop the entire system to fsck a partition, just that partition needs to be unmounted.

womble
  • 95,029
  • 29
  • 173
  • 228
  • cheers, now i just need to know http://serverfault.com/questions/304422/can-i-run-fsck-on-a-partition-which-is-unmounted-but-on-a-live-machine (can i run fsck, if unmounted but users might still try to access using its mount location) – David Aug 24 '11 at 09:16
0

Actually there is an another workaround to it,

Reboot your linux into recovery mode and you will get an option for clean boot which actually serves the purpose of freeing some space, incase the disk is full. This will unmount and remount in read-write state.

Then you can use the terminal root option to use the terminal and delete the required files without actually booting.

Ubuntu 18.04

0

Your update included this line of output:

mount: block device LABEL=USBDISK1 is write-protected, mounting read-only

This error should be pretty self-explanatory. The physical device is read-only, so a filesystem on it cannot be mounted as writeable.

If the device is a flash drive, this may mean that it has reached its end of life and needs to be replaced.

0

rm: cannot remove `.s.PGSQL.5438.lock': Read-only file system

for this error message during startup the DB/instances

Work around is to reboot the host/server