dpkg tip

If your dpkg runs seem to take a long time in the “reading database” step, try this:

Step One: Clear the available file dpkg --clear-avail

Step Two: Forget old unavailable packages dpkg --forget-old-unavail

Step Three: If you use grep-available or other tools that rely on a useful available file, update the available file using sync-available (in the dctrl-tools package).

The few times I’ve tried it (all situations where the “reading database” step seemed to take ages), it has always sped the process up dramatically. There probably are situations where it won’t make much difference, but I haven’t run into them.

11 replies on “dpkg tip”

Actually, reading the available file should not take that long. The
bottleneck is elsewhere, in reading the (typically) 1000+
/var/lib/dpkg/info/*.list files that are scattered all over the
filesystem. This is what makes dpkg so slow, but it is usually
confined to the first package installation or search — after that,
the files are in the operating system’s cache, unless your system is
tight on RAM.

Running sync-available will recreate and thus defragment the
available file, but that does not usually have a great effect.

What you said probably is true. Nevertheless, I have observed great gains in speed from this, and the cache effect doesn’t explain them (since I usually get fed up with the problem after *repeated* uses of dpkg -i).

thanks for the tip – it did speed up start up of aptitude a great deal

Thanks! this has long been a bane of my existance… having to wait almost a minute sometimes.

*adds these commands to cron*

As of Ubuntu 9.10,
dpkg: warning: obsolete ‘–forget-old-unavail’ option, unavailable packages are automatically cleaned up.

Thank you very much! My old Pentium Pro 200MHz server running Debian Lenny GNU/Linux is much faster in installing packages, I didn’t think it would work.

As of Debian Squeeze running in January 2012, this tip still works and makes a great deal of difference.

Ya ma guru man!
I was struggling around 10 minutes per apt-get operation
Now reading database step takes so short time I cant figure out in which line it reads that goddamn database! THANK YOU! YOU ARE THE BEST (nope, not caps, shift)

Leave a Reply

Your email address will not be published. Required fields are marked *

I accept the Privacy Policy * for Click to select the duration you give consent until.

This site uses Akismet to reduce spam. Learn how your comment data is processed.