Fix local drive mounts showing empty for apps running as PUID/PGID

Move chown/chmod to after mount so mount point is accessible by the
configured PUID/PGID user. Previously chown ran before mount, making
it useless since the mount replaces directory permissions with the
filesystem's root inode permissions.

For POSIX filesystems (btrfs, ext4) that don't support uid/gid mount
options, this ensures the mount point is traversable by non-root users.

Fixes #1868

Agent-Logs-Url: https://github.com/alexbelgium/hassio-addons/sessions/338cfbaa-45f3-4ff2-a2f7-b6e8fa3ee9b1

Co-authored-by: alexbelgium <44178713+alexbelgium@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-05-22 15:02:51 +00:00
committed by GitHub
parent fe4120bbdf
commit 00f7b604fe
2 changed files with 13 additions and 6 deletions

View File

@@ -60,11 +60,6 @@ if bashio::config.has_value 'localdisks'; then
# Creates dir
mkdir -p /mnt/"$disk"
if bashio::config.has_value 'PUID' && bashio::config.has_value 'PGID'; then
PUID="$(bashio::config 'PUID')"
PGID="$(bashio::config 'PGID')"
chown "$PUID:$PGID" /mnt/"$disk"
fi
# Check FS type and set relative options (thanks @https://github.com/dianlight/hassio-addons)
fstype=$(lsblk "$devpath"/"$disk" -no fstype)
@@ -101,12 +96,23 @@ if bashio::config.has_value 'localdisks'; then
if [ -d /share/"$disk" ]; then dirpath="/share"; fi
# shellcheck disable=SC2015
mount -t $type "$devpath"/"$disk" "$dirpath"/"$disk" -o $options && bashio::log.info "Success! $disk mounted to /mnt/$disk" \
mount -t $type "$devpath"/"$disk" "$dirpath"/"$disk" -o $options && bashio::log.info "Success! $disk mounted to $dirpath/$disk" \
|| (
bashio::log.fatal "Unable to mount local drives! Please check the name."
rmdir /mnt/"$disk"
bashio::addon.stop
)
# Set ownership and permissions on the mount point AFTER mounting
# so that apps running as PUID/PGID can access the content
if bashio::config.has_value 'PUID' && bashio::config.has_value 'PGID'; then
PUID="$(bashio::config 'PUID')"
PGID="$(bashio::config 'PGID')"
chown "$PUID:$PGID" "$dirpath"/"$disk" 2>/dev/null \
|| bashio::log.warning "Could not chown $dirpath/$disk to $PUID:$PGID - content may not be accessible"
chmod 755 "$dirpath"/"$disk" 2>/dev/null \
|| bashio::log.warning "Could not chmod $dirpath/$disk - content may not be accessible"
fi
done
fi

View File

@@ -1,6 +1,7 @@
## 10.11.9 (2026-05-22)
- Update to latest version from linuxserver/docker-jellyfin (changelog : https://github.com/linuxserver/docker-jellyfin/releases)
- Fix local drive mounts (btrfs/ext4) showing empty when app runs as PUID/PGID
## 10.11.8 (2026-04-06)
- Update to latest version from linuxserver/docker-jellyfin (changelog : https://github.com/linuxserver/docker-jellyfin/releases)