This page looks best with JavaScript enabled

Updating a really old Gentoo system.

 ·  🎃 kr0m

Updating an old Gentoo system can become a real odyssey. In this tutorial, we will explain how to do it on a system that has not been updated since March 30, 2017. Gentoo provides mechanisms and functionalities clearly superior to the rest of Linux distributions. Thanks to these functionalities, we can use a chroot from which to compile ebuilds for the parent system.

First of all, if it is a physical server, we will convert it to CT with the lxd-p2c tool as we explained in this previous article. This way, we can take snapshots and all the tests we want without worrying about breaking the system or interrupting the service. When we have the updated CT, we just have to perform the same steps on the physical server or turn off the original server and leave the CT with the IP of the physical server.

To make Gentoo work correctly within LXD, we must modify a devfs script, removing the ‘-’ from lxc:

vi /etc/init.d/devfs

keyword -docker lxc -prefix -systemd-nspawn -vserver

To update successfully, we must take into account the importance of profiles in Gentoo. When a release includes new functionalities, provides a set of core packages or parameters that modify the system’s operation, a new profile is provided.

A profile is a set of configuration files. The profiles are stored in the /var/db/repos/gentoo/profiles directory. They describe aspects such as the ebuilds that are considered part of the base system, the default USE flags, the mapping of virtual packages, and the architecture in which the system is running.
NOTE: Before making any profile changes, make sure that you have updated the operating system to the maximum before making the change.

The system in question is quite old and has not been updated since:

Last emerge --sync was Thu 30 Mar 2017 23:05:01 CEST.

The first step will be to remove all ebuilds that are not of vital importance. This way, we will avoid problems when compiling:

emerge –unmerge EBUILD_NAME

We also remove possible overlays configured in make.conf.
We create a chroot where we will have current tools with which to compile and update the conflicting ebuilds of the parent:

mkdir -p /mnt/build
wget http://distfiles.gentoo.org/releases/amd64/autobuilds/20190825T214502Z/stage3-amd64-20190825T214502Z.tar.xz
tar -xf stage3-amd64-20190825T214502Z.tar.xz -C /mnt/build
mount –rbind /dev /mnt/build/dev
mount –rbind /proc /mnt/build/proc
mount –rbind /sys /mnt/build/sys
mkdir -p /mnt/build/mnt/host
mount –rbind / /mnt/build/mnt/host
cp -L /etc/resolv.conf /mnt/build/etc/
chroot /mnt/build
source /etc/profile
export PS1="(chroot) ${PS1}"
emerge –sync

We select the same profile as the parent host:

eselect profile list

Available profile symlink targets:
 [1] default/linux/amd64/17.0 (stable) *

Now we update the parent’s portage from the chroot:

ROOT="/mnt/host" emerge –verbose –oneshot –nodeps sys-apps/portage

In another console, we continue to update the system regularly. If any package causes problems, we go back to the chroot console and update that package.

emerge -uDav world
emerge --depclean
revdep-rebuild
etc-update
gcc-config -l
perl-cleaner --all
eselect kernel list -> Only if it is a physical machine

Of course, we will read the messages that appear on the console. This is very important.

When we have the system updated, we can change the profile and continue updating until we have a fully functional system with the latest updated software versions.

Each profile has a migration process, in this case it is version 17.1, we follow the steps before changing the profile:
https://www.gentoo.org/support/news-items/2019-06-05-amd64-17-1-profiles-are-now-stable.html

emerge -1v app-portage/unsymlink-lib
unsymlink-lib --analyze
unsymlink-lib --migrate --pretend
unsymlink-lib --migrate
reboot

If it restarts correctly, we finish the migration with:

unsymlink-lib --finish

Otherwise, we revert the changes with:

unsymlink-lib --rollback

We finish the migration:

vi /etc/make.conf

SYMLINK_LIB=no
LIBDIR_x86=lib
emerge -1v /usr/lib/gcc /lib32 /usr/lib32

We are now ready to move on to the next profile:

eselect profile list
eselect profile set X

We recompile gcc:

emerge -1v sys-devel/gcc
emerge -1v --deep /lib32 /usr/lib32 /usr/lib/llvm/*/lib32

The update should have removed the /lib32 /usr/lib32 symlinks, if they still exist, we remove them manually:

ls -la /lib32
ls -la /usr/lib32
rm /lib32 /usr/lib32

We make sure that there is nothing left to update:

emerge --sync
emerge -uDav world
emerge --depclean
revdep-rebuild
etc-update
gcc-config -l
perl-cleaner --all
eselect kernel list -> Only if it is a physical machine

The syntax of the configuration files for some software may have changed, we will have to adapt it to work with the new version.

For each software, we will follow the relevant guide, for Apache for example:
https://httpd.apache.org/docs/current/upgrading.html
http://httpd.apache.org/docs/2.4/mod/core.html#options

Some Glibc errors that have appeared are:

 * Your //etc/nsswitch.conf is out of date.
 * Please make sure you have 'files' entries for
 * 'passwd:', 'group:' and 'shadow:' databases.

https://wiki.gentoo.org/wiki/Glibc_2.26_porting_notes/nsswitch.conf_in_glibc-2.26

sed ’s/\<compat\>/files compat/g’ /etc/nsswitch.conf

Another error has been the following related to the compiler:

configure: error:
*** These critical programs are missing or too old: compiler
*** Check the INSTALL file for required versions.
 * ERROR: sys-libs/glibc-2.29-r2::gentoo failed (configure phase):
 * failed to configure glibc
gcc-config -l
 [1] x86_64-pc-linux-gnu-4.9.3 *
 [2] x86_64-pc-linux-gnu-8.3.0
gcc-config 2
. /etc/profile

Finally, we clean the Python environment:

eselect python cleanup

And we have our Gentoo fully updated ;)

If you liked the article, you can treat me to a RedBull here