Deleting files via Plex - permissions / ownership issue

Hi folks. I’ve had great support here in the past, so here’s a small issue in my otherwise well-working DietPi-based Plex server that I could use help with.

The problem:

I haven’t tried to delete a movie or TV show from within Plex for quite a while. I feel like this did work at one point, but at the moment it does not. Plex throws up a simple “there was a problem deleting this item” message. I’d like this to work correctly.

Basic details:

My hardware is a Pi 4 and an external Seagate USB drive. The external is media-only. Everything else is on my SD card. I get the error message in Plex for files in any of the folders on that external (music, movies, etc). DietPi is at the latest version 9.12.1, as is Plex at 1.108.1.307.

Focus:
I’ve learned enough to assume this is a permissions and / or ownership issue. If that’s the case, perhaps someone more knowledgeable can spot any conflicts and help me correct them.

More info:
I’ll add a couple more posts below with my samba config and some other useful info that others were asked to share, having read similar posts.

Thanks :slight_smile:

I’ll start with my Samba config.

Of note, when this was first set up, I had problems getting Samba working, and incorporated some suggestions until I finally got it up and running. I’d think some of the lines below may be redundant, or not necessary at all. However, this is the config that finally got me up and running, so I haven’t tinkered with it.

You’ll spot my external, named PLEXDRIVE, and the various users dietpi, plexpi and of course root. I’m wondering if the single mention of the plexpi user is part of the issue.

If we can solve my main problem, I’d be happy to continue on and learn about anything else in this config that should be changed.

  GNU nano 7.2                    /etc/samba/smb.conf                             
[global]

        workgroup = WORKGROUP
        server string = %h server
        dns proxy = no
        log file = /var/log/samba/log.%m
        max log size = 1000
        syslog only = no
        syslog = 0

        panic action = /usr/share/samba/panic-action %d

        security = user
        encrypt passwords = true
        passdb backend = tdbsam
        obey pam restrictions = yes
        unix password sync = yes

        passwd program = /usr/bin/passwd %u
        passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:*>
        pam password change = yes
        map to guest = bad user

        load printers = no
        printcap name = /dev/null
        disable spoolss = yes

[dietpi]
        comment = DietPi Share
        path = /mnt/dietpi_userdata
        browseable = yes
        create mask = 0664
        directory mask = 0775
        valid users = dietpi
        writeable = yes
        max connections = 8

[PLEXDRIVE]
        comment = Samba Share for Plex
        path = /mnt/PLEXDRIVE
        valid users = plexpi
        browseable = yes
        writeable = yes
        create mask = 0775
        directory mask = 0775
        guest ok = no
        force user = root
        force group = root
        follow symlinks = yes
        read raw = yes
        write raw = yes
        socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=131072 SO_SNDBUF=13>
        min receivefile size = 16384
        use sendfile = yes
        aio read size = 16384
        aio write size = 16384
        strict allocate = yes
        strict locking = no
        max connections = 8

If it’s helpful here is my fstab that includes my PLEXDRIVE:

  GNU nano 7.2                        /etc/fstab                                  
# You can use "dietpi-drive_manager" to setup mounts.
# NB: It overwrites and re-creates physical drive mount entries on use.
#----------------------------------------------------------------
# NETWORK
#----------------------------------------------------------------


#----------------------------------------------------------------
# TMPFS
#----------------------------------------------------------------
tmpfs /tmp tmpfs size=1922M,noatime,lazytime,nodev,nosuid,mode=1777
tmpfs /var/log tmpfs size=50M,noatime,lazytime,nodev,nosuid

#----------------------------------------------------------------
# MISC: ecryptfs, vboxsf, glusterfs, mergerfs, bind, Btrfs subvolume
#----------------------------------------------------------------


#----------------------------------------------------------------
# SWAP SPACE
#----------------------------------------------------------------


#----------------------------------------------------------------
# PHYSICAL DRIVES
#----------------------------------------------------------------
PARTUUID=aeecd9eb-02 / ext4 noatime,lazytime,rw 0 1
PARTUUID=aeecd9eb-01 /boot/firmware vfat noatime,lazytime,rw 0 2
UUID=67E9-B406 /mnt/PLEXDRIVE exfat nofail,auto,rw

And in the past I’ve seen others here providing these outputs for troubleshooting:

root@DietPi:~# ls -la /mnt/PLEXDRIVE

total 7172
drwxr-xr-x  15 root   root   262144 Apr 22 22:04  .
drwxr-xr-x   7 plexpi plexpi   4096 Mar 26  2024  ..
-rwxr-xr-x   1 root   root     4096 Mar 30 17:14  ._
-rwxr-xr-x   1 root   root     4096 Mar 30 17:43  ._Bootlegs
drwxr-xr-x   2 root   root   262144 May  4  2024  Bootlegs
-rwxr-xr-x   1 root   root     4096 Mar 30 17:50  ._Concerts
drwxr-xr-x   5 root   root   262144 Mar 26 10:28  Concerts
-rwxr-xr-x   1 root   root     4096 Mar 31 14:18  ._.DS_Store
-rwxr-xr-x   1 root   root     6148 Apr 21 15:53  .DS_Store
-rwxr-xr-x   1 root   root     4096 Mar 30 17:43 '._Family Photos'
drwxr-xr-x   2 root   root   262144 Apr 25  2024 'Family Photos'
-rwxr-xr-x   1 root   root     4096 Mar 30 18:11 '._Family Videos'
drwxr-xr-x  16 root   root   262144 May  7  2024 'Family Videos'
drwxr-xr-x   2 root   root   262144 Apr 17 09:40  .fseventsd
drwxr-xr-x 366 root   root   262144 Apr 20 15:36  Movies
-rwxr-xr-x   1 root   root     4096 Mar 30 17:43  ._Music
drwxr-xr-x  26 root   root   262144 Apr 10 17:16  Music
-rwxr-xr-x   1 root   root     4096 Mar 30 17:45 '._Music Videos'
drwxr-xr-x   4 root   root   262144 Mar 17 07:45 'Music Videos'
drwxr-xr-x  32 root   root   262144 Apr  6 17:27 '   NEW TO WORK ON'
-rwxr-xr-x   1 root   root     4096 Mar 30 20:27 '._   NEW TO WORK ON'
drwxr-xr-x   3 root   root   262144 Mar 30 17:13  .Spotlight-V100
drwxr-xr-x   3 root   root   262144 Mar 30 17:18  .Trashes
drwxr-xr-x 673 root   root   262144 Apr 10 17:45  TV
-rwxr-xr-x   1 root   root     4096 Mar 30 17:14  ._.VolumeIcon.icns
-rwxr-xr-x   1 root   root   400394 Mar 30 17:14  .VolumeIcon.icns
-rwxr-xr-x   1 root   root     4096 Mar 30 17:48  ._Workouts
drwxr-xr-x   3 root   root   262144 Apr 25  2024  Workouts

As well as:

root@DietPi:~# ls -lah
total 36K
drwx------  5 root root 4.0K Apr 23 14:56 .
drwxr-xr-x 18 root root 4.0K Apr 19 19:10 ..
-rw-------  1 root root 7.8K Apr 23 14:56 .bash_history
-rw-r--r--  1 root root  571 Apr 10  2021 .bashrc
drwx------  3 root root 4.0K Mar 27  2024 .config
drwxr-xr-x  3 root root 4.0K Apr  7  2024 .local
-rw-r--r--  1 root root  161 Jul  9  2019 .profile
drwxr-xr-x  2 root root 4.0K Feb 19  2024 .ssh

And finally:

root@DietPi:~# lsblk -o name,fstype,label,size,ro,type,mountpoint,partuuid,uuid

NAME FSTYPE LABEL  SIZE RO TYPE MOUNTPOINT PARTUUID                             UUID
sda               12.7T  0 disk                                                 
├─sda1
│    vfat   EFI    200M  0 part            d6e193a4-0e93-4f2a-8970-8ed7f5cc7210 67E3-17ED
└─sda2
     exfat  PLEXDRIVE
                  12.7T  0 part /mnt/PLEXD b5a81d40-52c8-4f5f-b73f-15adc52b86de 67E9-B406
mmcblk0
                  59.5G  0 disk                                                 
├─mmcblk0p1
│    vfat          128M  0 part /boot/firm aeecd9eb-01                          4E17-76D0
└─mmcblk0p2
     ext4         59.4G  0 part /          aeecd9eb-02                          58ad7a5b-ca2e-47e7-afa3-88d78fff92fd

And that’s it for now. Let me know what you spot, and if you need further info I’ll try to provide it.

Thanks!

Due to your Samba configuration, everything is stored as root user/group. Nobody except root can write/delete files on these folders. Next to this, you are using exfat file system format on your external drive. Usually this doesn’t support Linux file system permissions.

Ah right, I forgot to mention the drive system, sorry about that.

I was under the impression that exFAT was the way to go here. I’m on a Mac for everything aside from this Pi, so my external drive had to be something I could use with both Mac and DietPi. I’m sure it couldn’t have been an Apple file system. It’s been a while, but with all my research before my initial setup, I don’t recall seeing anything other than exFAT suggested.

Perhaps you can fill me in on what your recommendation would have been?

So there’s nothing that can be done? Can Plex work as root… and at least solve the problem that way? Of note, nobody else uses or manages this Plex server but me.

And what does “usually” mean in this context? I assume it would either support or not support, so I’m not clear here.

You could try to mount the drive with dedicated user/group. This could give Plex write access. At least that’s the theory :slight_smile:

To do this, the corresponding entry in /etc/fstab would have to be adjusted. The disadvantage of this is that the Drive Manager should no longer be used, as it overwrites manual settings.

But it might be worth a try.

Can you walk me through what change would need to be made to fstab? I’d have a backup of my SD card, so I could wind back if necessary.


Also, what would you have chosen instead of exFAT? I’m not against starting over at some point, though right now I don’t have the extra drive space. If or when I do, I’d like to know which format to use, if that was a mistake originally.

These are the format options in Mac Disk Utility:

Apple File System (APFS): The file system used by macOS 10.13 or later.*
Mac OS Extended: The file system used by macOS 10.12 or earlier.*
MS-DOS (FAT) and ExFAT: File systems that are compatible with Windows.*

Does you need to switch the drive between your Mac and the Plex device? And if yes, do you usually unmount the drive before removal? Or just unplug and re-plug?

I unplug the drive on occasion and move it to my Mac, primarily when I want to load a large pile of new media on there. I might also move the drive if I wanted to back something up from it to another external. Both cases of course would be much faster than doing it over the network. Before the move, I “poweroff” the Pi and grab the drive when everything is shut down.

That reminds me, and if it matters… I had forgotten to be detailed on this earlier:

I can read and write to the drive from my Mac over the network just fine. I can add and delete files that way.

Also, If I add a movie or TV show to the drive over the network, Plex can scan and update its library to reflect the new files. No problem there.

It’s just the delete action from within Plex itself that I’m “locked out” of using.

That’s why, at my basic-to-intermediate level of experience at least, I assumed my setup, drive format, config, etc. were all generally fine, but one or two small things were missed or out of order, causing this problem.

SAMBA is different from Plex, you can’t compare them in terms of access. Both use different users.
Reading things from the hard drive is different from writing/deleting. These are different authorization’s under Linux.

ok let’s start by determining the user ID for Plex. We can then try to adjust the mount option.

id plex
uid=996(plex) gid=1000(dietpi) groups=1000(dietpi),44(video),105(render),993(plex)

you would need to adjust this entry within /etc/fstab

should looks like this at the end

UUID=67E9-B406 /mnt/PLEXDRIVE exfat nofail,auto,rw,uid=996,gid=1000  0 0

reboot your system once done and check how it looks afterwards

ls -la /mnt/PLEXDRIVE

Will do, thanks. That line was added not too long ago to get my media drive to auto-mount. Prior to that I was having to mount it with a command after each boot.

One question I have about the line: should that double-space be there before 0 0?

Single space should be enough

Thanks. I have some errands this morning and then I’ll proceed when I get back :slight_smile:

Thinking ahead though:

Your impression is that this line would render Drive Manager inactive for this particular drive?

As a workaround… if I restored the original line temporarily, could I then use Drive Manager, and put your new line back afterwards?

A few hours and several outside chores later… I have replaced that fstab line, rebooted, and ls -la /mnt/PLEXDRIVE gives me this, where everything previously owned by root has now changed to plex and dietpi. The second line remains the same.

(edit: that was a bit vague, I guess it’s technically now owner=plex and group=dietpi)

total 7172
drwxr-xr-x  15 plex   dietpi 262144 Apr 25 12:24  .
drwxr-xr-x   7 plexpi plexpi   4096 Mar 26  2024  ..
-rwxr-xr-x   1 plex   dietpi   4096 Mar 30 17:14  ._
-rwxr-xr-x   1 plex   dietpi   4096 Mar 30 17:43  ._Bootlegs
drwxr-xr-x   2 plex   dietpi 262144 May  4  2024  Bootlegs
-rwxr-xr-x   1 plex   dietpi   4096 Mar 30 17:50  ._Concerts
drwxr-xr-x   5 plex   dietpi 262144 Mar 26 10:28  Concerts
-rwxr-xr-x   1 plex   dietpi   4096 Mar 31 14:18  ._.DS_Store
-rwxr-xr-x   1 plex   dietpi   6148 Apr 21 15:53  .DS_Store
-rwxr-xr-x   1 plex   dietpi   4096 Mar 30 17:43 '._Family Photos'
drwxr-xr-x   2 plex   dietpi 262144 Apr 25  2024 'Family Photos'
-rwxr-xr-x   1 plex   dietpi   4096 Mar 30 18:11 '._Family Videos'
drwxr-xr-x  16 plex   dietpi 262144 May  7  2024 'Family Videos'
drwxr-xr-x   2 plex   dietpi 262144 Apr 17 09:40  .fseventsd
drwxr-xr-x 366 plex   dietpi 262144 Apr 20 15:36  Movies
-rwxr-xr-x   1 plex   dietpi   4096 Mar 30 17:43  ._Music
drwxr-xr-x  26 plex   dietpi 262144 Apr 10 17:16  Music
-rwxr-xr-x   1 plex   dietpi   4096 Mar 30 17:45 '._Music Videos'
drwxr-xr-x   4 plex   dietpi 262144 Mar 17 07:45 'Music Videos'
drwxr-xr-x  32 plex   dietpi 262144 Apr  6 17:27 '   NEW TO WORK ON'
-rwxr-xr-x   1 plex   dietpi   4096 Mar 30 20:27 '._   NEW TO WORK ON'
drwxr-xr-x   3 plex   dietpi 262144 Mar 30 17:13  .Spotlight-V100
drwxr-xr-x   3 plex   dietpi 262144 Mar 30 17:18  .Trashes
drwxr-xr-x 673 plex   dietpi 262144 Apr 10 17:45  TV
-rwxr-xr-x   1 plex   dietpi   4096 Mar 30 17:14  ._.VolumeIcon.icns
-rwxr-xr-x   1 plex   dietpi 400394 Mar 30 17:14  .VolumeIcon.icns
-rwxr-xr-x   1 plex   dietpi   4096 Mar 30 17:48  ._Workouts
drwxr-xr-x   3 plex   dietpi 262144 Apr 25  2024  Workouts

Testing out Plex… all seems fine. It works over both local and remote, I can mount the drive on my Mac and work with files there, and finally, I can now delete files from within Plex itself. :slight_smile:

Also ls- lah gives me this, which hasn’t changed and that makes sense.

total 36K
drwx------  5 root root 4.0K Apr 25 12:57 .
drwxr-xr-x 18 root root 4.0K Apr 19 19:10 ..
-rw-------  1 root root 7.9K Apr 25 12:57 .bash_history
-rw-r--r--  1 root root  571 Apr 10  2021 .bashrc
drwx------  3 root root 4.0K Mar 27  2024 .config
drwxr-xr-x  3 root root 4.0K Apr  7  2024 .local
-rw-r--r--  1 root root  161 Jul  9  2019 .profile
drwxr-xr-x  2 root root 4.0K Feb 19  2024 .ssh

Perhaps you can educate me on what changed, and if security or other risks may have been opened up by handling things with this workaround. Perhaps there are less now, with less owned by root? Again, it’s pretty much just my server for myself, so there won’t be others poking around.

And you never answered that question about what drive format might have been preferred to exFAT…?

Finally, if you would go back to my samba config… are there any oddities in there that should be removed or tidied up? I felt like a few things (perhaps too many) were thrown at the wall in getting that to work.