Rm can’t delete file

chmod 777  -R  /mnt  
rm -rf /mnt/*  

rm: cannot remove 'omitted': Read-only file system  
rm: cannot remove 'omitted': Read-only file system

Please show me how I can do this?


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

As the error message says: the filesystem on which omitted is located is read-only. You can’t do anything to modify that filesystem, including removing files.

You can check the mount point of the filesystem by running df omitted. It is probably /mnt given the command you’re running.

You can remount the filesystem as read-write by running

mount -o remount,rw /mnt

However it would be a good idea to find out why the filesystem was mounted as read-only in the first place. This may be an indication that you should not be deleting those files.

Run mount | grep /mnt to see what options were specified when mounting that filesystem. For an ext2/ext3/ext4 filesystem, if the options did not include ro (read-only) but included errors=remount-ro, it looks like the filesystem was damaged and was automatically remounted as read-only to limit the damage; you will find more information in the kernel logs.

Note that your command attempts to remove the mount point itself, but this is harmless you won’t have permission to do it anyway.

By the way, I strongly urge you not to use chmod 777. It is extremely rare to actually need these permissions, and they can cause a lot of harm (especially when you typo the argument, but even when not). If you try to remove a file and get a “permission denied” error, all you need to do is give yourself permission to write to the containing directory: generally, that’s chmod -R u+w /path/to/toplevel/directory.

Method 2

You have a device mounted in /mnt/… that is read only

try to umount every folder in /mnt and then try again.

a CD mounted here would cause this problem but are you root?

Method 3

Re-mount did not work for me–but directly unmounting the fifesystem did get rid of it. I was trying to get rid of a directory tree called /Volumes/InstallMe/ on a mac.

/Volumes$ ls -l
total 8
<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a3c7d1d4dbd18edbd18edbe3">[email protected]</a> 4   204  6 Apr 07:43 InstallMe
lrwxr-xr-x  1   1  1 Feb 21:12 Macintosh HD -> /

/Volumes$ mount -o remount,rw InstallMe/
mount: InstallMe/: unknown special file or file system.

/Volumes$ sudo diskutil unmount InstallMe/
Unmount successful for InstallMe/

/Volumes$ ls
Macintosh HD

Method 4

I solve that issue going to ‘Disks’ and repairing the filesystemRm can't delete file

Click on ‘Additional partition option’

Then click on ‘repair filesystem’ and OK.

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments