Cloud1
Posts: 44
Joined: Sat Jun 05, 2021 3:46 pm

Can't delete files on an external USB HDD

Tue Jun 15, 2021 8:24 pm

I did a backup via rsync to my Pi, the files synched to the drive with no issues.
$ rsync -rvP /source-folder/ pi@192.168.12.123:/media/HDDL2/BLu-1/TARGET/

I went to delete some of them manually via the gui, and no delete, ceated a few
folders via the gui and can't delete them either, I can delete them via terminal
with this rm -rf * when in the folder where I want to delete the files, and rm -R filename
for folders.

I got some errors via my gui attempts at deletion, something like completed but
with errors, but no files or folders ever got deleted via the gui,
I also got error stating
"Unable to find or create trash directory for /media/HDDL2/BLu-1/TARGET/New"
that is in refference to trying to delete a file called New in the folder TARGET


For some reason the plugged in USB drive is root:root , would this have anything to do with it?
$ stat -c "%U:%G" /media/HDDL2/BLu-1/
root:root
So I tried to change the drive / folder owner and group,
$ sudo chown pi:pi /media/HDDL2/BLu-1/* and $ sudo chown pi:pi /media/HDDL2/BLu-1/
$ stat -c "%U:%G" /media/HDDL2/BLu-1/
root:root

Am I right in thinking the user pi is the root user, and this is why nothing changes when I change
the ownership to this user and group.

Either way, does anyone know how I can get the connected drive which is mounted on /media/HDDL2
or the folders within to work so I can delete files and folders such as the one at media/HDDL2/BLu-1/

The below command shows some permissions , not sure what they pertain to, the end folder or the drive and all the folders
$ ls -l /media/HDDL2/BLu-1/
total 4
drwxrwxrwx 1 root root 4096 Jun 15 20:02 TARGET

The below command shows , a folder, a file and another folder with their permissions.
$ ls -l /media/HDDL2/
total 4
drwxrwxrwx 1 root root 0 Jun 15 19:53 BLu-1
drwxrwxrwx 1 root root 0 Jun 15 20:03 New
drwxrwxrwx 1 root root 4096 Jun 6 20:54 This-LU-computer


Here is wher the drive is set to automount on boot in fstab
UUID=3FAC12281A1EAB69 /media/HDDL2 ntfs defaults 0 2

I think Pi had it mounted on /media/pi but I changed it to reflect my other systems,
it mounts, and rsync delivers content to it no problem, but I can't delete from this drive.
Last edited by Cloud1 on Wed Jun 16, 2021 11:09 am, edited 2 times in total.

LTolledo
Posts: 5561
Joined: Sat Mar 17, 2018 7:29 am
Location: Anime Heartland

Re: Can't delete files on an external USB HDD

Tue Jun 15, 2021 9:11 pm

set the ownership of the drive,
1. via fstab when the drive is mounted
2. via terminal

lets say the default login is "cloud"
when you check the drive, the files should show something like this...

Code: Select all

-rw-rw--rw-  1 cloud  cloud   120172255 Jun  1  2020 'Attack on Attackers ep10.mp4'
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

Cloud1
Posts: 44
Joined: Sat Jun 05, 2021 3:46 pm

Re: Can't delete files on an external USB HDD

Tue Jun 15, 2021 9:23 pm

Thanks @LTolledo , but I aint smart enough to understand what you just wrote,
it looks nothing like my fstab entry, I couldn't imagin I could make what you wrote work,

Here is where the drive is set to automount on boot in fstab , so what do I need to modify or add.
UUID=3FAC12281A1EAB69 /media/HDDL2 ntfs defaults 0 2

I kept the original user name pi, and just changed the password.
Last edited by Cloud1 on Wed Jun 16, 2021 11:14 pm, edited 2 times in total.

LTolledo
Posts: 5561
Joined: Sat Mar 17, 2018 7:29 am
Location: Anime Heartland

Re: Can't delete files on an external USB HDD

Tue Jun 15, 2021 9:40 pm

Cloud1 wrote:
Tue Jun 15, 2021 9:23 pm
Thanks @LTolledo , but I aint smart enough to understand what you just wrote,
it looks nothing like my fstab entry, I couldn't imagin I could make what you wrote work,

Here is wher the drive is set to automount on boot in fstab , so what do I need to modify or add.
UUID=3FAC12281A1EAB69 /media/HDDL2 ntfs defaults 0 2

I kept the original user name pi, and just changed the password.
on one of my desktops, the external hard disk is auto-mounted (no entry in fstab)
but I've set the ownership and permissions via terminal window

Code: Select all

sudo chown -R pi:pi /media/pi/USBHDD
sudo chmod -R 777 /media/pi/USBHDD
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

markkuk
Posts: 276
Joined: Thu Mar 22, 2018 1:02 pm
Location: Finland

Re: Can't delete files on an external USB HDD

Wed Jun 16, 2021 7:01 am

Cloud1 wrote:
Tue Jun 15, 2021 8:24 pm
Am I right in thinking the user pi is the root user, and this is why nothing changes when I change
the ownership to this user and group.
No, you're wrong. The root user is identifed by User ID (UID) == 0 and conventionally has username "root". The user "pi" has UID 1000 in Raspberry Pi OS.
Cloud1 wrote:
Tue Jun 15, 2021 8:24 pm
Here is wher the drive is set to automount on boot in fstab
UUID=3FAC12281A1EAB69 /media/HDDL2 ntfs defaults 0 2
NTFS does not support Linux ownership or permissions, that's why chown or chmod don't work on this drive. You need to use parameters in the fstab file to set the permissions:

Code: Select all

UUID=3FAC12281A1EAB69  /media/HDDL2  ntfs uid=1000,gid=1000  0  2

Cloud1
Posts: 44
Joined: Sat Jun 05, 2021 3:46 pm

Re: Can't delete files on an external USB HDD

Wed Jun 16, 2021 11:00 am

markkuk wrote:
Wed Jun 16, 2021 7:01 am
Cloud1 wrote:
Tue Jun 15, 2021 8:24 pm
Am I right in thinking the user pi is the root user, and this is why nothing changes when I change
the ownership to this user and group.
No, you're wrong. The root user is identifed by User ID (UID) == 0 and conventionally has username "root". The user "pi" has UID 1000 in Raspberry Pi OS.
Cloud1 wrote:
Tue Jun 15, 2021 8:24 pm
Here is wher the drive is set to automount on boot in fstab
UUID=3FAC12281A1EAB69 /media/HDDL2 ntfs defaults 0 2
NTFS does not support Linux ownership or permissions, that's why chown or chmod don't work on this drive. You need to use parameters in the fstab file to set the permissions:

Code: Select all

UUID=3FAC12281A1EAB69  /media/HDDL2  ntfs uid=1000,gid=1000  0  2
And that makes sense, I remember hearing this before when I was trashing my head with what
file system to use on external drives.
I will test again and if rsync can can delete files from the drive during a test backup then I will be happy,
if it can’t then I will try the setting as you kindly provided.

Thanks to all who posted, I will report what works, thanks.

User avatar
thagrol
Posts: 5262
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Can't delete files on an external USB HDD

Wed Jun 16, 2021 11:10 am

See the troubleshooting section of my guide to fstab found in the beginner's section and make sure you have the ntfs-3g package installed (it's installed by default on recent builds of RPiOS).
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

Cloud1
Posts: 44
Joined: Sat Jun 05, 2021 3:46 pm

Re: Can't delete files on an external USB HDD

Wed Jun 16, 2021 1:30 pm

thagrol wrote:
Wed Jun 16, 2021 11:10 am
See the troubleshooting section of my guide to fstab found in the beginner's section and make sure you have the ntfs-3g package installed (it's installed by default on recent builds of RPiOS).
Yes, ntfs-3g is installed, I will try and find the guide you mention, thanks.

Just found your write up- Exelent source of information.
viewtopic.php?f=91&t=302752
And GitHub, https://github.com/thagrol/Guides

Cloud1
Posts: 44
Joined: Sat Jun 05, 2021 3:46 pm

Re: Can't delete files on an external USB HDD

Wed Jun 16, 2021 5:18 pm

Thanks @thagrol , rsync had the same issue with deleting files on the USB drive
in question, no real surprise there.

As soon as I updated /etc/fstab with the code provided I was able to delete files,
no errors either.

I went from this
UUID=3FAC12281A1EAB69 /media/HDDL2 ntfs defaults 0 2
To this
UUID=3FAC12281A1EAB69 /media/HDDL2 ntfs uid=1000,gid=1000 0 2

Now the reult of the below command shows the user pi is in charge,
$ stat -c "%U:%G" /media/HDDL2/BLu-1/
pi:pi

Thanks to all who posted a reply, much appreciated.

Cloud1
Posts: 44
Joined: Sat Jun 05, 2021 3:46 pm

Re: Can't delete files on an external USB HDD

Wed Jun 16, 2021 5:24 pm

LTolledo wrote:
Tue Jun 15, 2021 9:40 pm
Cloud1 wrote:
Tue Jun 15, 2021 9:23 pm
Thanks @LTolledo , but I aint smart enough to understand what you just wrote,
it looks nothing like my fstab entry, I couldn't imagin I could make what you wrote work,

Here is wher the drive is set to automount on boot in fstab , so what do I need to modify or add.
UUID=3FAC12281A1EAB69 /media/HDDL2 ntfs defaults 0 2

I kept the original user name pi, and just changed the password.
on one of my desktops, the external hard disk is auto-mounted (no entry in fstab)
but I've set the ownership and permissions via terminal window

Code: Select all

sudo chown -R pi:pi /media/pi/USBHDD
sudo chmod -R 777 /media/pi/USBHDD
Thanks for posting, I have a question now,
is the refference /pi in the above the mount point or is USBHDD the mount point.

Just to be sure I understand what is being modified, thanks

LTolledo
Posts: 5561
Joined: Sat Mar 17, 2018 7:29 am
Location: Anime Heartland

Re: Can't delete files on an external USB HDD

Wed Jun 16, 2021 9:00 pm

Code: Select all

/media/pi/USBHDD 
is my mount point, just like your

Code: Select all

/media/HDDL2
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

Cloud1
Posts: 44
Joined: Sat Jun 05, 2021 3:46 pm

Re: Can't delete files on an external USB HDD

Wed Jun 16, 2021 11:09 pm

LTolledo wrote:
Wed Jun 16, 2021 9:00 pm

Code: Select all

/media/pi/USBHDD 
is my mount point, just like your

Code: Select all

/media/HDDL2
Thanks for explaining this.

LTolledo
Posts: 5561
Joined: Sat Mar 17, 2018 7:29 am
Location: Anime Heartland

Re: Can't delete files on an external USB HDD

Sat Jun 26, 2021 9:11 pm

applezop wrote:
Sat Jun 26, 2021 8:54 am
......You can do this by right clicking on the file/folder and selecting the Security tab......
Note: this is impossible to do on a non-desktop setup
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

User avatar
thagrol
Posts: 5262
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Can't delete files on an external USB HDD

Sat Jun 26, 2021 9:58 pm

applezop wrote:
Sat Jun 26, 2021 8:54 am
......You can do this by right clicking on the file/folder and selecting the Security tab......
Not on an NTFS partition. Which is what this thread is about.
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

Return to “General discussion”