Replace a Linux installation with Gentoo in-place

This document gives an idea of the steps that need to be taken to replace a running linux system with Gentoo. Based on Jordan Ritter's article on replacing RHEL9 with Gentoo.

Prepare the system
We're going to need bzip2 for the stage3.

We're also about to overwrite fstab, so save it to /tmp.

Mark all present files as if they were modified at the beginning of time (which was in 1970) so that we can remove them later on. Modprobe is temporarily removed as it might potentially slow down this proccess.

Overwrite root with Gentoo
Extract the latest stage3 tarball over the current system.

Gentoo's /lib and /usr/lib are symlinks and tar if tar warned you about this, you need to fix them.

Recover fstab from /tmp as it has been overwritten by tar. You can also copy it from /etc/mtab.

Bring the Gentoo system to a bootable state
You will want to be able to log in to your new system even if network/sshd fails, so set a root password.

Enable your network interfaces.

Prevent any network device renaming surprises.

Fetch dhcpcd if you're going to be using DHCP. Otherwise, set up your interfaces manually.

Set the timezone.

Enable sshd for remote access

Feel free to test the system and finally reboot. You might have to use -f.

Remove anything that was left behind by the previous OS
If everything is now working as expected, go ahead and delete all the old files. /home and /root are spared.