Rebuild Synaptic database

From PCLinuxOS Knowledgebase
Jump to navigation Jump to search

YOU ARE HERE :: Main Page >> HowTo >> Rebuild Synaptic Database

  • Relevant to ALL editions of PCLinuxOS.

Problem : Synaptic has seemed to quit working.

Synaptic loads up but doesn't load the list and the menu's are grayed out.

Reason - It could be that the Synaptic database is corrupted.

Solution - Open a terminal and enter these commands:

 [<you>@localhost ~]$ su 
    <Then press enter>
 Password: 
    <Enter the root password>

Remove the corrupt database:

 [root@localhost <you>]# rm -f /var/lib/rpm/__db.* 
    <Then press enter>


Rebuild the database:


[root@localhost <you>]# rpm -vv --rebuilddb


    <Then press enter>

You'll see a lot of text scroll by, this may take sometime to complete. Let it finish!

Check for duplicate installed packages:

  [root@localhost ~]# dupeclean
    <Then press enter>

Clean out apt:

  [root@localhost ~]# apt-get clean
    <Then press enter>
  [root@localhost ~]# apt-get autoclean
    <Then press enter>

Close the terminal and try Synaptic again.


Database rebuild information provided by forum member old-polack and Texstar

Here is a bash script provided by forum member keltonix to simplify the aboves steps.

#!/bin/bash

# NAME: resyndb (Rebuild Synaptic Database)

# PURPOSE: Troubleshoot the Synaptic Database by
#          deleting it and rebuilding it entirely

# STEP 2: REMOVE POSSIBLY CORRUPT SYNAPTIC DATABASE
rm -f /var/lib/rpm/__db.*

# STEP 3: BUILD A NEW SYNAPTIC DATABASE
rpm -vv --rebuilddb

# STEP 4: CHECK FOR DUPLICATE INSTALLED PACKAGES
dupeclean

# STEP 4: CLEAN OUT APT
apt-get clean

# STEP 5: AUTOCLEAN APT
apt-get autoclean

# STEP 6: EXIT
exit

To use, first save the above script to /usr/local/bin on your system as synfix (short for "synaptic Fix"). In a terminal as the root user, enter chmod 755 synfix This makes the file executable. To run the file from a terminal as root, enter the command synfix

The bash script will now run each command in the proper order and when finished will exit

If you run the script and see an error like this

[dwmoar@ChimpBoxPrototype bin]$ synfix
error: can't create transaction lock on /var/lib/rpm/__db.000 (No such file or directory)
E: Could not open lock file /var/cache/apt/archives/lock - open (13 Permission denied)
E: Unable to lock the download directory
E: Could not open lock file /var/cache/apt/archives/lock - open (13 Permission denied)
E: Unable to lock the download directory
[dwmoar@ChimpBoxPrototype bin]$

Make sure that you are running the script as the ROOT user.