Self-Hosting Immich with NFS Storage for Private Photo Backups and Local Machine-Learning Search
Self-hosting a family photo library usually hits a storage split right away: your compute server has the fast NVMe drive and GPU or iGPU needed for instant thumbnails and machine-learning search, while your multi-terabyte RAID array lives over the network on a NAS. Putting PostgreSQL directly onto an NFS share invites database corruption during heavy indexing, yet storing years of RAW images and 4K phone videos on a small hypervisor SSD fills the disk in an afternoon.
In this guide, you will deploy Immich in Docker using a split-tier storage layout: PostgreSQL vector indexes on local NVMe, mobile backups on an NFSv4 NAS mount, existing desktop photo archives mounted strictly read-only, and local CLIP machine-learning models running offline. For the companion story on rebuilding classic 60-fps desktop photo browsing alongside local NAS folders, read Rebuilding Classic Photo Management on Linux with Rust and egui on Frizzle Tech Blog.
Prerequisites
Before launching the containers, prepare a Linux Docker host with local SSD space for the database, an NFSv4 export on your NAS for bulk photo storage, a Git repository (on GitHub, GitLab, or self-hosted GitLab) to version your docker-compose.yml (keeping .env gitignored), and optionally an AI coding assistant such as Antigravity, Claude Code, or Codex to verify hardware acceleration device paths on your host.
- A Linux host (
x86-64) running Docker Engine and Docker Compose, withnfs-commoninstalled (sudo apt-get install -y nfs-common). - At least
40 GBof free local NVMe SSD space at/path/to/local-nvme/immich-postgresand/path/to/local-nvme/immich-model-cache. - A NAS NFSv4 export (for example,
<nas-ip>:/volume1/photos) with read/write access for new mobile uploads and a subdirectory containing your existing photo archive. - Optional Intel iGPU (
/dev/dri) or NVIDIA GPU (with NVIDIA Container Toolkit) for hardware-accelerated machine learning and video transcoding.
Step 1: Mount the NAS Photo Share Cleanly Over NFSv4
Database files must stay off network shares, while bulk media files belong on redundant NAS disks. Create dedicated mount points on the Docker host and mount the NAS export over NFSv4 using _netdev and noatime so boot ordering waits for the network interface and directory scans do not generate unnecessary metadata writes:
sudo mkdir -p /mnt/nas-photos /path/to/local-nvme/immich-postgres /path/to/local-nvme/immich-model-cache
sudo chown -R 1000:1000 /path/to/local-nvme/immich-model-cache
Add the NFSv4 mount entry to /etc/fstab (replacing <nas-ip> and the export path with your NAS details):
<nas-ip>:/volume1/photos /mnt/nas-photos nfs4 rw,hard,intr,noatime,_netdev 0 0
Apply and verify the mount before starting Docker:
sudo mount -a
df -hT /mnt/nas-photos
mkdir -p /mnt/nas-photos/immich-uploads
Keeping hard enabled prevents silent half-written files if a switch briefly restarts during a phone backup batch.
Step 2: Split NVMe Database Storage from NAS Media in Docker Compose
Create /path/to/git/immich/.env with explicit paths separating UPLOAD_LOCATION (on NFS) from DB_DATA_LOCATION (on local NVMe):
IMMICH_VERSION=release
UPLOAD_LOCATION=/mnt/nas-photos/immich-uploads
EXTERNAL_ARCHIVE_PATH=/mnt/nas-photos/archive
DB_DATA_LOCATION=/path/to/local-nvme/immich-postgres
MODEL_CACHE_LOCATION=/path/to/local-nvme/immich-model-cache
TZ=America/Los_Angeles
DB_USERNAME=postgres
DB_PASSWORD=change-this-long-random-password
DB_DATABASE_NAME=immich
Next, create /path/to/git/immich/docker-compose.yml. Notice how /usr/src/app/external is mounted with :ro so Immich can index your existing desktop photo folders without ever modifying, renaming, or deleting original files:
name: immich
services:
immich-server:
container_name: immich_server
image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
restart: unless-stopped
env_file:
- .env
ports:
- "2283:2283"
devices:
- /dev/dri:/dev/dri
volumes:
- ${UPLOAD_LOCATION}:/usr/src/app/upload
- ${EXTERNAL_ARCHIVE_PATH}:/usr/src/app/external:ro
- /etc/localtime:/etc/localtime:ro
depends_on:
- redis
- database
immich-machine-learning:
container_name: immich_machine_learning
image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}-openvino
restart: unless-stopped
env_file:
- .env
devices:
- /dev/dri:/dev/dri
volumes:
- ${MODEL_CACHE_LOCATION}:/cache
redis:
container_name: immich_redis
image: docker.io/valkey/valkey:8-bookworm
restart: unless-stopped
database:
container_name: immich_postgres
image: ghcr.io/immich-app/postgres:16-vectorchord0.3.0-pgvectors0.2.0
restart: unless-stopped
environment:
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_USER: ${DB_USERNAME}
POSTGRES_DB: ${DB_DATABASE_NAME}
POSTGRES_INITDB_ARGS: "--data-checksums"
volumes:
- ${DB_DATA_LOCATION}:/var/lib/postgresql/data
If your host does not have an Intel iGPU at /dev/dri, omit the devices: lines and drop the -openvino suffix from immich-machine-learning (or switch to -cuda on an NVIDIA host).
Step 3: Launch the Stack and Verify Local Machine-Learning Inference
Start the containers and watch the initial database migration and ONNX model cache download:
cd /path/to/git/immich
docker compose up -d
docker compose logs -f immich-server immich-machine-learning
Browse to http://<host-ip>:2283 to create your admin account, then open Administration -> Settings -> Machine Learning Settings. Verify that the Smart Search URL points to http://immich-machine-learning:3003 with CLIP (ViT-B-32__openai) and Facial Recognition (buffalo_l) enabled. Every embedding vector is computed locally on your hardware and stored inside the NVMe PostgreSQL VectorChord index without sending a single photo to an external cloud API.
Step 4: Register Read-Only External Folders and Test Search
To index decades of existing desktop folders alongside new phone uploads without duplicating files:
1. Open Administration -> External Libraries -> Create Library and assign it to your user.
2. Add /usr/src/app/external as an import path and click Validate -> Save.
3. Click Scan All Libraries and watch Job Status under Administration -> Jobs.
Once thumbnail generation and Smart Search jobs finish, test a natural-language query such as "snowy mountain trail" or "birthday cake" in the search bar and verify sub-second results while confirming ls -la /mnt/nas-photos/archive remains untouched on disk.
Hardware & Gear Used in This Guide
- Compute node: Mini-PC or Proxmox VM with Intel QuickSync/OpenVINO iGPU (
/dev/dri) and 16 GB RAM - Database storage: Local PCIe NVMe SSD dedicated to PostgreSQL vector indexes and ONNX model caches
- Bulk photo storage: Multi-bay NAS exporting RAID-protected folders over NFSv4 on a 2.5GbE LAN
- Mobile clients: iOS and Android Immich app configured for automatic background Wi-Fi photo backup
What You Can Do Next
- Schedule nightly
pg_dumpallbackups from the local NVMe database container onto a separate backup dataset on your NAS so vector metadata and albums can be restored alongside raw photos. - Configure Storage Templates in Immich Administration so new mobile uploads organize automatically into
YYYY/MMdirectory trees on/mnt/nas-photos/immich-uploads. - Read Rebuilding Classic Photo Management on Linux with Rust and egui on Frizzle Tech Blog to see how a native Rust desktop viewer pairs with the same NAS photo folders for 60-fps studio browsing.
Later,
SteveO
