My system upgrade procedure for Gentoo Linux
March 7, 2020 Leave a comment
Gentoo Linux is a so-called ‘rolling-release’ distribution, and each Gentoo Linux user has their own preferred sequence of steps for keeping their installation up-to-date. Below is the general procedure I use for system maintenance of my Gentoo installations, which I perform approximately weekly.
1. Update the ebuilds on the machine (see Gentoo Wiki – Project:Portage/Sync)
root # emaint sync -a
If I were using the deprecated Portage sync method I would instead have used the following commands:
root # emerge --sync # Update the ebuilds from the main Portage tree
root # layman -S # Update the ebuilds from 3rd-party overlays
2. Upgrade the Portage package manager if the console output from Step 1 included a message telling me to upgrade portage
root # emerge -1v portage
3. As I use the eix
and the mlocate
utilities, update their data files
root # eix-update && updatedb
4. Check if there are any News items I have not read yet
root # eselect news list
5. Read new News items and make necessary changes, if any
root # eselect news read <n>
6. Perform a dry run for the upgrade of any packages in the World file that have new versions
root # emerge -uvpDN --with-bdeps=y @world
7. If no problems were flagged in Step 6, go to Step 9
8. Sort out any problem(s) flagged in Step 6 then go back to Step 6
9. Launch the upgrade of those packages in the World file that have new versions
root # emerge -uvDN --with-bdeps=y --keep-going @world
My decision on whether or not to include the option ‘--keep-going
‘ will depend on the precise circumstances.
10. If Step 9 ran to completion successfully, go to Step 14
11. If Step 9 did not run to completion successfully and it appears the package that failed to merge will not cause further problems, go to Step 12, otherwise fix the problem(s)* and go back to Step 9
*Sometimes I find that one or more packages do not merge successfully during Step 9 but do merge successfully simply by repeating Step 9.
12. Resume the upgrade process
root # emerge --resume --skipfirst
13. If Step 12 did not run to completion successfully and it appears the package that failed to merge will not cause further problems, go back to Step 12, otherwise fix the problem(s) and go back to Step 9
14. Upgrade any packages that are still built against old versions of libraries if the console output from Step 9 or Step 12 includes a message telling me to do that
root # emerge @preserved-rebuild
15. If any problems remain, fix them and go back to Step 14
16. Scan libraries and binaries for missing shared library dependencies and re-merge any broken binaries and shared libraries
root # revdep-rebuild -i
Actually, I cannot recall the last time ‘revdep-rebuild
‘ was needed, as Portage has improved so much over the years.
17. Remove outdated and unneeded packages
root # emerge --ask --depclean
18. Merge any configuration files
root # etc-update
I always check the differences between the listed existing and new configuration files before going ahead, and may edit the new configuration file if I deem it necessary.
19. As I use the mlocate
utility I make sure its index file is bang up to date
root # updatedb
20. Optionally, I clear out any old source-code and binary packages
root # eclean-dist --deep
21. If I remember to do it, I check if there are any installed obsolete packages and then remove them
root # eix-test-obsolete
22. I make sure no temporary work files have been left around by any failed merges
root # rm -rf /usr/tmp/portage/*
Actually, I created a script in directory /etc/local.d/
to do this automatically when HDD free space gets low (see my blog post ‘Automatically clearing the /usr/tmp/portage directory in Gentoo Linux‘).
23. I wait for at least 24 hours (usually about a week) and then go to Step 1
Notes
Actually, I have added the option ‘--with-bdeps=y
‘ to EMERGE_DEFAULT_OPS
in the file /etc/portage/make.conf
so I do not need to type that option every time.
One of my laptops has an older Core i7 CPU and I initially added ‘--jobs=8 --load-average=8
‘ to EMERGE_DEFAULT_OPTS
in order to merge packages in parallel, which speeds up upgrading. However, I found this slowed interactive use of the machine and therefore I changed the options to ‘--jobs=6 --load-average=6
‘ which works a bit better on that machine.
In order to prevent the number of log files increasing indefinitely, I added ‘clean-logs
‘ to FEATURES
in the file /etc/portage/make.conf
so that log files older than seven days are deleted automatically.