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.

9 thoughts on “dpkg tip

  1. 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.

  2. 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).

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

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

    *adds these commands to cron*

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

  6. 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.

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

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>