Problem with "rpm --rebuilddb" after dnf system upgrade from f35 to f36

Yesterday i upgraded my F35 (gnome) to F36 using dnf system-upgrade. All went smoothly, and my system seems to be working perfectly. But when i tried to run “sudo rpm --rebuilddb” as recommended in the system upgrade docs, I got the following error:

error: failed to replace old database with new database!
error: replace files in /usr/lib/sysimage/rpm with files from /usr/lib/sysimage/rpmrebuilddb.4616 to recover

I tried replacing the files as instructed, and running rpm rebuilddb again but this resulted with the same error message just with a different folder name (rpmrebuilddb.xxxx)

As i said, I seem to have no problems with my fedora installation. If I didn’t try to rebuild rpm db, I would now be perfectly content with my system. But now that I’m receiving this error, which I couldn’t get rid of, despite googling it and trying some rare recommendations, I intend to do a fresh install, which I really don’t want to.

Does anybody have a solution? Thanks a lot in advance.

Hello @aparlak ,
The error indicates how to recover.

There should be a directory
That contains files you would copy over to this directory
So you should be able to copy them over with
sudo cp /usr/lib/sysimage/rpmrebuilddb.4616/* /usr/lib/sysimage/rpm/
Hope that helps.

Thanks for replying. I already did copy the files as suggested. After copying I tried to run sudo rpm -vv --rebuilddb again, to see if the problem went away; unfortunately no… I continue receiving the same error.

Could it be related to this change in Fedora 36?

1 Like

Thanks for the tip.
I checked the timeshift image I made before upgrading. In the backup, /var/lib/rpm contains rpm database files. /usr/lib/sysimage is empty in the backup. (I don’t know if the directory was really empty or timeshift just skipped them)
Currently (after the F36 upgrade) /var/lib/rpm is just a symlink to /usr/lib/sysimage/rpm

I desperately tried copying the db files in the backup to /usr/lib/sysimage/rpm but didn’t help

You might want to check the SELINUX context and permissions of the files:

[grumpey@grumpey0 sysimage]$ ls -lZ
total 0
drwxr-xr-x. 1 root root system_u:object_r:rpm_var_lib_t:s0 154 Mar 27 10:25 rpm
[grumpey@grumpey0 sysimage]$ cd rpm
[grumpey@grumpey0 rpm]$ ls -lZ
total 183408
-rw-r--r--. 1 root root system_u:object_r:rpm_var_lib_t:s0 187777024 May  7 10:19 rpmdb.sqlite
-rw-r--r--. 1 root root system_u:object_r:rpm_var_lib_t:s0     32768 May  8 08:49 rpmdb.sqlite-shm
-rw-r--r--. 1 root root system_u:object_r:rpm_var_lib_t:s0         0 May  7 10:19 rpmdb.sqlite-wal
[grumpey@grumpey0 rpm]$ 

If you need to restore the SELINUX context take you should be able to do so with restorecon

Great. Inspired by your suggestion, I did

sudo fixfiles -B onboot
and rebooted

Problem solved!
(by the way, this was recommended in the dnf system upgrade docs, but i haven’t done it)

Thanks to everyone, especially Joe.

1 Like