Jump to content

Recommended Posts

myoldvcr
Posted

My Emby Linux server recording directories are 

drwxrwsrwx+  emby:video

 So, the user is "emby" and the group is "video". The user "emby" is a member of the "video" and "remder" groups. The "+" at the end is an ACL to give write access to the "video" group and the "s" is a sticky bit flag for the folder to prevent anyone but the owner to delete it, I think. If you want to see what your permissions are for your recording folder you can use this command.

getfacl folder-path

I give full permissions to everyone so I can access my shared folders from a Windows PC on the network. 

Q-Droid
Posted
11 hours ago, Lessaj said:

I'm not really familiar with the "rws" that is showing up in your permissions and I think that's very strange. I've read a little bit about it and it doesn't seem necessary here, I'm wondering if it's the cause of your permission issues.

The setgid bit (s) forces group ownership inheritance for files and dirs created under that directory. They will have consistent ownership at the group level but it doesn't affect permissions. For permissions the umask still applies and ACLs when defined.

 

 

  • Thanks 1
sftech13
Posted

I’m still confused on this issue, maybe its not a issue. All permissions appear to be set correctly, yet I’m still getting permission denied errors. As a workaround, I’ve set up a cron job to run twice a day to reapply the correct permissions across directories.

The strange part is that the cron logs show no changes needed everything looks fine. However, I continue to see "permission denied" errors after 11PM (after the cron has already run) but after 2AM. By the time the cron runs again at 2AM, the issue seems to resolve itself without any permission changes being logged.

I’m not sure what’s causing this or why it temporarily fails even though permissions haven’t changed. 

Logs of script:

[2025-04-23 23:00:01] Starting permission check on /mnt/Media /mnt/Misc
[INFO] Processing: /mnt/Media/Movies
[INFO] Checking metadata file permissions in: /mnt/Media/Movies
[INFO] Processing: /mnt/Media/TV Shows
[INFO] Checking metadata file permissions in: /mnt/Media/TV Shows
[INFO] Processing: /mnt/Misc/Animation
[INFO] Checking metadata file permissions in: /mnt/Misc/Animation
[INFO] Processing: /mnt/Misc/CinemaSounds
[INFO] Checking metadata file permissions in: /mnt/Misc/CinemaSounds
[INFO] Processing: /mnt/Misc/Documentary
[INFO] Checking metadata file permissions in: /mnt/Misc/Documentary
[INFO] Processing: /mnt/Misc/Kodi
[INFO] Checking metadata file permissions in: /mnt/Misc/Kodi
[INFO] Processing: /mnt/Misc/Recordings
[INFO] Checking metadata file permissions in: /mnt/Misc/Recordings
[INFO] Processing: /mnt/Misc/Replays
[INFO] Checking metadata file permissions in: /mnt/Misc/Replays
[INFO] Processing: /mnt/Misc/repo
[INFO] Checking metadata file permissions in: /mnt/Misc/repo
[INFO] Processing: /mnt/Misc/Software
[INFO] Checking metadata file permissions in: /mnt/Misc/Software
[INFO] Processing: /mnt/Misc/StandUp
[INFO] Checking metadata file permissions in: /mnt/Misc/StandUp
[OK] All .nfo and clearlogo.png files are group writable.

[2025-04-24 02:00:01] Starting permission check on /mnt/Media /mnt/Misc
[INFO] Processing: /mnt/Media/Movies
[INFO] Checking metadata file permissions in: /mnt/Media/Movies
[INFO] Processing: /mnt/Media/TV Shows
[INFO] Checking metadata file permissions in: /mnt/Media/TV Shows
[INFO] Processing: /mnt/Misc/Animation
[INFO] Checking metadata file permissions in: /mnt/Misc/Animation
[INFO] Processing: /mnt/Misc/CinemaSounds
[INFO] Checking metadata file permissions in: /mnt/Misc/CinemaSounds
[INFO] Processing: /mnt/Misc/Documentary
[INFO] Checking metadata file permissions in: /mnt/Misc/Documentary
[INFO] Processing: /mnt/Misc/Kodi
[INFO] Checking metadata file permissions in: /mnt/Misc/Kodi
[INFO] Processing: /mnt/Misc/Recordings
[INFO] Checking metadata file permissions in: /mnt/Misc/Recordings
[INFO] Processing: /mnt/Misc/Replays
[INFO] Checking metadata file permissions in: /mnt/Misc/Replays
[INFO] Processing: /mnt/Misc/repo
[INFO] Checking metadata file permissions in: /mnt/Misc/repo
[INFO] Processing: /mnt/Misc/Software
[INFO] Checking metadata file permissions in: /mnt/Misc/Software
[INFO] Processing: /mnt/Misc/StandUp
[INFO] Checking metadata file permissions in: /mnt/Misc/StandUp
[OK] All .nfo and clearlogo.png files are group writable.


EMBY Log snippet:

2025-04-23 11:23:34.109 Error ProviderManager: Error in metadata saver
	*** Error Report ***
	Version: 4.8.11.0
	Command line: /opt/emby-server/system/EmbyServer.dll -programdata /var/lib/emby -ffdetect /opt/emby-server/bin/ffdetect -ffmpeg /opt/emby-server/bin/ffmpeg -ffprobe /opt/emby-server/bin/ffprobe -restartexitcode 3 -updatepackage emby-server-deb_{version}_amd64.deb
	Operating system: Linux version 5.4.0-214-generic (buildd@lcy02-amd64-062) (gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.2)) #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2
	Framework: .NET 6.0.36
	OS/Process: x64/x64
	Runtime: opt/emby-server/system/System.Private.CoreLib.dll
	Processor count: 8
	Data path: /var/lib/emby
	Application path: /opt/emby-server/system
	System.UnauthorizedAccessException: System.UnauthorizedAccessException: Access to the path '/media/Movies/iHostage (2025)/iHostage (2025) {imdb-tt31181421} [NF][WEBDL-2160p][HDR10][EAC3 Atmos 5.1][h265]-MWeb.nfo' is denied.
	 ---> System.IO.IOException: Permission denied
	   --- End of inner exception stack trace ---
	   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
	   at Interop.CheckIo(Error error, String path, Boolean isDirectory, Func`2 errorRewriter)
	   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
	   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
	   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
	   at System.IO.Strategies.FileStreamHelpers.ChooseStrategy(FileStream fileStream, String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize)
	   at System.IO.FileStream..ctor(String path, FileStreamOptions options)
	   at Emby.Server.Implementations.IO.ManagedFileSystem.GetFileStream(String path, FileOpenMode mode, FileAccessMode access, FileShareMode share, Int32 bufferSize, FileOpenOptions fileOpenOptions, Int64 preAllocationSize)
	   at Emby.Server.Implementations.IO.ManagedFileSystem.GetFileStream(String path, FileOpenMode mode, FileAccessMode access, FileShareMode share, Boolean isAsync)
	   at NfoMetadata.Savers.BaseNfoSaver.SaveToFile(Stream stream, String path, LibraryOptions libraryOptions, CancellationToken cancellationToken)
	   at NfoMetadata.Savers.BaseNfoSaver.Save(BaseItem item, LibraryOptions libraryOptions, CancellationToken cancellationToken)
	   at Emby.Providers.Manager.ProviderManager.SaveMetadata(BaseItem item, LibraryOptions libraryOptions, ItemUpdateType updateType, IMetadataSaver[] savers, CancellationToken cancellationToken)
	Source: System.Private.CoreLib
	TargetSite: Void ThrowExceptionForIoErrno(ErrorInfo, System.String, Boolean, System.Func`2[Interop+ErrorInfo,Interop+ErrorInfo])
	InnerException: System.IO.IOException: Permission denied
	Source: 
	TargetSite: 
2025-04-23 11:23:35.830 Error ProviderManager: Error in metadata saver
	*** Error Report ***
	Version: 4.8.11.0
	Command line: /opt/emby-server/system/EmbyServer.dll -programdata /var/lib/emby -ffdetect /opt/emby-server/bin/ffdetect -ffmpeg /opt/emby-server/bin/ffmpeg -ffprobe /opt/emby-server/bin/ffprobe -restartexitcode 3 -updatepackage emby-server-deb_{version}_amd64.deb
	Operating system: Linux version 5.4.0-214-generic (buildd@lcy02-amd64-062) (gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.2)) #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2
	Framework: .NET 6.0.36
	OS/Process: x64/x64
	Runtime: opt/emby-server/system/System.Private.CoreLib.dll
	Processor count: 8
	Data path: /var/lib/emby
	Application path: /opt/emby-server/system
	System.UnauthorizedAccessException: System.UnauthorizedAccessException: Access to the path '/media/Movies/Ash (2025)/Ash (2025) {imdb-tt17489650} [AMZN][WEBDL-1080p][EAC3 5.1][h264]-BYNDR.nfo' is denied.
	 ---> System.IO.IOException: Permission denied
	   --- End of inner exception stack trace ---
	   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
	   at Interop.CheckIo(Error error, String path, Boolean isDirectory, Func`2 errorRewriter)
	   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
	   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
	   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
	   at System.IO.Strategies.FileStreamHelpers.ChooseStrategy(FileStream fileStream, String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize)
	   at System.IO.FileStream..ctor(String path, FileStreamOptions options)
	   at Emby.Server.Implementations.IO.ManagedFileSystem.GetFileStream(String path, FileOpenMode mode, FileAccessMode access, FileShareMode share, Int32 bufferSize, FileOpenOptions fileOpenOptions, Int64 preAllocationSize)
	   at Emby.Server.Implementations.IO.ManagedFileSystem.GetFileStream(String path, FileOpenMode mode, FileAccessMode access, FileShareMode share, Boolean isAsync)
	   at NfoMetadata.Savers.BaseNfoSaver.SaveToFile(Stream stream, String path, LibraryOptions libraryOptions, CancellationToken cancellationToken)
	   at NfoMetadata.Savers.BaseNfoSaver.Save(BaseItem item, LibraryOptions libraryOptions, CancellationToken cancellationToken)
	   at Emby.Providers.Manager.ProviderManager.SaveMetadata(BaseItem item, LibraryOptions libraryOptions, ItemUpdateType updateType, IMetadataSaver[] savers, CancellationToken cancellationToken)
	Source: System.Private.CoreLib
	TargetSite: Void ThrowExceptionForIoErrno(ErrorInfo, System.String, Boolean, System.Func`2[Interop+ErrorInfo,Interop+ErrorInfo])
	InnerException: System.IO.IOException: Permission denied
	Source: 
	TargetSite: 

Script:

#!/bin/bash

# --- CONFIG ---
BASE_DIRS=("/mnt/Media" "/mnt/Misc")
LOG_FILE="/home/sftech13/logs/fix_emby_permissions.log"
TIMESTAMP=$(date +"%Y-%m-%d %H:%M:%S")

# --- LOG HEADER ---
echo -e "\n[${TIMESTAMP}] Starting permission check on ${BASE_DIRS[*]}" >> "$LOG_FILE"

for BASE_DIR in "${BASE_DIRS[@]}"; do
    if [ ! -d "$BASE_DIR" ]; then
        echo "[ERROR] Base directory does not exist: $BASE_DIR" >> "$LOG_FILE"
        continue
    fi

    # Loop through each top-level subdirectory
    for DIR in "$BASE_DIR"/*; do
        if [ -d "$DIR" ]; then
            echo "[INFO] Processing: $DIR" >> "$LOG_FILE"

            chown -R emby:emby "$DIR"
            chmod -R ug+rw "$DIR"
            find "$DIR" -type d -exec chmod g+s {} \;

            echo "[INFO] Checking metadata file permissions in: $DIR" >> "$LOG_FILE"
            find "$DIR" \( -iname "*.nfo" -o -iname "clearlogo.png" \) ! -perm -g=w -print >> "$LOG_FILE"
        fi
    done
done

FOUND=$(find "${BASE_DIRS[@]}" \( -iname "*.nfo" -o -iname "clearlogo.png" \) ! -perm -g=w | wc -l)
if [ "$FOUND" -gt 0 ]; then
    echo "[WARN] $FOUND metadata files without group write permission found." >> "$LOG_FILE"
else
    echo "[OK] All .nfo and clearlogo.png files are group writable." >> "$LOG_FILE"
fi

 

sftech13
Posted

I might have the issue will check again later. ACL's

Permissions and ACLs were out of alignment directories were owned by sftech13:emby, but /mnt/Misc didnt have group write access, possibly causing Emby to throw permission errors.

I adjusted them and will see what happens later. 

sftech13@sftech13:~$ getfacl /mnt/Media
getfacl: Removing leading '/' from absolute path names
# file: mnt/Media
# owner: sftech13
# group: emby
# flags: -s-
user::rwx
group::rwx
other::r-x

sftech13@sftech13:~$ getfacl /mnt/Misc
getfacl: Removing leading '/' from absolute path names
# file: mnt/Misc
# owner: sftech13
# group: sftech13
# flags: -s-
user::rwx
group::r-x
other::r-x

After changing them:

sftech13@sftech13:~$ getfacl /mnt/Media
getfacl: Removing leading '/' from absolute path names
# file: mnt/Media
# owner: sftech13
# group: emby
# flags: -s-
user::rwx
group::rwx
other::r-x

sftech13@sftech13:~$ getfacl /mnt/Misc
getfacl: Removing leading '/' from absolute path names
# file: mnt/Misc
# owner: sftech13
# group: emby
# flags: -s-
user::rwx
group::rwx
other::r-x

 

Q-Droid
Posted

You said before that your filesystems are ext4. Does that include the one mounted at /mnt/Media, also ext4?

Could you try creating a new temporary library under /mnt/Media, something like /mnt/Media/Test and use that path in Emby? Don't follow the sym link route of /media/Test like you did with /media/Movies. Then throw a couple of movies in there to see what happens.

 

TMCsw
Posted

@sftech13You mention using 'Swizzin' (the seedbox I presume?) you should probable look into how this creates dirs/files...

There seems to be a logic error in your .sh file???

7 hours ago, sftech13 said:
# Loop through each top-level subdirectory
    for DIR in "$BASE_DIR"/*; do
        if [ -d "$DIR" ]; then
            echo "[INFO] Processing: $DIR" >> "$LOG_FILE"

            chown -R emby:emby "$DIR"
            chmod -R ug+rw "$DIR"
            find "$DIR" -type d -exec chmod g+s {} \;

            echo "[INFO] Checking metadata file permissions in: $DIR" >> "$LOG_FILE"
            find "$DIR" \( -iname "*.nfo" -o -iname "clearlogo.png" \) ! -perm -g=w -print >> "$LOG_FILE"
        fi
    done
done

it seems you are looking for permissions that are wrong after you have corrected them??? I would recommend making it a little bit simpler like the following too better understand what files are the problem and who or what creased them...

find /mnt/media -type f -exec chown -v emby:emby {} \;|grep changed >> $LOG_FILE
find /mnt/media -type d -exec chmod -v 775 {} \;|grep changed >> $LOG_FILE
...
...

Also as @Q-Droidmentions what and how you are mounting these? (DETAILS please)...

sftech13
Posted
2 hours ago, Q-Droid said:

You said before that your filesystems are ext4. Does that include the one mounted at /mnt/Media, also ext4?

Could you try creating a new temporary library under /mnt/Media, something like /mnt/Media/Test and use that path in Emby? Don't follow the sym link route of /media/Test like you did with /media/Movies. Then throw a couple of movies in there to see what happens.

 

Thank you for the response. they are both ext4. I will try your suggestion this weekend. 

sftech13@sftech13:~$ df -T /mnt/Media /mnt/Misc
Filesystem     Type   1K-blocks        Used  Available Use% Mounted on
/dev/md0       ext4 35015431952 31548360916 1709235056  95% /mnt/Media
/dev/sde1      ext4  5813177436  4302960980 1217173996  78% /mnt/Misc


 

sftech13
Posted
1 hour ago, TMCsw said:

@sftech13You mention using 'Swizzin' (the seedbox I presume?) you should probable look into how this creates dirs/files...

There seems to be a logic error in your .sh file???

it seems you are looking for permissions that are wrong after you have corrected them??? I would recommend making it a little bit simpler like the following too better understand what files are the problem and who or what creased them...

find /mnt/media -type f -exec chown -v emby:emby {} \;|grep changed >> $LOG_FILE
find /mnt/media -type d -exec chmod -v 775 {} \;|grep changed >> $LOG_FILE
...
...

Also as @Q-Droidmentions what and how you are mounting these? (DETAILS please)...

LOL good catch... thanks you I adjusted the script and tested it. 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...