linux-aarhus | 2022-10-07 09:16:16 UTC | Source: Update Manjaro the smart way
Either when you use your system or shortly after login - a message appears - telling you there is updates available. When you click the message Pamac opens with the updates pane listing 100's of packages ready to download/install on your system.
Almost per instinct you click the update now - provide your password and the flow begin.
Suddenly your screen goes blank - you wait - nothing happens.
You press CtrlAltF4 to access TTY - nothing happens - you wait - nothing happens.
Without giving much thought to it - you hold the power button until the system powers off and press it again to power on your system - and now you are having a black screen maybe a message .... unless your system is not booting at all !
What now? Could the situation have been avoided?
While - of course - there is no guarantee - the following headlines may help you understand what goes on behind the scenes.
There is a few packages - which when updated most likely will require a restart. A short list of important system packages which probably requires restart
Another part of knowing your system is which foreign packages you have installed. Foreign packages is defined as everything not in the official repository so keeping a list of packages installed by an AUR helper or using
makepkg -i will be of help when you update your system.
Before you update - you can query pacman for the list - pipe it to a text file for later referral
$ pacman -Qm > ~/aur-pkglist.txt && xdg-open aur-pkglist.txt
The way pacman works - using the alpm library - is to download the packages and verify by signatures - and when a package validation fail - the transaction will be not committed.
This ensures no updates are written to the system if the internet connects is severed as the update will be cancelled unless all packages required is available in the local package cache.
A part of knowing your system is to understand how the alpm library applies the updates.
Many packages - especially system packages - makes use of hooks to process changes during an update.
If a package update is not fully completed - eg. your system loses power during update - the post-update hooks are not executed - and bad things can happen - what actually happens depends on the package and the hooks implemented.
Most of us has been using Windows and we know from Windows that system files may be locked so the system must be restarted so the file can be replaced with the updated versions.
Due to the modularity of Linux only needed parts of an application is loaded into memory and the rest is loaded on as-needed-basis - and this includes kernel, kernel modules and drivers.
When you build a custom package using an AUR helper, the package is built using the - at build time - available system libraries.
When you update your system - you may be replacing those dependencies with new libraries - and such replacement may cause instability or outright failure of your custom package - especially when your custom packages depends on a specific kernel release.
When you reboot your system after an update the system will use new modules and any application or device relying on a custom kernel module will fail because the module has not been rebuilt.
Only after a successful update and a successful restart you can begin to update your custom modules.
Themes is not only a bunch of color definitions and icons.
This makes applications prone to errors when themes are not maintained to match the next release of the tool kit.
Such maintenance may appear tedious but nonetheless - a non maintained theme may break the system - most notably the display manager most notably gdm for Gnome and sddm for Plasma but also toolbars, extensions and plasmoids may exhibit erratic behavior.
The following is a simplified description - of what may happen.
When you run huge updates within the graphical environment - whether you use a terminal or a gui package manager - the system may end in a state where it needs to load a specific library at a specific memory address pointing at a specific routine in the library - but due to updates - the library is no longer existing - it has been updated to a never version - and your update stalls.
Before major updates, it is wise to - temporarily
Updating the smart way includes knowing which packages may pose a problem if the update is run with the GUI. I showed you a list of packages which by a lot of users experience often requires special attention.
When Pamac shows you a huge list of update - it can be hard to get a clear view and you could miss one.
You can use a small utility script simplifying the task of evaluating a huge list of updates.
When you have evaluated the list and found this update to have the potential to stall - the smart way is to update using the console. Logout of your GUI and switch to TTY.
Don't ever interrupt the process - intentionally or unintentionally.
Ensure you are not doing your update when your area are known to power spike, or during stormy weather which can cause interruptions to the power grid - if your system loses power you will probably have a problem getting it back up and runnning.
Before syncronizing your system optionally ensure your primary mirror is up-to-date
$ pacman-mirrors Pacman-mirrors version 4.16.4 Local mirror status for unstable branch Mirror #1 OK 00:31 Denmark https://www.uex.dk/public/manjaro/
If you don't regularly clean up you system - now is a good time
Remove old entries from the journal (reduce the size to 50M)
$ sudo journalctl --vacuum-size=50M
Cleanup your pacman cache (this will remove uninstalled packages and reduce pkg versions to the installed version)
$ sudo paccache -ruk0
Logout of your GUI and switch to TTY- CtrlAltF4 and run the update. Depending on the result you may proceed to update the system
If you are using dkms based drivers - ensure they are rebuild without errors.
$ sudo pacman -Syu
If you need to rebuild your mirror list - you will need to use below variation of the update command - forcing your system package database to equal your primary mirror's databases and as pointed to by @cscs Pamac has a timer - rebuilding your mirror list on a regular base - in which case this command should be favored.
$ sudo pacman -Syyu
When you reboot after a successful update - first thing to do is rebuilding your foreign packages and drivers. This can be done from a terminal in the GUI session - but if you want to ensure you get no problems - TTY is recommended CtrlAltF4.
Depending on your environment, you switch back to GUI using CtrlAltF7 or if your displaymanager is SDDM CtrlAltF1
Rebuilding all your AUR packages using a single command e.g.
$ pamac upgrade -a
Reapply your custom theming and give yourself a :clap: - you deserve it.
Following a few basic rules will help you keep your system healthy and hopefully you will avoid problems from a stalled update.