Keep the Immich DB at SB_ROOT, not the HDD where I moved SB_DATA_DIR?
Posted by DjunaBug
Hi there :) After installing TomSparkBox on my Ubuntu Server, I migrated data to an HDD like so: SBDATADIR=/mnt/12tbdata/sparkbox-data MEDIAROOT=/mnt/12tbdata/sparkbox-data/media My SparkBox install, meanwhile, remains at the default location, on an an NVMe drive: SBROOT=/opt/sparkbox Now I'm checking out Immich (as a prospective new user) and I see the database for Immich lives under SBDATADIR, thanks to its docker-compose.yml file which reads: volumes: Storage wave 2 (2026-06-11): smart-search vectors grow with the photo library — pool, not the small system disk. migrateimmichdbtopool (sparkbox CLI) moves an existing DB here before the container boots. - ${SBDATADIR:-${SBROOT:-/opt/sparkbox}/data}/immich/db:/var/lib/postgresql/data As I've got plenty of free space (~800Gb) on the NVMe drive where SBROOT lives, I'd like to move the Immich database to that drive, which I suspect could be done by shutting down sparkbox, syncing the existing db files and editing the above line in Immich's docker-compose.yml file to, say... ${SBROOT:-/opt/sparkbox}/data/immich/db:/var/lib/postgresql/data But... would my docker-compose.yml tweaks be overwritten on SparkBox updates? Is there any way I can robustly keep an Immich DB under /opt/sparkbox while my PHOTOSPATH remains under SBDATADIR (where it is now)? Many thanks!! Djuna
3 replies
Chris wrote:
Good news — you read it exactly right on both counts. Immich's database folder is deliberately tied to SBDATADIR, so out of the box it lands on your 12TB HDD next to the photos, and there's no separate setting today to peel just the database onto your NVMe while the library stays on the HDD. And yes — hand-editing Immich's docker-compose.yml would get put back the next time you run sudo sparkbox update, since updates re-lay-down the module files, so that route isn't robust like you suspected. Rather than hand you a tweak a future update quietly reverts, I've flagged this to Tom — he handles these setup calls personally and can point you at the safe supported way, or whether it's worth adding a proper option for it. Nothing's wrong with your box in the meantime.
DjunaBug wrote:
Thanks for the quick confirmation :) Based on Immich recommendations (https://docs.immich.app/install/requirements/), it seems the best default behavior would be to keep the DB on SBROOT rather than SBDATADIR: Good performance and a stable connection to the Postgres database is critical to a smooth Immich experience. The Postgres database files are typically between 1-3 GB in size. For this reason, the Postgres database (DBDATALOCATION) should ideally use local SSD storage, and never a network share of any kind. I'm happy to see my Plex database, posters, etc., remain on my SSD under opt/sparkbox/modules/plex/ following migration of data to HDD. If you expect there are those who will encounter space constraints, perhaps offer the option to choose DB location on setup? Or, to quickly offer flexibility, start with making the the Immich DB location a variable that can be optionally overridden in the .env file (if said variable is found there), safe from SparkBox updates? Best! Djuna
Chris wrote:
This is a genuinely good suggestion, Djuna — and your reasoning is spot on: Immich's own docs want that Postgres DB on fast local SSD, which is exactly why you'd want it on the NVMe even with the library sitting on the 12TB HDD. I've passed your specific idea along to Tom on top of the earlier flag — both the setup-time choice and the lighter-weight 'optional .env override that survives updates' angle, since that second one is just the kind of thing that's quick to make safe. I can't promise a timeline, but well-argued requests like this tend to land. Thanks for taking the time to cite the docs!