1. Introduction
This HowTo converts a working 32 bit installation into a 64 bit system. You keep all programs, settings and data. You start with a 32 bit system that can run 64 bit programs, and finish with a 64 bit system that can run 32 bit programs. We firstly demonstrate an upgrade from 6.0 Squeeze 32 bit to 7 Wheezy because Debian 7 is a pre-requisite.
With the recent release of Debian GNU/Linux 7.0 Wheezy, a new feature called multiarch has been introduced. The facility permits the installation of executable files (such as libraries and programs) from multiple architectures simultaneously on the same system. The primary use of this is to allow 32 bit programs to be run on a 64 bit system, but there are more interesting possibilities. We can turn this on its head, allowing 64 bit programs to run on a 32 bit system, then ultimately replace all 32 bit programs with their 64 bit equivalents. No other operating system can provide this flexible feature.
Read this guide through in its entirety before starting, and keep plenty of tested backups to hand. Run these steps in an ssh session or on the console.
Updated 2013-09-30: This HowTo has been significantly simplified and no longer unpacks packages manually.
2. Debian 6.0 32 bit installation
Download the ISO file image, burn it to CD, then start the installation.
wget http://cdimage.debian.org/debian-cd/6.0.7-live/i386/iso-hybrid/debian-live-6.0.7-i386-standard.iso
Install some extra packages as you see fit, e.g. openssh-server and gnome-desktop-environment. I have performed the installation on a spare machine with 6G of RAM and a 10G disk. I utilised LVM and used the whole hard disk for Debian.
3. Debian 7 32 bit upgrade
Now upgrade from Squeeze to Wheezy as we need to have the new Debian 7 release in order to change the architecture (i.e. change from 32 bit to 64 bit later on).
sed -i -e"s/squeeze/wheezy/g" /etc/apt/sources.list
apt-get update
apt-get dist-upgrade
Now reboot to pick up the latest Linux kernel.
Now purge old uninstalled but configured packages from Debian 6.0, e.g.
aptitude
l~c [return]
_gg
Finally move down to Obsolete and Locally Created Packages and again do something like _g_g to purge them. Perform this step multiple times if necessary.
4. Backups
Backup everything before starting this process. Run tests to ensure that you can recover your backups successfully. There are some packages whose data will not function under the different architecture. One example is the controlfile format for PostgreSQL. Therefore we would need to create an architecture-independent backup that can be restored after the migration.
5. Boot into a 64 bit kernel
The 32 bit kernel does not allow the execution of 64 bit programs. However the 64 bit kernel allows the execution of both 32 bit and 64 bit programs, so this kernel is the first thing needed. Run the following in turn to allow 64 bit programs to be installed as an additional architecture, then install the 64 bit kernel. We will also install debootstrap as we will use it later.
dpkg --add-architecture amd64
apt-get update
apt-get install linux-image-amd64:amd64 debootstrap
Now reboot with the newly installed 64 bit amd64 kernel before continuing. You will probably wish to purge all the old 32 bit i386 kernels at this point. This will also ensure that the 64 bit kernel will be chosen automatically at each boot.
6. Pre-prepare files
Save a checkpoint of the packages we have installed at the start. The aim is to have the same packages installed at the end, just in the 64 bit architecture.
dpkg --get-selections "*:i386"|grep -v deinstall >dpkg-get-selections.cp.00.i386
dpkg --get-selections "*:amd64"|grep -v deinstall >dpkg-get-selections.cp.00.amd64
dpkg --get-selections "*:all"|grep -v deinstall >dpkg-get-selections.cp.00.all
Create a list of, and download, the packages for the base system. We can get away with including ssh in the base system, but most additional packages will break the migration process.
mkdir -p bootstrap-i386
rm -Rf bootstrap-i386/*
debootstrap --arch=i386 --download-only --include=openssh-client,openssh-server wheezy ./bootstrap-i386
mkdir -p bootstrap-amd64
rm -Rf bootstrap-amd64/*
debootstrap --arch=amd64 --download-only --include=openssh-client,openssh-server wheezy ./bootstrap-amd64
unalias ls
ls -1 bootstrap-amd64/var/cache/apt/archives/|egrep "\.deb$"|cut -d "_" -f1|awk '{print $1 " install"}' >dpkg-get-selections.base
7. Strip to 32 bit base system
Strip down the current selection of installed packages on the current 32 bit system to the base system of essential packages only. Do not abort the kernel removal when prompted, but note that the system will not be bootable until this is re-installed later with any required LVM tools, etc.
dpkg --clear-selections
cat dpkg-get-selections.base | dpkg --set-selections
apt-get dselect-upgrade
Downgrade the 32 bit base system to the base release (i.e. no updates or security patches). This step is needed because dpkg in Wheezy cannot cross-grade different versions of a package, and debootstrap does not include updates.
dpkg -i bootstrap-i386/var/cache/apt/archives/*.deb
8. Upgrade base system to 64 bit
Note you may skip the explicit cross-grade of dpkg and apt if you desire. Even if skipped, these packages will be cross-graded later (eventually).
Firstly prepare the files to cross-grade apt, but do not install.
mkdir -p archives-apt/partial
rm -f archives-apt/*.deb
apt-get install -d -y -o Dir::Cache::Archives=./archives-apt apt:amd64
Cross-grade dpkg from 32 bit to 64 bit first.
mkdir -p archives-dpkg/partial
rm -f archives-dpkg/*.deb
apt-get install -d -y -o Dir::Cache::Archives=./archives-dpkg dpkg:amd64
mv -i archives-dpkg/dpkg_*.deb .
dpkg -i archives-dpkg/*.deb
dpkg -i dpkg_*.deb
mv -i dpkg_*.deb archives-dpkg
Now complete the cross-grade of apt.
dpkg -i archives-apt/*.deb
Clear the package cache (to de-select 32 bit packages) and install the remaining base packages. Execute dpkg -i multiple times until no errors are encountered. This is a trade-off as it is simpler to re-run dpkg until all package dependencies succeed, rather than pre-calculate all the dependencies.
dpkg --clear-selections
dpkg --abort-after=1000 -i bootstrap-amd64/var/cache/apt/archives/*.deb
dpkg --abort-after=1000 -i bootstrap-amd64/var/cache/apt/archives/*.deb
dpkg --abort-after=1000 -i bootstrap-amd64/var/cache/apt/archives/*.deb
Save another checkpoint to document the state of the architecture migration.
dpkg --get-selections "*:i386"|grep -v deinstall >dpkg-get-selections.cp.01.i386
dpkg --get-selections "*:amd64"|grep -v deinstall >dpkg-get-selections.cp.01.amd64
dpkg --get-selections "*:all"|grep -v deinstall >dpkg-get-selections.cp.01.all
The base system is now running on the 64 bit architecture, so now we can clean up. The dselect-upgrade will remove the 32 bit base system and apply updates and security patches to the 64 bit base system.
apt-get autoremove
apt-get dselect-upgrade
Now we can finally re-install our kernel. After this we can take a breath as it will again be safe to reboot.
apt-get install locales linux-image-amd64 lvm2 grub-pc
Take another look at the packages we have installed. There should not be any i386 architecture packages installed at this point. The base system now comprises entirely amd64 and all packages. If any i386 packages remain at this point, go back over the previous steps, or remove them using dpkg, until they are all gone.
dpkg --get-selections "*:i386"|grep -v deinstall >dpkg-get-selections.cp.02.i386
dpkg --get-selections "*:amd64"|grep -v deinstall >dpkg-get-selections.cp.02.amd64
dpkg --get-selections "*:all"|grep -v deinstall >dpkg-get-selections.cp.02.all
9. Re-install packages
Now that the base system has been migrated to 64 bit, we can begin the process of re-installing the packages that were previously installed as 32 bit software. It may be necessary to run the installs and configures multiple times until all dependencies are met. Start with the most important software and any standard meta-packages.
I use the Gnome desktop environment, so I will pre-install those packages now. But first, manually purge some libraries that have their files in non-architecture-independent places. It is better to purge their 32 bit installation configurations rather than use --force-overwrite as this would only be a temporary work-around. If the install fails there may be other packages that need to be purged in a similar fashion using dpkg --purge pkgname:i386. If so, and once purged, re-install the conflicting package(s) using dpkg -i /var/cache/apt/archives/pkgname_*.deb and finish with dpkg --configure -a.
dpkg --purge libldap-2.4-2:i386 libpython2.7-minimal:i386 libpulse0:i386 libpython3.3-minimal:i386 libnl-3-200:i386 libatk-wrapper-java-jni:i386 libmagic1:i386 libgl1-mesa-dri:i386 libsane:i386 libxvmc1:i386 openjdk-7-jre-headless:i386 libsane-extras:i386 openjdk-6-jre-headless:i386 libpam-cap:i386 freeglut3:i386
apt-get install gnome-desktop-environment
dpkg --configure -a
Now we are ready to install all the software packages that were previously installed. Install dselect and use aptitude to bulk purge all the configuration files for the i386 libraries.
apt-get install dselect
dselect update
aptitude keep-all
aptitude forget-new
aptitude
l~clib
_gg
Now quit aptitude. Our --set-selections will now be successful once all remaining conflicting i386 packages have been purged.
cat dpkg-get-selections.cp.00.all|grep -v deinstall >dpkg-get-selections.final
cat dpkg-get-selections.cp.00.i386|grep -v ":i386"|grep -v deinstall|cut -f1|awk '{print $1 " install"}' >>dpkg-get-selections.final
cat dpkg-get-selections.cp.00.i386|grep ":i386"|grep -v deinstall|cut -d: -f1|awk '{print $1 " install"}' >>dpkg-get-selections.final
cat dpkg-get-selections.cp.00.amd64|grep ^linux-image|grep -v deinstall|cut -d: -f1|awk '{print $1 " install"}' >>dpkg-get-selections.final
dpkg --clear-selections
dpkg --remove-architecture i386
dselect update
cat dpkg-get-selections.final|dpkg --set-selections
Let's proceed. Be prepared to purge some 32 bit package configurations that still clash with the 64 bit package files.
apt-get dselect-upgrade
apt-get install `dpkg --get-selections "*:i386"|grep -v deinstall|cut -f1|cut -d: -f1|sed ':a;N;$!ba;s/\n/ /g'`
apt-get install `dpkg --get-selections "*:all"|grep -v deinstall|cut -f1|cut -d: -f1|sed ':a;N;$!ba;s/\n/ /g'`
apt-get install `dpkg --get-selections "*:amd64"|grep -v deinstall|cut -f1|cut -d: -f1|sed ':a;N;$!ba;s/\n/ /g'`
aptitude keep-all
/etc/init.d/gdm3 restart
10. Restore backups
Restore any backups that you took for data affected by the architecture migration, e.g. for PostgreSQL.
11. Allow 32 bit packages (optional)
We can now re-enable the installation of 32 bit packages. In other words we have a multiarch system that runs 64 bit but allows the installation of 32 bit programs and libraries.
dpkg --add-architecture i386
apt-get update
Take one final look at which packages are now installed.
dpkg --get-selections "*:i386"|grep -v deinstall >dpkg-get-selections.cp.03.i386
dpkg --get-selections "*:amd64"|grep -v deinstall >dpkg-get-selections.cp.03.amd64
dpkg --get-selections "*:all"|grep -v deinstall >dpkg-get-selections.cp.03.all
sdiff -s dpkg-get-selections.cp.00.i386 dpkg-get-selections.cp.03.amd64
12. Re-install 32 bit-only programs (optional)
Re-install any packages that are 32 bit only, for example:
apt-get install googleearth
Thanks and translation
Hi Ewan,
Thank you very much for your tutorial. I followed it for migrating some long time ago installed servers to amd64. Moreover I wrote a translation to spanish with some little tips added. If you'd like to check it it's on
https://doc.fmsistemas.com/servidores:general:wheezy_cambiando_arquitec…
Have a great weekend,
Felix.
Thanks!!
Excellent work! Followed step by step. It worked great!
Debian Wiki
The instructions at https://wiki.debian.org/Migrate32To64Bit are obsolete. Would you be against copying your howto into the Debian Wiki?
HowTo in Debian Wiki
In reply to Debian Wiki by Johannes (not verified)
Hi Johannes,
I don't have a problem with that. Could you retain the link to my page from the wiki?
Kind regards,
Ewan.
After I added the link to the
In reply to HowTo in Debian Wiki by Ewan
After I added the link to the Debian Wiki, someone else wrote: "note that the guide on that link also performs dangerous and unnecessary steps, like unpacking raw .deb packages because it removes essential packages, instead of simply letting dpkg cross-grade them." which sounds link the process could be simplified even further. What is your take on that?
Simplified process
In reply to After I added the link to the by Johannes (not verified)
I agree. My original method was to use apt (higher level) where possible, then fall back to dpkg (lower level) when necessary. I have reversed that. I have already updated this page accordingly. DEB files are no longer unpacked but cross-graded from i386 to amd64. This removed quite a few awkward steps. There is a limitation (currently) in that dpkg cannot cross-grade and up/downgrade at the same time. The cross-graded package must be the same version in both architectures. There is an additional step to ensure this limitation does not cause the base system cross-grade to fail.
Works!
In reply to Simplified process by Ewan
Did it after your last changes. 2,5h (most time waiting) to change jessie (not wheezy) from i386 to amd64 and no need to reinstall the machine. Thanks.
This also works for transitioning armel to and armhf
I've written up a few lines about it here:
http://clashthebunny.mason.ch/2014/03/upgrade-armel-to-armhf/
I think it's pretty good and the nice thing about armel->armhf is that you don't need the kernel upgrade! Thanks so much for the pointers on getting this running.
Thanks 1k!
Worked perfect! Thank you very much, I even learned something about how the package management works! Two thumbs up!
grub-pc on wheezy 64bit raid/lvm leaves system unbootable
First: big hug for your script, works perfect!
Relating to the subject, I had problems on a (soft)-raid1 within step 8.:
"Now we can finally re-install our kernel. After this we can take a breath as it will again be safe to reboot.
apt-get install locales linux-image-amd64 lvm2 grub-pc "
Installing grub-pc leaves the system unbootable.
see -> http://bugs.debian.org/cgi-bin/bugreport.cgi?archive=no&bug=707831
Because of this bug I installed grub-legacy as a temporary solution and it works.
Thanks again.
grub-pc on wheezy 64bit raid/lvm leaves system unbo .. (1)
Sorry, I just read my comment and there is an important hint missing (thankx for correct it)
Because of this bug [change] I removed/purged at the very end(!) of your script grub-pc and [change end] installed grub-legacy as a temporary solution and it works.
Thanks again.
grub-pc on wheezy 64bit raid/lvm leaves system unbootable
THANKS and comments
THANKS a bunch. Just got 3 wheezy iSCSI servers from 32 to 64 using your instructions (due to brain malfunctioning I had mistakenly set them up with 32bits).
Here are some minor extra steps I needed to make it work on my systems:
1 - after multiple "dpkg --abort-after=1000 -i bootstrap-amd64/var/cache/apt/archives/*.deb " I was still left with some errors which wouldn't go away. I had to:
dpkg -P libapt-pkg4.12:i386 libapt-inst1.5:i386
then one more
dpkg --abort-after=1000 -i bootstrap-amd64/var/cache/apt/archives/*.deb
to clear all errors.
2 - my resulting "dpkg-get-selections.final" still had three "686" packages, libc6, and 2 related to linux-image (although I had purged them before), which resulted in errors later, so I manually removed them from dpkg-get-selections.final after the
cat dpkg-get-selections.cp.00.amd64|grep ^linux-image|grep -v deinstall|cut -d: -f1|awk '{print $1 " install"}' >>dpkg-get-selections.final
All the rest was like magic.
Thanks again.
Joao
I just followed your
I just followed your instructions to upgrade an old server I had, worked great! Thanks for the detailed guide!
My desktop was originally
My desktop was originally installed as Woody circa 2003 and has been upgraded through each new Debian release (on multiple generations of hardware) to Wheezy.
Over this time it has accumulated a serious crapload of installed packages, and no small amount of cruft. I followed this howto carefully, checking the output at each command and the contents of generated text files, and dealing with issues as they arose (there were not many).
The only modification I made to these steps was to uninstall software that was not originally installed from a deb package (ie VMware Workstation) before beginning, and reinstalling it after the 64 bit migration.
Thanks for the excellent howto.
"Now reboot with the newly
"Now reboot with the newly installed 64 bit amd64 kernel before continuing. You will probably wish to purge all the old 32 bit i386 kernels at this point. This will also ensure that the 64 bit kernel will be chosen automatically at each boot."
I am new to debian and I don't know how to purge the i386 kernels.
List and purge
In reply to "Now reboot with the newly by Anonymous (not verified)
You can list the installed kernels using dpkg --list "linux-image*" and the 32 bit kernels are shown below on the i386 lines.
You can then purge kernels, for example apt-get purge linux-image-2.6-686:i386 linux-image-3.2.0-4-686-pae:i386 linux-image-686-pae:i386
System hosed
I got as far as the middle of step 8 (running "dpkg --abort-after=1000 -i bootstrap-amd64/var/cache/apt/archives/*.deb"), but there is a huge list of errors such as "tar: /lib/i386-linux-gnu/libc.so.6: version `GLIBC_2.17' not found (required by tar)". I presume I will need to reinstall from scratch, but does anyone have insight into what might have caused the problem, and if there is an easy fix I have overlooked?
Does the file exist?
In reply to System hosed by tombsar (not verified)
Does the file now exist, i.e. /lib/i386-linux-gnu/libc.so.6?
Step 6
The correct for me in the step 6 was: sudo debootstrap --arch=i386 --download-only --include=openssh-client,openssh-server jessie /bootstrap-i386 http://ftp.debian.org/debian
Debian 8 Jessie
In reply to Step 6 by Claudio Rocha … (not verified)
Yes, the guide was made for Debian 7 Wheezy, but works fine for Debian 8 Jessie.
For system's language other
For system's language other than english (example PL) add package locales to --include in debootstrap command (in point 6.)
Brilliant
Many, many thanks for this. It mostly worked great for me. There was a bit of a moment when somehow I'd ended up with a point version difference in a key package (libc6 IIRC) and then wondered how I'd get round the catch 22 of not having any means to copy a new file to the system without being able to install any of the tools that all relied on this lib. Then I found the correct i386 version was in fact there, installed it and carried on.
Rather than just re-installing everything that was on before, I took the opportunity to clean up a bit - but starting with a clone of the system (so all my scripts, customisations, config files etc all in place) certainly helped.
Thank you so much
I used it on jessy. It works great.
Thank you for this great and well explained procedure
Correction for ls statement to build list of base packages
Hi Ewan
I'm just trying to do a migration of a Devuan system following your guide.
However, I've one or two small problems with the following line in section 6, which produced an empty file on my system:
ls -1 bootstrap-amd64/var/cache/apt/archives/|egrep "\.deb$"|cut -d "_" -f1|awk '{print $1 " install"}' >dpkg-get-selections.base
First, the dollar sign in egrep ... .deb$ leads to an empty output here. If I remove the dollar sign, it works. I know it should denote the end of the line; maybe ls outputs additional (invisible) characters after the .deb over here - I don't know.
Second, i mistook the -1 (one) after the ls for an -l (long), due to the typeface my browser uses to show this line.
If an -l (long) is erratically used, then awk ... print $1 returns the access rights with added install for every line, and print $9 would work :-)
I don't know whether a -1 is needed at all, because ls and ls -1 apparently seem to produce identical results; if that option is not needed I'd suggest to leave it out alltogether.
In any case, I would suggest to add a suggestion to check the content of all selection... files immediately after creating them - just to make sure they're not empty, because that might cause some major disappointment in the process.
Now, I'll try to continue...
Thanks again for writing up this guide!
Suggestion: Add --color=never to the ls statements...
...in order to avoid control characters ending up in the produced base package listing.
These would otherwise stop dpkg from working.
Thanks and kind regards again! J.
Colors
In reply to Suggestion: Add --color=never to the ls statements... by js (not verified)
Hmm, pretty sure Ubuntu never used to do that (from memory), but there's an alias: alias ls='ls --color=auto'. Hopefully unalias ls will be sufficient to fix the behavior.
And another one... :-)
On my system, I tried to add a foreign architecture amd64 and installed several libraries in the :amd64 version before I tried the migration.
In step 7, cat dpkg-get-selections.base-all-packages | dpkg --set-selections failed with some warnings some errors; the latter caused by "more than one version of several packages installed", and this would stop the process.
So I tried dpkg-remove `dpkg-query -l | grep -io .*:amd64 | cut -d " " -f3' to remove all :amd64 packages before doing the migration, hoping this would help.
This fixed this problem; i.e. the set-elections worked - still with 10 warnings, but no errors.
However, I guess the removal of amd64 packages should have happened right in the beginning, before the installation of the amd64 kernel.
(I don't know enough to be completely sure, but you might know.)
Kind regards, J.
Hi JS, I never expected AMD64
In reply to And another one... :-) by js (not verified)
Hi JS, I never expected AMD64 packages to be installed at all, but I suppose you could have used them with qemu. They probably held dependencies on the base system and that would cause a mischief with the platform migration.
error debootstrap
got this error :
root@2508-11774-4993:/home/admin# debootstrap --arch=i386 --download-only --include=openssh-client,openssh-server wheezy ./bootstrap-i386
I: Retrieving Release
E: Failed getting release file http://ftp.us.debian.org/debian/dists/wheezy/Release
Debian 7 wheezy is so old now
In reply to error debootstrap by Jheff (not verified)
Debian 7 wheezy is so old now it has been moved to the archive: http://archive.debian.org/debian/dists/wheezy/