What would happen if blackout occurred *during* sudo zypper dup?

Hello

Today i dup’d from TW 20170721 to 20170724 on my Tower. [As far as i know] the process went fine. I delayed rebooting for some tens of minutes as i wished to finish reading some website pages i was reviewing in my browser. I intended then to reboot, but before i could, my neighbourhood suffered an electricity outage “blackout”]. 90’ later with the power back & my Tower running again, all seems fine. However it made me wonder…

…what might have resulted if that blackout had happened during the actual installation phase of the zypper dup? Would it have caused a broken, unbootable, system? Or does TW have some internal magic [cache?] that would somehow have made it ok [aside from me having to roll-back to an earlier Snapshot]? It seems conceptually tricky to me, as presumably some system files would be the new versions, some the old, & whichever one was being written when the power went might be damaged.

Worst case scenario;
Library or otherwise files critical to the functionality of the OS and/or GUI would have been corrupted and you would have been left with a broken system.

Linux in this way is no different than any other OS because it’s simply not possible (or is extremely hard and error prone) to design a system, without backup power of some sort, that doesn’t blow up if files are corrupted when writing. Windows, Linux, BSD, MacOS and everything else suffers from the same “problem”.

Thank you. Yes, that’s exactly what i expected, but wanted to ask experts first.

Well, given that now i am a TW user, & as such my PCs will be getting major system upgrades / replacements much more often than they ever have in their non-openSUSE TW histories, PLUS in July/August in my part of the world strong winds occur, PLUS consequential blackouts are not uncommon now during said winds [trees blown into powerlines, i suspect], i believe that makes me now statistically more likely than ever before to potentially experience a future blackout at just the critically wrong time. Thus, i’m now wondering if maybe this might be the time to begin researching a possible domestic UPS, as a safeguard.

On Wed, 26 Jul 2017 05:56:02 +0000, GooeyGirl wrote:

> Thank you. Yes, that’s exactly what i expected, but wanted to ask
> experts first.
>
> Well, given that now i am a TW user, & as such my PCs will be getting
> major system upgrades / replacements -much- more often than they ever
> have in their non-openSUSE TW histories, PLUS in July/August in my part
> of the world strong winds occur, PLUS consequential blackouts are not
> uncommon now during said winds [trees blown into powerlines, i suspect],
> i believe that makes me now statistically more likely than ever before
> to potentially experience a future blackout at just the critically wrong
> time. Thus, i’m now wondering if maybe this might be the time to begin
> researching a possible domestic UPS, as a safeguard.

Given the cost of a UPS with something on the order of 1kw battery
capacity, I have always considered one a part of the necessary items for
all my desktop locations. A couple of churches I ‘baby sit’ found small
UPS units for under $50 that will keep 2-3 desktops running for 25-30
minutes. That covers the majority of situations and I generally see the
UPS batteries lasting 5-7 years so the cost is fairly painless.

Interesting - thank you.

I don’t recommend trying it. However, in most cases you would probably be okay.

Typically, unless you are short of disk space, “zypper” first downloads all of the rpms. And then it installs them.

After power returns, the trick is to rerun the “zypper” command. It will recognize packages that have already been downloaded, and won’t retrieve them again. If it installed some packages, then it won’t reinstall those (unless there is some special need).

What could go wrong:

Worst is when the system is left in a state where zypper won’t run. I had that happen once. Another possibility is that the power went out while it was running scripts after the install. And it might not know where it left off. It might just see that packages are all installed, and not run any scripts.

The case where zypper wont run: This happened a few years ago. Part way through the install, it restarted Xorg, which crashed the terminal session that I was in and cut off the update. And “zypper” had been updated, but the matching update to “libzypp” had not been installed. So “zypper” refused to run. This happened to several people at that time.

I managed to recover. I booted the live rescue USB, and mounted everything at “/mnt”. Then, from the top level of the rescue system, I ran

zypper -R /mnt

This applies zypper to the presumed root directory given after “-R”. So I was using the working “zypper” on the rescue USB to update the broken system. It worked pretty well.

Haha, well i can assure you that i don’t ever want to [have to] experience this problem.

OMZ - that’s amazing! The big difference is that you clearly knew what to do, whereas i wouldn’t have a clue. If this doomsday scenario actually did ever happen to me, my only advantage would be that because i have a 2nd pc, i could at least still get online & into these fora to beg for help. I never ever update both pc’s simultaneously, as a precaution.

Thank you for your interesting reply.

So do not overwrite them. Clone current system, update clone, sync, switch to clone for next boot. At any point you have either old consistent system or new consistent system.

Of course most people will scream when suggested they need to reboot every time to “activate” updates. But you can’t please 'em all - convenience always conflicts with reliability.

wait… is it likely that even is OS wont run then booting from snapshot would?

Two options when the root filesystem is other than btrfs:

  • System boots? Run ‘zypper dup’ again
  • System doesn’t boot? Boot from an install USB medium, open a virtual terminal and chroot to the installed system, run ‘zypper dup’.
    Had to use the last option once when the new cleaner pulled the plug while the system was updatiing.

Oh noooooooooooo, that’s terrible [but also kinda funny!]. :open_mouth: