I
Immich2mo ago
Chaos

Moving library path

I'm going to move my library from HDD to SSD, and their label is different. Currently my path is /media/4TB/immich/ and the new one will be /media/STORAGE/immich/. What's the process so everything keeps working? Would it be a matter of updating file paths in the db? What would be the right command to do so?
40 Replies
Immich
Immich2mo ago
:wave: Hey @Chaos, Thanks for reaching out to us. Please carefully read this message and follow the recommended actions. This will help us be more effective in our support effort and leave more time for building Immich :immich:. References - Container Logs: docker compose logs docs - Container Status: docker ps -a docs - Reverse Proxy: https://immich.app/docs/administration/reverse-proxy - Code Formatting https://support.discord.com/hc/en-us/articles/210298617-Markdown-Text-101-Chat-Formatting-Bold-Italic-Underline#h_01GY0DAKGXDEHE263BCAYEGFJA Checklist I have... 1. :ballot_box_with_check: verified I'm on the latest release(note that mobile app releases may take some time). 2. :ballot_box_with_check: read applicable release notes. 3. :ballot_box_with_check: reviewed the FAQs for known issues. 4. :ballot_box_with_check: reviewed Github for known issues. 5. :ballot_box_with_check: tried accessing Immich via local ip (without a custom reverse proxy). 6. :ballot_box_with_check: uploaded the relevant information (see below). 7. :ballot_box_with_check: tried an incognito window, disabled extensions, cleared mobile app cache, logged out and back in, different browsers, etc. as applicable (an item can be marked as "complete" by reacting with the appropriate number) Information In order to be able to effectively help you, we need you to provide clear information to show what the problem is. The exact details needed vary per case, but here is a list of things to consider: - Your docker-compose.yml and .env files. - Logs from all the containers and their status (see above). - All the troubleshooting steps you've tried so far. - Any recent changes you've made to Immich or your system. - Details about your system (both software/OS and hardware). - Details about your storage (filesystems, type of disks, output of commands like fdisk -l and df -h). - The version of the Immich server, mobile app, and other relevant pieces. - Any other information that you think might be relevant. Please paste files and logs with proper code formatting, and especially avoid blurry screenshots. Without the right information we can't work out what the problem is. Help us help you ;) If this ticket can be closed you can use the /close command, and re-open it later if needed. Successfully submitted, a tag has been added to inform contributors. :white_check_mark:
schuhbacca
schuhbacca2mo ago
Just bring the stack down. Move all the folders that you want to the new location (Not sure if you just have a single upload location, or custom locations setup). Update the env to point to the new location, and bring the stack back up
Chaos
ChaosOP2mo ago
oh really? It will update the db automatically? That's great
schuhbacca
schuhbacca2mo ago
The db doesn't keep the file system paths. It just knows the container paths.
Chaos
ChaosOP2mo ago
but if I check the db right now (while the library is doing a backup and the server is off) it shows originalpaths showing the full path. You mean they'll get updated as soon as the server starts with a new env, right? @schuhbacca Please confirm when you can before I mess up
schuhbacca
schuhbacca2mo ago
The full path on your actual host machine? Or the full container path eg: usr/src/app/upload/ etc
Chaos
ChaosOP2mo ago
let me see, because I'm running it in Home Assistant, and db and Immich are 2 separate addons/containers
schuhbacca
schuhbacca2mo ago
Oh, home assistant I have no idea This is all default docker compose recommendations Home assistant may do things way different
Chaos
ChaosOP2mo ago
yeah but the process is the same
Chaos
ChaosOP2mo ago
the db tables won't be any different in HA
No description
schuhbacca
schuhbacca2mo ago
I just can't guarantee it there but I would hope it would be the same
Chaos
ChaosOP2mo ago
here you go, you can see originalPath showing the path visible to the container (to all containers in HA really)
schuhbacca
schuhbacca2mo ago
Honestly I can't confidently say
Chaos
ChaosOP2mo ago
in my case, that 4TB is the drive label, which will change could you check your db to see if originalPath shows a similar path?
Zeus
Zeus2mo ago
You can’t change the right side of the mount point. Idk how to change the source (left) side in home asst We don’t support or recommend that deployment
schuhbacca
schuhbacca2mo ago
Yeah mine shows the container path
Chaos
ChaosOP2mo ago
I don't follow. Can you please elaborate?
Zeus
Zeus2mo ago
Not really, idk how it’s setup on home asst
Chaos
ChaosOP2mo ago
what does that mean? Sorry I'm not handy on docker or containers
Zeus
Zeus2mo ago
You could reach out to them or their docs. I’m just describing normal docker setup
Chaos
ChaosOP2mo ago
yeah I udnerstanmd, but can you clarify what you meant with right and left? With an example ideally
schuhbacca
schuhbacca2mo ago
No description
schuhbacca
schuhbacca2mo ago
Normal docker volume mounting Left is host, right is container
Chaos
ChaosOP2mo ago
does the db live in the same container?
schuhbacca
schuhbacca2mo ago
They are seperate containers in the docker setup
Chaos
ChaosOP2mo ago
so then the OriginalPath in your db is what? /usr/src/app/external/photos? so it's the same in HA really I just want to know if when changing the env, the server will run something on server start that will updatee the paths in the db (because at the end of the day, that needs to happen, either auto or manually)
schuhbacca
schuhbacca2mo ago
For the external library yes. For the internal it's just /data/library/... Like we said, we have no idea. Home assistant could set things up differently, we really only support the default setup
Chaos
ChaosOP2mo ago
I understand. Does that mean I cannot ask some guidance to figure things out myself though?
schuhbacca
schuhbacca2mo ago
You certainly can, we just may not know or may inadvertently steer you wrong. So your at your own risk basically
Zeus
Zeus2mo ago
The server will not handle or detect any of those changes
Chaos
ChaosOP2mo ago
ofc cool, that was my guess tbh. I think I will still do a test boot and see the errors happen, just to make sure as it should be harmless. So I'd need to manually run a db query to update all the assets paths, right? Can someone help me with that? Otherwise I'll try AI for guidance
Sergey Katsubo
Sergey Katsubo2mo ago
Just to recap. 1. It's an external library. 2. Your current Import path in Immich settings is like /media/4TB/immich 3. Could you post your Immich volumes: section? I guess the external library (directory) is mounted approximately like: - /media/4TB/immich:/media/4TB/immich 4. You are going to move files on host from 4TB to STORAGE 5. And switching to smth like - /media/STORAGE/immich:/media/STORAGE/immich ? (In principle, you can choose more storage-agnostic internal path, such as /photo. Then upon changing/moving on-host, only compose volume definition has to be updated: /media/4TB/immich:/photo -> /media/STORAGE/immich:/photo, everything will be /photo/... inside the Immich container and the database)
Chaos
ChaosOP2mo ago
1. No, it's not an external library. 2. Yes. Probably that's not how the Home Assistant addon is set up. In HA there's a setting that passes the env for all immich content.
No description
Chaos
ChaosOP2mo ago
I just tried, and guess what, it was much easier than expect. The addon maintainer had already thought of this and implemented the thing.
[Nest] 1197 - 08/29/2025, 9:14:54 AM  WARN [Api:StorageService] Detected a change to media location, performing an automatic migration of file paths from /media/4TB/immich to /media/STORAGE/immich, this may take awhile
[Nest] 1197 - 08/29/2025, 9:14:54 AM  WARN [Api:StorageService] Detected a change to media location, performing an automatic migration of file paths from /media/4TB/immich to /media/STORAGE/immich, this may take awhile
it just updated all db paths for me automatically after changing the env path
Zeus
Zeus2mo ago
That’s immich, not the addon maintainer. This is such a weird path for an internal library, pretty surprised I wish they had a more standard deployment but glad it worked
Chaos
ChaosOP2mo ago
huh? How can it be Immich? That was my initial question all along and all of you explained that it didn't make sense in the default setup because the path would be relative to the container.
Mraedis
Mraedis2mo ago
For future tickets, when you ask questions here we always assume a "normal" deployment, HA Addon is very much not normal
Immich
Immich2mo ago
this.logger.warn(
\`Detected a change to media location, performing an automatic migration of file paths from ${previous} to ${current}, this may take awhile\`,
);
await this.databaseRepository.migrateFilePaths(previous, current);
this.logger.warn(
\`Detected a change to media location, performing an automatic migration of file paths from ${previous} to ${current}, this may take awhile\`,
);
await this.databaseRepository.migrateFilePaths(previous, current);
Chaos
ChaosOP2mo ago
I'll still leave this here in case someone needs doing this manually. The Query to update all paths in the db.
BEGIN;

-- 1. asset table
UPDATE public.asset
SET originalPath = replace(originalPath, '/media/4TB/immich/', '/media/STORAGE/immich/')
WHERE originalPath LIKE '/media/4TB/immich/%';

UPDATE public.asset
SET sidecarPath = replace(sidecarPath, '/media/4TB/immich/', '/media/STORAGE/immich/')
WHERE sidecarPath LIKE '/media/4TB/immich/%';

UPDATE public.asset
SET encodedVideoPath = replace(encodedVideoPath, '/media/4TB/immich/', '/media/STORAGE/immich/')
WHERE encodedVideoPath LIKE '/media/4TB/immich/%';

-- 2. asset_file table
UPDATE public.asset_file
SET path = replace(path, '/media/4TB/immich/', '/media/STORAGE/immich/')
WHERE path LIKE '/media/4TB/immich/%';

-- 3. person table
UPDATE public.person
SET thumbnailPath = replace(thumbnailPath, '/media/4TB/immich/', '/media/STORAGE/immich/')
WHERE thumbnailPath LIKE '/media/4TB/immich/%';

COMMIT;
BEGIN;

-- 1. asset table
UPDATE public.asset
SET originalPath = replace(originalPath, '/media/4TB/immich/', '/media/STORAGE/immich/')
WHERE originalPath LIKE '/media/4TB/immich/%';

UPDATE public.asset
SET sidecarPath = replace(sidecarPath, '/media/4TB/immich/', '/media/STORAGE/immich/')
WHERE sidecarPath LIKE '/media/4TB/immich/%';

UPDATE public.asset
SET encodedVideoPath = replace(encodedVideoPath, '/media/4TB/immich/', '/media/STORAGE/immich/')
WHERE encodedVideoPath LIKE '/media/4TB/immich/%';

-- 2. asset_file table
UPDATE public.asset_file
SET path = replace(path, '/media/4TB/immich/', '/media/STORAGE/immich/')
WHERE path LIKE '/media/4TB/immich/%';

-- 3. person table
UPDATE public.person
SET thumbnailPath = replace(thumbnailPath, '/media/4TB/immich/', '/media/STORAGE/immich/')
WHERE thumbnailPath LIKE '/media/4TB/immich/%';

COMMIT;
yeah, I'm def aware, that's why I always mention it (I thought I did but it seems this time I forgot)

Did you find this page helpful?