Tip: Do snapshot upgrades and system upgrades in a tty

It prevents your desktop from crashing and leaving your system unusable or unbootable. This especially applies to ext4 users who dislike or can’t use btrfs for some reason.

I was updating my system yesterday when the kde desktop suddenly crashed and restarted. The update seemed to be successful, but booting the 6.4.12 kernel was unsucessful. Thinking the kernel was broken, i rolled back, downloaded the updates using sudo zypper dup -d, then switched to a tty and did sudo zypper dup.

Don’t be like me :rofl:

Can we assume this was in Tumbleweed. You do not explain much about your setup.

Both Tumbleweed and Leap.

For me I found tmux to work as well. You may be kicked out the graphical environment but the session with zypper stays active.

2 Likes

I’m probably living dangerously, I’ve been doing zypper dup in a konsole without taking any precautions and have never had an issue. This would be on tumbleweed for about 5 years, Leap/SUSE for decades (earlier it was always via yast).

I suppose one’s luck may depend on the hardware mix and whether you run any power management: I’ve only run desktops, no laptops, no power management/suspend, except for DPMS, and Nvidia for the at least the last couple of decades. I also don’t user btrfs or snapshots (but do keep backups based on rsync to online and offline storage).

But good advice, I should probably use tmux or screen, it’s not like it costs much effort. It’s never happened during a dup, but on quite rare occasions, X11 applications have locked up the mouse, so there’s that to consider.

zypper dist-upgrade in the system slice

systemd manages processes in distinct groups, a system slice and user slices. Duping in the user slice is a bad idea. Running it in the system slice is robust and unobtrusive. This service replaces PackageKit which is removed from Tumbleweed on infamous host erlangen and its numerous siblings:

erlangen:~ # systemctl cat dup
# /etc/systemd/system/dup.service
[Unit]
Description=zypper dist-upgrade 
After=purge-kernels.service 

[Service]
ExecStartPre=/usr/bin/nm-online
ExecStart=/usr/bin/zypper --non-interactive dist-upgrade

# /etc/systemd/system/service.d/toplevel-override.conf
[Unit]
OnFailure=failure-notification@%n
erlangen:~ # 

Notifications are sent upon failure: systemd - ArchWiki

This timer triggers daily upgrades:

erlangen:~ # systemctl cat dup.timer 
# /etc/systemd/system/dup.timer
[Unit]
Description=zypper dist-upgrade

[Timer]
OnCalendar=daily
Persistent=true

[Install]
WantedBy=timers.target
erlangen:~ # 

Schedule:

erlangen:~ # systemctl list-timers dup
NEXT                         LEFT     LAST                         PASSED       UNIT      ACTIVATES  
Mon 2023-09-11 00:00:00 CEST 18h left Sun 2023-09-10 05:20:35  CEST 52min ago dup.timer dup.service

1 timers listed.
Pass --all to see loaded but inactive timers, too.
erlangen:~ # 

At midnight erlangen was suspended to RAM. The persistent timer started today’s upgrade upon wake from sleep:

erlangen:~ # journalctl --since 0:00 -u dup.service -g 'Starting|following|conflicts|Consumed'
Sep 10 05:20:35 erlangen systemd[1]: Starting zypper dist-upgrade...
Sep 10 05:20:36 erlangen zypper[5310]: The following 56 packages are going to be upgraded:
Sep 10 05:20:36 erlangen zypper[5310]: The following product is going to be upgraded:
Sep 10 05:20:36 erlangen zypper[5310]: The following 3 NEW packages are going to be installed:
Sep 10 05:20:38 erlangen zypper[5310]: Checking for file conflicts: [.....done]
Sep 10 05:21:00 erlangen systemd[1]: dup.service: Consumed 20.849s CPU time.
erlangen:~ #