Linux – What happens to RPM transaction when it is interrupted in the middle

linuxrpm

Let's imagine that I'm installing with RPM packages A, B and C. They are installed in the same order. And suddenly in the middle of installing B there is a power cut.

1) regarding state after turning on: What happens to this transaction? Will it be resumed? Or maybe RPM will remove all packages and files from that transaction?

2) regarding user actions: does RPM require user action to do above things or it checks it automatically at computer start?

RPM transctions are described mainly in terms of dependency error or error when computer is still running…

Best Answer

This is, in many ways, a too broad question, but here are some facts:

  • downloaded packages via yum or dnf are cached until a yum clean packages or dnf clean packages operation removes them.
  • downloaded packages via rpm will sit there until manually removed (unless downloaded in an ephemeral /tmp filesystem, in which case they will be lost after a reboot)

Yet, the answer depends on several things:

  1. were you in the middle of a yum or dnf transaction? or was it a direct rpm command? for the former case, yum-complete-transaction will attempt to finish all pending actions. For the latter case, again, it depends on what was the exact stage of the installation that was taking place during the power outage. You can always try to run rpm --force -Uvh $package to reinstall a package regardless its current state. The worst case scenario in this case would be a broken rpm package.

  2. are your hypothetical packages one or more of: grub, kernel, initramfs, dracut, lvm or any package that would give you access to your root filesystem? in this case, the most probable result is an unbootable system that needs to be repaired by other means, e.g. PXE booting into a systemrescue image. The amount of different cases that could happen depending on the packages involved and the dependencies among them makes it impossible to know beforehand what exactly would happen.

Related Question