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?

    Can you share output of `mount` ?

  • 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.

License under CC-BY-SA with attribution

Content dated before 6/26/2020 9:53 AM