How do I fix digiKam album paths after replacing a drive and changing the filesystem UUID?

Asked 9/26/2023

3 views

2 answers

0

After moving an Ubuntu 22.04 home directory to a larger SSD, digiKam 7.5 no longer finds the photo albums even though the folders are at the same path as before. The new drive has a different filesystem UUID, and digiKam appears to treat that UUID as part of each album root location. How can the existing digiKam library be reconnected to the same folders without reimporting everything?

Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0

Photography Stack Exchange contributor

2y ago

2 Answers

1

I found an old mail thread from 2011 and some bugs (267131, 456749) that discuss a similar issue. It also seemed to suggest how the digiKam database could be updated to fix the issue.

It seems that, even for non-removable drives, digiKam considers the volume's UUID to be part of the file path to the album. A new filesystem created on a new drive will have a differnt UUID even though it contains the same data as the old. For each root album digiKam stores, in its sql database, a record like:

.headers on
select * from AlbumRoots limit 10;
id|label|status|type|identifier|specificPath
1|digikam|0|1|volumeid:?uuid=90ee45ae-cd07-4e23-a948-7ddf8afff45f|/home/brick/Pictures/digikam

It combines the volume UUID from the identifier column with the path in the specificPath column to decide where to look for files. If it does not find a volume with the specified UUID it considers the album to be missing.

Summarily, fixing it involves:

  1. Use the blkid command to find the UUID of your new volume
  2. Use the sqlite3 command to open digiKam's database
  3. Update the offending AlbumRoot record to the new disk's UUID.
  4. Alternatively, change the AlbumRoot to a UUID-free rubric. Should avoid similar issues going forward, but also seemed to be necessary if using a ZFS based filesystem since digiKam does not seem to pick up the UUID.

1. Getting the new UUID

On my system blkid gave:

$ blkid
/dev/sda4: LABEL="rpool" UUID="8788856976958701461" UUID_SUB="2923538069334769741" BLOCK_SIZE="4096" TYPE="zfs_member" PARTUUID="24ffc0e5-7b57-9940-8526-e267bf4e194a"
/dev/sda2: UUID="a59d3973-47b8-42ec-9d64-755553a7bb33" TYPE="swap" PARTUUID="4a88d048-d33e-0142-bed0-14bc7d1a5e34"
/dev/sda3: LABEL="bpool" UUID="11746124927107044680" UUID_SUB="12202475822180589330" BLOCK_SIZE="4096" TYPE="zfs_member" PARTUUID="252ae807-f008-d54a-a63d-3b9df9dfff1e"
/dev/sda1: UUID="DB82-0239" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="dbb46316-3caf-4f7b-b26c-dde89c848141"

I moved to using a ZFS root directory, so the /dev/sda4: LABEL="rpool" ... entry's PARTUUID="24ffc0e5-7b57-9940-8526-e267bf4e194a" section gives me the required UUID.

2. Open the digiKam database

First ensure you have sqlite3 installed by running, in a terminal:

sudo apt install sqlite3

You need to find the file named digikam4.db. Where this file lives will be up to how you installed digiKam. TBH I'm not exactly sure how to easily and reliably find this file, but I knew mine was stored in the same directory as my first album.

Before you go further, quit digiKam (make sure you got all the windows) and make a backup of the database file in case you break it with the updates. In my case, in a terminal:

cp /home/brick/Pictures/digikam/digikam4.db cp /home/brick/Pictures/digikam/digikam4.db.backup

Then open the database file with sqlite3 in a terminal:

sqlite3 /home/brick/Pictures/digikam/digikam4.db

3. Fix the UUID using sqlite3

Find the current (problematic) AlbumRoot (the .headers line is optional but makes it easier to see what is going on) by typing in the sqlite3 terminal session:

.headers on
select * from AlbumRoots limit 10;

In my case this returned a single record:

id|label|status|type|identifier|specificPath
1|digikam|0|1|volumeid:?uuid=90ee45ae-cd07-4e23-a948-7ddf8afff45f|/home/brick/Pictures/digikam

Now we replace the UUID by the one we found in step 1 using blkid, in my case 24ffc0e5-7b57-9940-8526-e267bf4e194a in the sqlite3 terminal session:

update AlbumRoots set identifier = 'volumeid:?uuid=24ffc0e5-7b57-9940-8526-e267bf4e194a' where identifier = 'volumeid:?uuid=90ee45ae-cd07-4e23-a948-7ddf8afff45f';

I added the where clause just from the habit of never doing unqualified SQL update statements. If you had multiple album roots this would prevent you from breaking other records that were correct.

So, templated the update would be

update AlbumRoots set identifier = 'volumeid:?uuid=<OLD UUID>' where identifier = 'volumeid:?uuid=<NEW UUID>'

Now you should be done. Start up digiKam and, hopefully, everything is as it should be.

4. Alternative ending to 3. without using UUID

I had updated my filesystem from ext4 to ZFS and, even when I made this fix, digiKam still did not recognize my album. With a bit of experimentation (adding another album) it seems that digiKam does not recognise the UUID of my ZFS partition and, instead, created an AlbumRoot entry in a UUID-free format. I then converted my main album to the same format by doing, in the sqlite3 terminal session:

update AlbumRoots set identifier = 'volumeid:?path=/home/brick/Pictures/digikam' where specificPath = '/home/brick/Pictures/digikam';
update AlbumRoots set specificPath = '/' where specificPath = '/home/brick/Pictures/digikam';

Afterwards the AlbumRoots table looked like this:

sqlite> select * from AlbumRoots limit 10;
id|label|status|type|identifier|specificPath
1|digikam|0|1|volumeid:?path=/home/brick/Pictures/digikam|/

In summary, the identifier column becomes volumeid:?path=<absolute_path_to_your_album> and the specificPath column simply becomes /.

Q: Why do it this way? A: You won't run into a similar issue if you upgrade your drive again, as long as you always store the same album in the same absolute path. If you are using ZFS it seems you have no choice.

Q: Why not do it this way? A: For albums on removable drives digiKam won't be able to disambiguate between different physical drives that happen to be mounted at the same, temporary, mount point. For Albums on your fixed / internal drive it should be absolutely fine though.

Originally by user112761. Source · Licensed CC BY-SA 4.0

user112761

2y ago

0

AI Answer

Generated from our catalog & community — verify before relying on it.

digiKam stores each album root using both the folder path and the volume UUID. After cloning/restoring to a new SSD, the path may be unchanged but the filesystem UUID is different, so digiKam treats the album root as missing.

The fix is usually to update the album-root entry in digiKam’s database so the stored UUID matches the new drive. In the AlbumRoots table, digiKam keeps values like:

  • identifiervolumeid:?uuid=...
  • specificPath → your photo folder path

Check your digiKam database, find the affected AlbumRoots row, and replace the old UUID in identifier with the new filesystem UUID for that drive. Back up the database first, and make the change with digiKam closed.

After reopening digiKam, it should recognize the existing albums at the same path again.

If needed, you can inspect the current album-root records with a query such as select * from AlbumRoots; and then update the matching row. The key point is that digiKam is matching on UUID + path, not path alone.

UniqueBot

AI

2y ago

Your Answer