Migrating Between Architectures Without Reinstalling
From ArchWiki
A question often asked is how to upgrade from 32 bit to 64 bit without having to reinstall the entire system. This page documents various potential methods.
Contents |
Preparation
Confirm CPU architecture
In order to run 64 bit software, you must have a 64 bit capable CPU. Most modern CPUs are capable of running 64 bit software. You may check your CPU with the following command:
cat /proc/cpuinfo | grep --color lm
If your CPU supports x86_64, it will return the letters lm highlighted.
Prepare disk space
You should allow for and be prepared for /var/cache/pacman/pkg to grow approximately twice its current size on your system during this process. This is due to package duplication between i686 and x86_64 versions of the same packages. Please do not remove any i686 packages until you are fully operational on your new x86_64 system. Removing the i686 packages too early may leave you unable to fallback and revert changes.
Environment considerations
This process may take a substantial amount of time. You should plan on at least an hour or more dependent on the number and size of your installed packages and current internet connection speed. Please make sure you are connected to a stable power source, preferably with some sort of failover or battery backup.
Prepare fallback environment
# pacman -S busybox
If the upgrade process fails, we can revert our changes, with BusyBox.
Method 1: Utilising the Arch LiveCD
- Download, burn and boot the 64-bit Arch ISO LiveCD
- Configure your network on the LiveCD, then pacman to use 64-bit repos
- Mount your existing installation to /mnt directory. For example: mount /dev/sda1 /mnt
- Use the following script to update the local pacman database, get a list of all your installed packages and then reinstall them:
#!/bin/bash MOUNTED_INSTALL='/mnt' TEMP_FILE='/tmp/packages.list' pacman --root $MOUNTED_INSTALL -Sy pacman --root $MOUNTED_INSTALL -Qqet > $TEMP_FILE for PKG in $(cat $TEMP_FILE) ; do pacman --root $MOUNTED_INSTALL -S $PKG --noconfirm done exit 0
Method 2: From a running system
Download packages
- Download all of our currently installed i686 packages for fallback purposes.
# pacman -Sw $(pacman -Qq)
- Edit the mirrorlist file and change all occurrences of i686 to x86_64.
# sed -i -e s/i686/x86_64/g /etc/pacman.d/mirrorlist
- Flush the current i686 repository cache and re-sync with x86_64 using our modified mirrorlist:
# rm -rf /var/lib/pacman/sync/* # flush existing repository cache # pacman -Sy # sync x86_64 packages
- Download the x86_64 flavor of all our currently installed i686 packages:
# pacman -Sw $(pacman -Qq) # download x86_64 package versions
If you have any packages installed from the AUR or third-party repositories without x86_64 availability, pacman will let you know it cannot find a suitable replacement. Make a list of these packages so you may re-install them after the update process and then remove them using pacman -Rsn package_name.
Open a root tty
This is the time to switch to a true root tty for the rest of the process. You should be fine using a terminal emulator like SSH but it is not advised. There will be several packages removed and replaced during the update process that may cause X11 desktops to become unstable leaving your system in an unbootable state.
Upgrade
Upgrade the kernel
Upgrading the kernel is safe and straightforward: 64 bit programs must be run with a 64 bit kernel while 32 bit and 64 bit applications both run equally well under a 64 bit kernel.
To install the standard Arch Linux x86_64 kernel, use the following command:
$ pacman -S kernel26
We already changed our mirrorlist so pacman will automatically download and install x86_64 packages without any special instructions.
Once the kernel update is done reboot your system and check the kernel architecture. If all went well you are now running a 64 bit kernel.
x86_64
Prepare fallback library
You may safely skip this step. It is only necessary when something does not go as planned after the update process has begun. Should such an event take place you can run 32 bit programs by explicitly calling /lib/ld-linux-x86-32.so.2. However we already have a statically linked BusyBox installed for this same purpose.
# pacman -S lib32-glibc
Upgrade pacman
# pacman -S pacman glibc libfetch libarchive openssl acl attr xz-utils bzip2 zlib readline bash ncurses expat
Immediately following this command only BusyBox, Bash and pacman will be executable on your system until the x86_64 replacements are installed below. You must not reboot your system until the following commands have been completed. You have been warned.
Upgrade the whole system
Install all of our previously downloaded x86_64 replacements. (Go get a drink and make a sandwich ... this could take awhile.)
# pacman -S $(pacman -Qq)
You now have a fully functional x86_64 bit system.
Cleanup
You are now free to remove busybox and lib32-glibc.
# pacman -Rcn busybox lib32-glibc
Troubleshooting
During the upgrade, when glibc is replaced by the 64 bit version, many programs can't run. If problems occur, you can solve them with busybox or lib32-glibc.
Using BusyBox
In Arch, BusyBox is statically linked; it can run above the kernel without any other libraries. There are many commands available to you. For example, extract 64 bit pacman from cached package:
# busybox zcat /var/cache/pacman/pkg/pacman-3.3.2-1-i686.pkg.tar.gz | busybox tar xf - -C /
Using lib32-glibc
Example run 32 bit /bin/ls:
# /lib/ld-linux-x86-32.so.2 /bin/ls
Be sure to upgrade compiler flags
During the upgrade the x86_64 version of /etc/makepkg.conf may be stored as /etc/makepkg.conf.pacnew. You will have to replace the old version or modify it, if you want to compile anything with makepkg in the future.
# cp /etc/makepkg.conf /etc/makepkg.conf.backup_i686 && cp /etc/makepkg.conf.pacnew /etc/makepkg.conf
It might also be a good idea to just get a list of "new" additions to /etc. You can get a list with the following command:
# find /etc/ -type f -name \*.pac\*
Most problems can be resolved with one or more of the above tips. Good luck!