DNF Repair using LIveCD

Is there an easy way that has been documented that will allow you to run DNF to backout / replace / reinstall using the LiveCD? I run from updates-testing and from time to time, there is an update that kills my network connectivity… so when I discover and try to back out, of course I have no network connection and it’s a PITA to either find the appropriate updates, load them to a USB stick and install or sometimes it’s faster to just reinstall.

If I understand your situation correctly, then what you are looking for is the “rollback” feature already included in dnf. Have a look at the following article:

You don’t even need the live CD for it, as - if I am correct - all the old packages should still be in the package management cache … if you didn’t erase it someow :wink: In that case, network should not be necessary which might make it a solution for your situation.

Thanks, I’m familiar with the history command, but my cache was cleared out - so needed network access. After searching around a bit more, I found this: Recovering aborted Fedora Update

That… is incorrect, I’m afraid, at least with the default configuration on Fedora systems. That article only demonstrates undoing pure installs, which are the only type of transaction you can undo from DNF’s history without needing a network connection.

dnf pretty aggressively clears its package cache — basically, it preserves downloaded packages only until the next successful transaction. At which point it clears the whole mess, whether they were even used or not.

(For example:) Earlier I ran a sudo dnf upgrade for the first time in a few days, and with both Qt and Wine being updated the total set was 1.6 Gb — too large for my root partition to do all at once. So, after downloading it all, the transaction test aborted with an insufficient space error.

I ran a sudo dnf upgrade wine\* to get those out of the way. It was quick, because everything was already downloaded.

Then I ran sudo dnf upgrade qt5\*, and dnf had to download every package over again, because as soon as sudo dnf upgrade wine\* succeeded the cache was emptied. (This is a known “gotcha” when prepping for upgrades with dnf system-upgrade, especially, since the natural response to any transaction errors is to remove any installed packages blocking the upgrade. If you do that, use rpm, not dnf, unless you enjoy re-downloading several gigs of upgrade packages.)

…And that’s just for downloaded packages. To run a dnf history undo you need to get the original old versions of the packages back again so they can be reinstalled, from however long ago that was. Which means that, even right now, if I try to undo my wine update from just a couple of hours ago, with or without access to the updates repo:

$ sudo dnf history undo -1  
Last metadata expiration check: 2:12:09 ago on Sun 12 Jan 2020 12:11:50 AM EST.
Undoing transaction 2552, from Sun 12 Jan 2020 12:22:18 AM EST
    Upgrade  mingw32-wine-gecko-2.47.1-1.fc31.noarch            @updates
    Upgraded mingw32-wine-gecko-2.47-10.fc31.noarch             @@System
    Upgrade  mingw64-wine-gecko-2.47.1-1.fc31.noarch            @updates
    Upgraded mingw64-wine-gecko-2.47-10.fc31.noarch             @@System
    Upgrade  wine-5.0-0.rc4.0.fc31.i686                         @updates
    Upgraded wine-4.21-1.fc31.i686                              @@System
    Upgrade  wine-5.0-0.rc4.0.fc31.x86_64                       @updates
    Upgraded wine-4.21-1.fc31.x86_64                            @@System
    Upgrade  wine-alsa-5.0-0.rc4.0.fc31.i686                    @updates
    Upgraded wine-alsa-4.21-1.fc31.i686                         @@System
    Upgrade  wine-alsa-5.0-0.rc4.0.fc31.x86_64                  @updates
    Upgraded wine-alsa-4.21-1.fc31.x86_64                       @@System
    Upgrade  wine-arial-fonts-5.0-0.rc4.0.fc31.noarch           @updates
    Upgraded wine-arial-fonts-4.21-1.fc31.noarch                @@System
    Upgrade  wine-capi-5.0-0.rc4.0.fc31.i686                    @updates
    Upgraded wine-capi-4.21-1.fc31.i686                         @@System
    Upgrade  wine-capi-5.0-0.rc4.0.fc31.x86_64                  @updates
    Upgraded wine-capi-4.21-1.fc31.x86_64                       @@System
    Upgrade  wine-cms-5.0-0.rc4.0.fc31.i686                     @updates
    Upgraded wine-cms-4.21-1.fc31.i686                          @@System
    Upgrade  wine-cms-5.0-0.rc4.0.fc31.x86_64                   @updates
    Upgraded wine-cms-4.21-1.fc31.x86_64                        @@System
    Upgrade  wine-common-5.0-0.rc4.0.fc31.noarch                @updates
    Upgraded wine-common-4.21-1.fc31.noarch                     @@System
    Upgrade  wine-core-5.0-0.rc4.0.fc31.i686                    @updates
    Upgraded wine-core-4.21-1.fc31.i686                         @@System
    Upgrade  wine-core-5.0-0.rc4.0.fc31.x86_64                  @updates
    Upgraded wine-core-4.21-1.fc31.x86_64                       @@System
    Upgrade  wine-courier-fonts-5.0-0.rc4.0.fc31.noarch         @updates
    Upgraded wine-courier-fonts-4.21-1.fc31.noarch              @@System
    Upgrade  wine-desktop-5.0-0.rc4.0.fc31.noarch               @updates
    Upgraded wine-desktop-4.21-1.fc31.noarch                    @@System
    Upgrade  wine-filesystem-5.0-0.rc4.0.fc31.noarch            @updates
    Upgraded wine-filesystem-4.21-1.fc31.noarch                 @@System
    Upgrade  wine-fixedsys-fonts-5.0-0.rc4.0.fc31.noarch        @updates
    Upgraded wine-fixedsys-fonts-4.21-1.fc31.noarch             @@System
    Upgrade  wine-fonts-5.0-0.rc4.0.fc31.noarch                 @updates
    Upgraded wine-fonts-4.21-1.fc31.noarch                      @@System
    Upgrade  wine-ldap-5.0-0.rc4.0.fc31.i686                    @updates
    Upgraded wine-ldap-4.21-1.fc31.i686                         @@System
    Upgrade  wine-ldap-5.0-0.rc4.0.fc31.x86_64                  @updates
    Upgraded wine-ldap-4.21-1.fc31.x86_64                       @@System
    Upgrade  wine-marlett-fonts-5.0-0.rc4.0.fc31.noarch         @updates
    Upgraded wine-marlett-fonts-4.21-1.fc31.noarch              @@System
    Upgrade  wine-ms-sans-serif-fonts-5.0-0.rc4.0.fc31.noarch   @updates
    Upgraded wine-ms-sans-serif-fonts-4.21-1.fc31.noarch        @@System
    Upgrade  wine-openal-5.0-0.rc4.0.fc31.i686                  @updates
    Upgraded wine-openal-4.21-1.fc31.i686                       @@System
    Upgrade  wine-openal-5.0-0.rc4.0.fc31.x86_64                @updates
    Upgraded wine-openal-4.21-1.fc31.x86_64                     @@System
    Upgrade  wine-opencl-5.0-0.rc4.0.fc31.i686                  @updates
    Upgraded wine-opencl-4.21-1.fc31.i686                       @@System
    Upgrade  wine-opencl-5.0-0.rc4.0.fc31.x86_64                @updates
    Upgraded wine-opencl-4.21-1.fc31.x86_64                     @@System
    Upgrade  wine-pulseaudio-5.0-0.rc4.0.fc31.i686              @updates
    Upgraded wine-pulseaudio-4.21-1.fc31.i686                   @@System
    Upgrade  wine-pulseaudio-5.0-0.rc4.0.fc31.x86_64            @updates
    Upgraded wine-pulseaudio-4.21-1.fc31.x86_64                 @@System
    Upgrade  wine-small-fonts-5.0-0.rc4.0.fc31.noarch           @updates
    Upgraded wine-small-fonts-4.21-1.fc31.noarch                @@System
    Upgrade  wine-symbol-fonts-5.0-0.rc4.0.fc31.noarch          @updates
    Upgraded wine-symbol-fonts-4.21-1.fc31.noarch               @@System
    Upgrade  wine-system-fonts-5.0-0.rc4.0.fc31.noarch          @updates
    Upgraded wine-system-fonts-4.21-1.fc31.noarch               @@System
    Upgrade  wine-systemd-5.0-0.rc4.0.fc31.noarch               @updates
    Upgraded wine-systemd-4.21-1.fc31.noarch                    @@System
    Upgrade  wine-tahoma-fonts-5.0-0.rc4.0.fc31.noarch          @updates
    Upgraded wine-tahoma-fonts-4.21-1.fc31.noarch               @@System
    Upgrade  wine-times-new-roman-fonts-5.0-0.rc4.0.fc31.noarch @updates
    Upgraded wine-times-new-roman-fonts-4.21-1.fc31.noarch      @@System
    Upgrade  wine-twain-5.0-0.rc4.0.fc31.i686                   @updates
    Upgraded wine-twain-4.21-1.fc31.i686                        @@System
    Upgrade  wine-twain-5.0-0.rc4.0.fc31.x86_64                 @updates
    Upgraded wine-twain-4.21-1.fc31.x86_64                      @@System
    Upgrade  wine-wingdings-fonts-5.0-0.rc4.0.fc31.noarch       @updates
    Upgraded wine-wingdings-fonts-4.21-1.fc31.noarch            @@System
No package mingw32-wine-gecko-2.47-10.fc31.noarch available.
No package mingw64-wine-gecko-2.47-10.fc31.noarch available.
No package wine-alsa-4.21-1.fc31.i686 available.
No package wine-alsa-4.21-1.fc31.x86_64 available.
No package wine-arial-fonts-4.21-1.fc31.noarch available.
No package wine-capi-4.21-1.fc31.i686 available.
No package wine-capi-4.21-1.fc31.x86_64 available.
No package wine-cms-4.21-1.fc31.i686 available.
No package wine-cms-4.21-1.fc31.x86_64 available.
No package wine-common-4.21-1.fc31.noarch available.
No package wine-core-4.21-1.fc31.i686 available.
No package wine-core-4.21-1.fc31.x86_64 available.
No package wine-courier-fonts-4.21-1.fc31.noarch available.
No package wine-desktop-4.21-1.fc31.noarch available.
No package wine-filesystem-4.21-1.fc31.noarch available.
No package wine-fixedsys-fonts-4.21-1.fc31.noarch available.
No package wine-fonts-4.21-1.fc31.noarch available.
No package wine-ldap-4.21-1.fc31.i686 available.
No package wine-ldap-4.21-1.fc31.x86_64 available.
No package wine-marlett-fonts-4.21-1.fc31.noarch available.
No package wine-ms-sans-serif-fonts-4.21-1.fc31.noarch available.
No package wine-openal-4.21-1.fc31.i686 available.
No package wine-openal-4.21-1.fc31.x86_64 available.
No package wine-opencl-4.21-1.fc31.i686 available.
No package wine-opencl-4.21-1.fc31.x86_64 available.
No package wine-pulseaudio-4.21-1.fc31.i686 available.
No package wine-pulseaudio-4.21-1.fc31.x86_64 available.
No package wine-small-fonts-4.21-1.fc31.noarch available.
No package wine-symbol-fonts-4.21-1.fc31.noarch available.
No package wine-system-fonts-4.21-1.fc31.noarch available.
No package wine-systemd-4.21-1.fc31.noarch available.
No package wine-tahoma-fonts-4.21-1.fc31.noarch available.
No package wine-times-new-roman-fonts-4.21-1.fc31.noarch available.
No package wine-twain-4.21-1.fc31.i686 available.
No package wine-twain-4.21-1.fc31.x86_64 available.
No package wine-wingdings-fonts-4.21-1.fc31.noarch available.
No package wine-4.21-1.fc31.i686 available.
No package wine-4.21-1.fc31.x86_64 available.
Error: no package matched

…The old versions are no longer in updates, making dnf history undo useless.

Just to correct myself, ISTR at some point the logic was tweaked slightly so that now it’s closer to “packages are retained until the next successful install transaction”, a change made specifically to address this problem. So if you’re careful to use dnf strictly for removing packages, your upgrade cache will be retained. Just as long as none of those removals trigger any other type of transaction.

@FeRDNYC Good to know, thanks! Didn’t know dnf clears packages so aggressively…
I guess there is no way to configure dnf’s aggressive behaviour? It would make sense if you can ensure somehow to have network connection all the time, or if you don’t want (or can’t) bloat your system. But in a case where you have network issues like mentioned here, a more careful approach really would make sense.

@gbcox Looks like a more comfortable solution than what you applied previously :+1:

1 Like

Yeah, you can set keepcache = True in /etc/dnf/dnf.conf, and dnf will never clear the package cache. From the dnf.conf(5) man page:

       keepcache
              boolean

              Keeps downloaded packages in the cache when set to True. Even if
              it  is  set  to  False and packages have not been installed they
              will  still  persist  until  next  successful  transaction.  The
              default is False.

The caveat being the obvious one: dnf will NEVER clear its cache. Which means that unless you have unlimited disk space, it’s now entirely up to you to manage its contents and keep the size under control.

There might be situations where that makes sense, but it doesn’t seem likely to be workable for most people. And even if it does make sense for you (IOW, if you’re in the “unlimited disk space” camp), it probably still makes more sense to set up a local repo mirror, and just point dnf there to use as its package source. Then you can use a tool like prunerepo to manage the contents.

@FeRDNYC Thanks for the info! I think I will try setting keepcache true; just to observe how fast the package cache is growing. I would like to have something ‘in the middle’, DNF with some kind of garbage collection like algorithm to clear the cache. Oh, and I’m also not in the “unlimited disk space” camp :wink: Rather the oppsite