read-only file permissions on Ubuntu 18.04

Asked by Brian McMahon

I am trying to delete a folder contained on a mounted HDD.

When trying to put the folder into trash, I get the error "You do not have sufficient permissions to delete the folder [name] ... Error removing file [file]: Read-only file system".

When running `sudo rm -rf [folder]` in terminal, I get error "rm: cannot remove [file]: Read-only file system".

When I input `sudo mount -o remount,rw /dev/sdb1` the disk remounts, and then when again trying `sudo rm -rf [folder]` I get the error "rm: cannot remove [folder]: Directory not empty".

If I try to again put the folder directly into the trash, and empty the trash, it will empty. But then if I refresh the parent folder the deleted folder and all its contents remains!

I would also mention that my computer has two hard drives, a SSD and a mount-required HDD. When I reboot my computer, I have had to manually open the HDD to mount for a while (ie also in previous versions of Ubuntu). However, I have not, until now, had read-only access issues with the HDD.

Any guidance in resolving this matter would be immensely appreciated!

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Brian McMahon
Solved:
Last query:
Last reply:

This question was reopened

Revision history for this message
Manfred Hampl (m-hampl) said :
#1

I see different aspects to this question:

1. Why is the partition mounted read-only? Is this on purpose, or is something wrong that the system remounts the partition read-only (which is some kind of emergency feature)?
What is there in /etc/fstab for this partition?
What file system is the partition?

2. Is the directory really empty when you want to delete it?
What does the command "ls -la [folder]" show?
What happens if you try deleting the file in the directory first?

Eventually some of the files have extended attributes set (like immutable etc.)
Does the command
lsattr *
show something extraordinary?

Revision history for this message
Brian McMahon (cipher813) said :
#2

Manfred, thanks for your reply.

1. The partition is not mounted read-only, and I have tried to remount it using rw per the code above but this did not solve the problem. This system appears to remount the partition read-only.

/etc/fstab reads as follows:
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda6 during installation
UUID=812b5f4a-2dd0-475e-a0f9-887409b17b1d / ext4 errors=remount-ro 0 1
# /boot/efi was on /dev/sda1 during installation
UUID=2EA1-823F /boot/efi vfat umask=0077 0 1
# swap was on /dev/sda7 during installation
UUID=b0867e6a-05f0-4144-817f-0fc1ce33c2be none swap sw 0 0

The partition in question is /dev/sdb1, type fuseblk

2. The directory is not empty when I try to `rm -rf [folder]`, but with recursive deletion it shouldn't need to be empty correct?
printout of `ls -la [folder]` is as follows:

total 233
drwxrwxrwx 1 cipher000 cipher000 4096 Apr 7 17:05 .
drwxrwxrwx 1 cipher000 cipher000 8192 Apr 18 17:27 ..
drwxrwxrwx 1 cipher000 cipher000 4096 Apr 7 17:04 agents
drwxrwxrwx 1 cipher000 cipher000 0 Apr 7 14:59 archive
-rwxrwxrwx 1 cipher000 cipher000 24931 Apr 7 14:47 data.txt
drwxrwxrwx 1 cipher000 cipher000 4096 Apr 7 17:04 .git
-rwxrwxrwx 1 cipher000 cipher000 34 Apr 7 15:00 .gitignore
-rwxrwxrwx 1 cipher000 cipher000 6115 Apr 7 14:47 physics_sim.py
-rwxrwxrwx 1 cipher000 cipher000 151517 Apr 7 14:47 Quadcopter_Project-Copy1.ipynb
-rwxrwxrwx 1 cipher000 cipher000 17801 Apr 7 14:47 Quadcopter_Project.ipynb
-rwxrwxrwx 1 cipher000 cipher000 1188 Apr 7 14:47 README.md
-rwxrwxrwx 1 cipher000 cipher000 46 Apr 7 14:47 requirements.txt
drwxrwxrwx 1 cipher000 cipher000 0 Apr 7 17:05 supplemental
-rwxrwxrwx 1 cipher000 cipher000 1961 Apr 7 14:47 task.py

When I try to `rm -rf [subfolder]`, it says "rm: cannot remove [folder]: Directory not empty".
When I try to `rm -rf [file]`, there is no response. But then when I `ls` again, the file is still there.

I ran `lsattr *` and received the following response: "lsattr: Invalid argument While reading flags on [filepaths]"

Revision history for this message
Manfred Hampl (m-hampl) said :
#3

For diagnostic purposes, what is the output of the commands

uname -a
lsb_release -crid
mount | grep "^/dev"

Remarks: The file system of that partition seems to be NTFS, and that is always somewhat special. Is this a dual boot system with Windows, and can you try deleting the files/directories from within Windows?

Revision history for this message
Brian McMahon (cipher813) said :
#4

Requested information is as follows:

`uname -a`: Linux cipher813 4.15.0-15-generic #16-Ubuntu SMP Wed Apr 4 13:58:14 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

`lsb_release -crid`:
Distributor ID: Ubuntu
Description: Ubuntu Bionic Beaver (development branch)
Release: 18.04
Codename: bionic

`mount | grep "^/dev"`:
/dev/sda6 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
/dev/sda1 on /boot/efi type vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
/dev/sdb1 on /media/cipher000/DATA type fuseblk (ro,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096,uhelper=udisks2)

This is a dual boot system with Windows. I was able to boot Windows and delete the files with no issues. On Windows, the HDD auto-mounts without issue as well. When booting back into Ubuntu, the files deleted in Windows remain deleted.

Thanks!

Revision history for this message
Manfred Hampl (m-hampl) said :
#5

You have to be aware that NTFS is a proprietary file system developed by Microsoft, and Linux is doing its best to be able to read and write it, but prefers not to modify it if possible(hence mounting read-only by default).

If you are satisfied with the current situation and do not need further answers, you could mark this question as "solved".

Revision history for this message
Brian McMahon (cipher813) said :
#6

The problem is I can't seem to remount the drive as rw, as when I attempt to do so per the process above it remains read only. I am not clear on the underlying error that has been caused and how to resolve within Ubuntu. Your guidance is sincerely appreciated.

Revision history for this message
Brian McMahon (cipher813) said :
#7

The problem now appears to be solved - perhaps a patch to 18.04 was applied? I now appear to have rw access to the drive. Many thanks!

Revision history for this message
Brian McMahon (cipher813) said :
#8

For the record, I am still having this problem. I cannot determine what resolved the problem previously, but soon after I had posted this as solved the problem returned. I have redone the commands that were suggested above, yet the HDD remains read only. I cannot create new folders on the drive.

Is there a permanent fix that you could suggest?

Many thanks.

Revision history for this message
Manfred Hampl (m-hampl) said :
#9

Maybe you should try using the ntfs-3g driver instead of fuseblk.

As already written:
You have to be aware that NTFS is a proprietary file system developed by Microsoft, and Linux is doing its best to be able to read and write it, but prefers not to modify it if possible (hence mounting read-only by default).

Revision history for this message
Brian McMahon (cipher813) said :
#10

Manfred, well understood your disclaimer on NTFS. However, I have only recently started having this issue, and can't seem to figure out what caused it in the first place.

I have been doing research on your statement above and am unclear how to install the ntfs-3g driver over fuseblk. Can you please provide additional information about how I would go about removing the fuseblk driver? Many thanks!

Revision history for this message
Brian McMahon (cipher813) said :
#11

So I think I figured it out. I use a dual boot system with Windows 10 and upon applying a windows upgrade it appears that the fast boot option was reenabled. This seems to tie up NTFS system resources so that Ubuntu cannot access. I booted Windows and turned off fast boot from power options per explanation at https://www.windowscentral.com/how-disable-windows-10-fast-startup. This appears to have solved the problem.

Revision history for this message
kinghat (kinghat) said :
#12

>So I think I figured it out. I use a dual boot system with Windows 10 and upon applying a windows upgrade it appears that the fast boot option was reenabled. This seems to tie up NTFS system resources so that Ubuntu cannot access. I booted Windows and turned off fast boot from power options per explanation at https://www.windowscentral.com/how-disable-windows-10-fast-startup. This appears to have solved the problem.

this happened out of the blue for me as well. finding that fast boot was on and turning it off worked for me.

Revision history for this message
Mehmet (eniyisiyim) said :
#13

Same problem after Windows 10 updates, and same solution worked for me too. Thanks Brian.