"yum clean" hangs - what to try next?

30,535

Solution 1

I had the same problem, all my yum commands were hanging.

I ran the following commands

rm /var/lib/rpm/__db*
rm /var/lib/rpm/.rpm.lock
rm /var/lib/rpm/.dbenv.lock

So a combination of some of the above comments and answers.

Solution 2

On my Redhat 7.2 this helps to let run the yum commands.

 rm /var/lib/rpm/.dbenv.lock

Solution 3

In my case, I had all but one server with

[main]
enabled=1

in

/etc/yum/pluginconf.d/subscription-manager.conf

Setting this to enabled=0 fixed my issue.

Solution 4

This is not a direct answer, but if none of the commands from the other answers helped then I'd check the command package-cleanup.

All the proposed commands are for handling the RPM database, but it could be that there's something broken in the relation of some installed packages.

From man package-cleanup:

DESCRIPTION
       package-cleanup is a program for cleaning up the locally-installed RPMs.
EXAMPLES
       List all dependency problems:
              package-cleanup --problems

       List all packages that are not in any Yum repository:
              package-cleanup --orphans

I'd start with the command in the second example, I've used it before and it solved some weird issues I had in one of my CentOS machines which was related to yum clean.

Share:
30,535

Related videos on Youtube

Hamish Downer
Author by

Hamish Downer

Unless I explicitly state otherwise in a post, all my original contributions to StackOverflow and ServerFault are placed into the public domain. If this is not legally possible, then anyone receiving a copy of them by any means is granted a non-exclusive perpetual license to use, distribute and modify them, and to distribute modifications, under any license or none, with or without attribution to me. Please note that this license applies only to my original contributions.

Updated on September 18, 2022

Comments

  • Hamish Downer
    Hamish Downer over 1 year

    I run a number of CentOS servers. I was recently doing the occasional yum update but this failed on a handful of the servers. On most I have been able to move forward by doing:

    # yum clean all
    # rm -f /var/lib/rpm/__db*
    # rpm --rebuilddb
    # yum update
    

    However on one server, the yum clean command hangs. I have tried running:

    # yum -v --noplugins clean all
    

    but I get no output at all. Yum just hangs, and will sit there for hours if I let it, not using any cpu, just stopped. Doing

    # strace -f yum -v --noplugins clean all
    

    produces quite a lot of output, but then stops with:

    ...
    stat64("/var/lib/rpm/__db.003", {st_mode=S_IFREG|0644, st_size=450560, ...}) = 0
    open("/var/lib/rpm/__db.003", O_RDWR|O_LARGEFILE) = 4
    fcntl64(4, F_SETFD, FD_CLOEXEC)         = 0
    mmap2(NULL, 450560, PROT_READ|PROT_WRITE, MAP_SHARED, 4, 0) = 0xb6b34000
    close(4)                                = 0
    stat64("/var/lib/rpm/Packages", {st_mode=S_IFREG|0644, st_size=14938112, ...}) = 0
    open("/var/lib/rpm/Packages", O_RDONLY|O_LARGEFILE) = 4
    fcntl64(4, F_SETFD, FD_CLOEXEC)         = 0
    read(4, "\0\0\0\0\1\0\0\0\0\0\0\0a\25\6\0\10\0\0\0\0\20\0\0\0\10\0\0k\t\0\0"..., 512) = 5
    12
    close(4)                                = 0
    open("/var/lib/rpm/Packages", O_RDONLY|O_LARGEFILE) = 4
    fcntl64(4, F_SETFD, FD_CLOEXEC)         = 0
    fstat64(4, {st_mode=S_IFREG|0644, st_size=14938112, ...}) = 0
    futex(0xb6b7bd1c, FUTEX_WAIT, 1, NULL
    

    At this point I'm feeling stuck. This is a production server, so I don't want to just blow it away, or even blow away all the yum information. Apart from the yum stuff, the server is working fine.

    • gokva
      gokva about 12 years
      do you have any nfs mounted filesystems that are currently hung?
    • Janne Pikkarainen
      Janne Pikkarainen about 12 years
      What does lsof reveal, if anything?
    • Hamish Downer
      Hamish Downer about 12 years
      There is a single root fs (with plenty of space) and then just proc, sysfs and tmpfs (and tmpfs has plenty of space).
    • Hamish Downer
      Hamish Downer about 12 years
      @JannePikkarainen - lsof /var/lib/rpm/Packages originally showed an old rpm process. I've killed that, and my yum, checked that lsof didn't show anything else accessing the file, and tried again, but I stop at the same place. I've also scanned through the full lsof output and not seen anything that looks likely.
    • Hamish Downer
      Hamish Downer about 12 years
      Also, I can open the file /var/lib/rpm/Packages for reading in another application.
    • Janne Pikkarainen
      Janne Pikkarainen about 12 years
      Does the server have access to outside world? Yes, I know, yum is not supposed to contact the net that soon, but ...
    • Hamish Downer
      Hamish Downer about 12 years
      @JannePikkarainen - yes there is network access. I can ssh into and out of it, and ping other servers. I can load web pages in lynx.
    • GioMac
      GioMac almost 12 years
      need output: rpm -qa|grep yum
    • Brian
      Brian almost 9 years
      Try doing the yum clean all along with yum update after rebuilding the databases (rm -f /var/lib/rpm/__db* and rpm --rebuilddb) instead of before.
  • dimiguel
    dimiguel about 5 years
    This corrupted my yum installation, but then running sudo rpm --rebuilddb && yum clean all did the trick.
  • David Morton
    David Morton almost 5 years
    Brilliant! This worked like a charm for me! I saw the other superuser thread regarding a similar issue, but it turns out the locks were what were freezing it for me. Appreciate this greatly! superuser.com/questions/384963/yum-hangs-and-wont-respond
  • Lkbhai Lr
    Lkbhai Lr about 3 years
    second command helped me in centos