Immich with Backblaze B2 as primary storage
I’ve been planning on migrating my Nextcloud photos to a more photo-oriented storage solution but one thing in the way is the fact that Immich lacks S3-compatible storage support. To overcome this, my solution was to use an rclone mount
Essentially, you want an rclone mount on /mnt/immich or similar with Backblaze being the storage device you are mounting.
The command you’d want for that is normally rather small, but to fight the latency and other limitations of an rclone mount, I’ve made this very aggressive set of arguments:
rclone mount b2:entekc /mnt/immich \
--allow-other \
--config /home/debian/.config/rclone/rclone.conf \
--allow-non-empty \
--file-perms 0660 \
--dir-perms 0770 \
--dir-cache-time 168h \
--poll-interval 15m \
--vfs-cache-mode full \
--vfs-cache-max-size 50G \
--vfs-cache-max-age 72h \
--vfs-write-back 5s \
--vfs-read-chunk-size 8M \
--vfs-read-chunk-size-limit 512M \
--vfs-read-chunk-size-limit 400M \
--buffer-size 256M \
--fast-list \
--use-mmap \
--b2-chunk-size 20M \
--b2-upload-concurrency 8 \
--transfers 8 \
--checkers 16 \
--multi-thread-streams 16 \
--multi-thread-cutoff 10M \
--timeout 2h \
--contimeout 60s \
--retries 10 \
--retries-sleep 5s \
--low-level-retries 20 \
--stats 1m \
--log-level INFO
This includes, caching, concurrency, chunking, permissions, and stability fixes. I have a decent amount of storage so I have the caching at full blast.
But to keep this running, I made a systemd service at /etc/systemd/system/immich.service:
[Service] Type=simple User=root ExecStart=/usr/bin/rclone mount b2:entekc /mnt/immich \ --allow-other \ --config /home/debian/.config/rclone/rclone.conf \ --allow-non-empty \ --file-perms 0660 \ --dir-perms 0770 \ --dir-cache-time 168h \ --poll-interval 15m \ --vfs-cache-mode full \ --vfs-cache-max-size 50G \ --vfs-cache-max-age 72h \ --vfs-write-back 5s \ --vfs-read-chunk-size 8M \ --vfs-read-chunk-size-limit 512M \ --vfs-read-chunk-size-limit 400M \ --buffer-size 256M \ --use-mmap \ --b2-chunk-size 20M \ --b2-upload-concurrency 8 \ --transfers 8 \ --checkers 16 \ --multi-thread-streams 16 \ --multi-thread-cutoff 10M \ --timeout 2h \ --contimeout 60s \ --retries 10 \ --retries-sleep 5s \ --low-level-retries 20 \ --stats 1m \ --log-level INFO ExecStop=/bin/fusermount -u /mnt/immich Restart=always RestartSec=10
Now, I use docker. this means I have to modify the volume part of my docker compose to get immich to treat this mount as its storage:
volumes: - '/mnt/immich:/usr/src/app/upload' - '/etc/localtime:/etc/localtime:ro'
Additionally, I also set the UPLOAD_LOCATION environment variable to /usr/src/app/upload
And that’s how I did it.