Manjaro: Applying Updates while shutting down the system

I really like Manjaro. The combination of always up-to-date software packages and the high stability, thanks to the Manjaro team (especially Philip Müller), really ensure a stress-free workflow.

I use the stable channel (that’s the default) and am still happy to get very fresh packages (latest and stable). With very few exceptions, there are problems but these are minor. I can also confirm those issues have been decreasing lately.

Meanwhile, I have recommended it to other people and they also are using it.

The big advantage of Manjaro’s updates is that they are applied in small increments. So there is not really a distinction between updates (small security patches) and upgrades (major changes). Talking about ongoing updates; Unlike Windows or distros such as Ubuntu, where both terms are kept apart and the upgrades are jumps with added pain.

But Manjaro has a disadvantage that always strikes. You can work with the system, run the updates (when else should you do it?), but the system changes in the background and the user notes that at one point or another. This of course leads to an experience that is not nice.

However, with Manjaro, major updates are incorporated in less time. This can be annoying for a normal user.

So why not keep the updates running while system is shutting down? It has two advantages:

1.- The user does not have to worry about updates all the time.

2.- Since the updates do not run in the background, but only at the shutdown process, the user does not have to tackle messed up situations.

By the way, distros like Fedora and Ubuntu do it, but with certain bigger updates. The computer is subsequently booted up, updates are applied and shut down immediately.

Here’s how to extend this functionality in Manjaro. It should be noted that this process has often been criticized by the Manjaro community. The expectation is to always take time for the updates and also to read news about the packages (Similar to Arch Linux). But I can understand that some people do not want to do that. I’ve been using Manjaro for over three years and believe these automatic shutdown updates are not a problem. I’ve never broken my system with Manjaro updates.

However, it is not excluded that something would go wrong. Therefore I recommend a snapshot backup with timeshift, so you can quickly restore an old state in cases of failure.

Thanks to Systemd (installed by default) this is not a big problem. Under the directory /usr/lib/systemd/system-shutdown/ a script can be created, which executes the updates automatically. All we have to do is make sure that the package manager Pacman runs.

sudo nano /usr/lib/systemd/system/unattendedUpdates.service

Now we fill the file with content like this:

[Unit]
Description=Unattended Updates

[Service]
ExecStop=/usr/bin/pacman -Syuq --noconfirm
RemainAfterExit=yes
TimeoutStopSec=7200
KillMode=process
Killsignal=SIGINT


[Install]
WantedBy=multi-user.target

Save (with ctrl + o, ctrl + x) and activate it in systemd:

sudo systemctl daemon-reload
sudo systemctl start unattendedUpdates
sudo systemctl enable unattendedUpdates  

By the way: The value 7200 corresponds in seconds to the maximum time given to the updater. In that case, the process will take a maximum of 2 hours. This is a lot of time. On my system, larger updates take about 10 minutes (with SATA SSD). Such process should not take longer. With that strategy if the updater stalls for some reason, the machine still gets to shut down.

Now all updates (except AUR) should be applied at shutdown. Good luck!

Das könnte dich auch interessieren …

2 Antworten

  1. Dietrich sagt:

    Does not work. „journalctl -u unattendedUpdates.service“ shows repeated errors regarding host name resolution. I assume DNS or the network connection is already dead, when this script runs?

    • gerstrong sagt:

      I have not tested this with wifi connections, maybe that is the reason. On LAN with a locally connected PC it works. Maybe you can make one of your connections permanent to all users.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert