Gentoo Live 32 to 64 migration as clean as possible:
This is my method - letting portage track every file and package except glibc and ld-linux.so.2 loader. System and all services can remain running. If this is done correctly only 2 reboots will be required.
cd /usr git clone https://github.com/gentoo/gentoo.git ./gentoo-git cd gentoo-git git checkout `git rev-list -n 1 --first-parent --before="2020-09-01" master` #note backticks
mkdir /migration-backup cp /etc/portage/make.conf /migration-backup/
emerge crossdev -av
crossdev -S -s3 --target x86_64-pc-linux-gnu
genkernel all
env-update source /etc/profile ldconfig
mkdir /lib32 (not if donor VM profile is 17.1 and onwards which uses lib and lib64 with no symlink) mkdir /lib64 mkdir /usr/lib32 (not if donor VM profile is 17.1 and onwards which uses lib and lib64 with no symlink) mkdir /usr/lib64
rm -Rf /usr/lib/distcc
cp -ar /usr/x86_64-pc-linux-gnu /migration-backup/usr/ cp -ar /usr/i686-pc-linux-gnu /migration-backup/usr/ cp -ar /usr/libexec /migration-backup/usr/ cp -ar /usr/include /migration-backup/usr
# cat /etc/portage/profile/use.mask -abi_x86_32
quickpkg glibc gcc zlib ncurses gmp mpfr util-linux acl attr sandbox coreutils procps binutils libcap libxcrypt mpc cracklib flex =db-5* glib pam pambase =python-3* bash readline findutils install-xattr bzip2 tar xz-utils make grep patch gawk sed libpcre dev-libs/libffi gettext libxml2
mv /lib oldlib ln -s lib64 lib (not on 17.1 - mkdir lib) cd /usr mv lib to oldlib ln -s lib64 lib (not on 17.1 - mkdir lib)
cp migration-backup/lib/ld-linux.so.2 /lib ldconfig
cd /usr/oldlib mv python-exec python3.6 libpython* portage gcc ../lib/ cp -r /oldlib/gentoo /lib/
LD_PRELOAD="/migration-backup/usr/lib/gcc/i686-pc-linux-gnu/10.3.0/libgcc_s.so.1:/migration-backup/usr/lib/libffi.so.7" PATH="/migration-backup/bin:/migration-backup/usr/bin:/migration-backup/sbin:/migration-backup/usr/sbin:${PATH}" FEATURES="-collision-detect -protect-owned" emerge -1kav sys-devel/gcc
/usr/bin/cal /bin/date /usr/bin/env /usr/bin/free /bin/ls /usr/bin/uname /usr/bin/uptime
These can be restored from these binary packages immediately after getting glibc working:
emerge -1kav util-linux coreutils procps
To emerge coreutils, working mv command is required. libattr.so.1 and libacl.so.1 (symlinks.. copy the actual libraries) were copied over from donor VM lib64 directories and appropriate symlinks made. These belong to packages acl and attr binary packages which can then be emerged to account for those files.
PKGDIR=/var/cache/binpkgs emerge -1kav sys-devel/gcc mpfr mpc binutils gcc-config 1 binutils-config 1 . /etc/profile
PKGDIR=/var/cache/binpkgs emerge -1kav glibc
Double check /etc/nsswitch.conf and other files backed up above, this may have overwritten them again.
mv /migration-backup/lib/modules /lib64
(or to /lib if 17.1 profile)
emerge gcc -1av
FEATURES="-sandbox -usersandbox" USE="-X -gtk -qt5 -introspection -cairo -gpm -consolekit -policykit -net -ipv6 -spell -sqlite -nls -berkdb -gdbm -openssl" emerge -1eav @system
emerge -eav –keep-going @world
emerge -1av /lib32 /usr/lib32
cd /lib32 ; find -xdev -type f -exec qfile -o {} + |less