alexbelgium / hassio-addons

My homeassistant addons
MIT License
1.36k stars 193 forks source link

🐛 [Immich] Unable to remove file from disk when mounted via localdisks #1452

Closed golonac closed 2 days ago

golonac commented 3 days ago

Description

Immich 1.104.0 added the ability to delete photos from external libraries. I'm using Home Assistant OS and mounting an external hard drive with the addon's localdisks setting. Deleting a photo does not remove it from disk, and the logs have a permission denied error.

Reproduction steps

1. Configure an external HD with the addon's localdisks setting, e.g. '/dev/disk/by-label/Photos'
2. Move a file to trash in Immich, go into trash and delete
3. See error in Immich Home Assistant addon logs

Addon Logs

-----------------------------------------------------------
 Add-on: Immich
 Self-hosted photo and video backup solution directly from your mobile phone
-----------------------------------------------------------
 Add-on version: 1.106.4-3
 You are running the latest version of this add-on.
 System: Home Assistant OS 12.4  (amd64 / generic-x86-64)
 Home Assistant Core: 2024.6.4
 Home Assistant Supervisor: 2024.06.2
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums
-----------------------------------------------------------
 Provided by: https://github.com/alexbelgium/hassio-addons 
-----------------------------------------------------------
 Defining permissions for main user : 
User UID: 1000
User GID : 1000
-----------------------------------------------------------
/etc/cont-init.d/00-global_var.sh: executing
DB_DATABASE_NAME='immich'
DB_HOSTNAME='homeassistant.local'
DB_PASSWORD=******
DB_PORT='5432'
DB_USERNAME='postgres'
DISABLE_MACHINE_LEARNING='false'
JWT_SECRET=******
PGID='1000'
PUID='1000'
TZ='Europe/Paris'
data_location='/share/immich'
localdisks='/dev/disk/by-label/Photos'
/etc/cont-init.d/00-local_mounts.sh: executing
---------------------------------------------------
[02:28:51] INFO: Available Disks for mounting :
NAME   LABEL            SIZE FSTYPE   RO
└─sda1 Media            1.8T ext4      0
└─sdb1 Photos           1.8T ext4      0
├─sdc2                   24M squashfs  0
---------------------------------------------------
Supported fs :  ext3 ext2 ext4 squashfs vfat msdos iso9660 btrfs
Inspired from : github.com/dianlight
---------------------------------------------------
Local Disks mounting...
... Photos is a device by label
[02:28:52] INFO: Mounting Photos of type ext4
[02:28:52] INFO: Success! Photos mounted to /mnt/Photos
/etc/cont-init.d/00-smb_mounts.sh: executing
/etc/cont-init.d/01-config_yaml.sh: executing
Setting permissions for the config.yaml directory

Load environment variables from /config/addons_config/immich/config.yaml if existing
If accessing the file with filebrowser it should be mapped to /homeassistant/addons_config/immich/config.yaml

---------------------------------------------------------
Wiki here on how to use : github.com/alexbelgium/hassio-addons/wiki/Add‐ons-feature-:-add-env-variables
... no env variables found, exiting
/etc/cont-init.d/01-custom_script.sh: executing
Execute /homeassistant/addons_config/immich/immich.sh if existing
Wiki here : github.com/alexbelgium/hassio-addons/wiki/Add-ons-feature-:-customisation
/etc/cont-init.d/20-folders.sh: executing
[02:28:52] INFO: Setting data location
... check /share/immich folder exists
... setting permissions
... correcting official script
/etc/cont-init.d/99-run.sh: executing
[02:29:01] INFO: Setting variables
DB_DATABASE_NAME='immich'
DB_HOSTNAME='homeassistant.local'
DB_PASSWORD=******
DB_PORT='5432'
DB_USERNAME='postgres'
DISABLE_MACHINE_LEARNING='false'
JWT_SECRET=******
PGID='1000'
PUID='1000'
TZ='Europe/Paris'
data_location='/share/immich'
localdisks='/dev/disk/by-label/Photos'

...

[Nest] 1175  - 06/26/2024, 2:31:19 AM    WARN [Microservices:StorageService] Unable to remove file from disk
[Nest] 1175  - 06/26/2024, 2:31:19 AM    WARN [Microservices:StorageService] Error: EACCES: permission denied, unlink '/mnt/Photos/photo.JPEG'

Architecture

No response

OS

HAos

alexbelgium commented 3 days ago

Hi, you are running as user 1000:1000 so you can only delete photos if they have permissions for this owner

golonac commented 2 days ago

Thanks!! I assumed since the addon was doing the mounting it would have rights by default, changed from the default user 1000:1000 to 0:0 and now deletions work! Sorry for wrong label.

alexbelgium commented 2 days ago

Ahah no problem for security purposes it keeps permissions & ownerships to avoid exposing more data than neeed. Glad it worked!