How to migrate your Gentoo system from an AMD chip to an Intel chip (or vice versa)

menguin

Geek
Pinoy Techie
Q: Why would anyone sane want to do this - wouldn't it just be easier to simply reinstall Gentoo?
A: For the lulz. But also - what if you don't feel like migrating a ton of personal data around.

First of all make sure you have your system entirely up to date: ~$ emerge --ask --update --deep --newuse --with-bdeps=y --keep-going @world @system

Once that is done building you need to reconfigure your kernel to include at a minimum drivers for your new disk controller and a CPU scheduler for your new chip, it might be nice to also adjust the CPU type to reflect your new hardware and to include any networking drivers you might need too.

Now we need to prep the system. First we need to create a set out of all your currently installed packages since we are likely going to clobber world later on (I'd very much appreciate anyone updating this to include a non-world clobbering solution but for now this is the best I could come up with) I will use eix here since it is a popular Portage tree indexing tool that most Gentooers have installed:
~$ eix-installed -q all > installed.txt

This isn't exactly what we want so we'll run this gem to finish it off by prefixing each line with an equals sign: ~$ sed -e 's/^/=/' installed.txt > myset
~$ rm installed.txt # clean up
~$ cp -a myset /etc/portage/sets/ # place the file where Portage will look for it

Now backup /etc like so:
~$ cd /
~$ tar cjpf etc-`date +%F`.tar.bz2 /etc

At this point you need to have a live CD handy - install your new hardware and then boot off the live CD and continue on. >Mount your file systems as if you were preparing for a basic stage3 install (consult the Handbook if you need a refresher) and download the current stage3 tarballs only, don't bother with the Portage tarball.

Extract the stage3 tarball over your system and chroot in (this is why we backed up /etc earlier)

Extract our original /etc back into our system: ~$ tar xjpvf etc-`date +%F`.tar.bz2

Double check your CFLAGS and then rebuild system, this will rebuild our core tool chain and other development tools - technically not completly necessary since we got (all?) the generic binaries for this set from the stage3 tarball: emerge --ask --oneshot --keep-going @system

Once that finishes we need to rebuild our original world, which was clobbered by extracting the new stage3 tarball but that we saved in myset. If your system was anything like mine, this will have included over 1000 packages and so you might want to plan this as an overnight build: ~$ emerge --ask --oneshot --keep-going @myset

This last part is pretty ugly - any programs you want included in your world file you'll need to readd manually. Fortunately you already compiled them, this will literally just add the package to your world file:
~$ emerge --noreplace app-editors/vim

# on second though - I could have probably just backed up the original world file and just copied that over but hey it was late at night and my system was broken - I just untarred the stage3 tarball and got to work!
 
Top Bottom