Debian – How to convert a 32-bit (x86) Debian-based system to 64-bit

32bit64bitdebian

I have a 32-bit system which runs on a 64-bit processor. How do I convert it to be all-64-bit, without re-installing? I have seen somewhere that it is doable as a result of the new Multiarch framework.

Best Answer

TL;DR: It is doable, but complicated. I have outlined an alternative at the bottom.

Now the long description, and take it with a grain of salt, as I may not have taken the best route:

It is possible, and here is what I did for the last two nights: There is a wiki entry describing the old-school way without multiarch support. It is helpful for fixing broken packages.

To migrate your base system, do this:

$ dpkg --print-architecture
i386
# dpkg --add-architecture amd64
$ dpkg --print-foreign-architectures
amd64
# apt-get update
# apt-get download gcc-4.6-base:amd64 libgcc1:amd64 libc6:amd64 \
          libselinux1:amd64 zlib1g:amd64 libbz2-1.0:amd64 dpkg:amd64
# dpkg -i gcc-4.6-base*.deb libgcc*.deb libc*.deb libselinux*.deb \
          libbz2*.deb zlib*.deb dpkg*.deb
$ dpkg --print-architecture
amd64
$ dpkg --print-foreign-architectures
i386

Some of your packages are then amd64, but most will remain i386. apt-get upgrade will take care of some packages, apt-get -f install will repair some of errors, but still most packages will remain i386. If you want to cope with this, then skip the tricky part ;)

Using dpkg --get-selections | grep :i386 will return all your packages, that you will still have to migrate.

My next idea was to do:

# apt-get install `dpkg --get-selections \
  | grep i386 \
  | awk {'gsub(/:i386/, ":amd64"); print $1'}`

But it turned out to be a bad idea: some packages are not available in amd64 (e.g. libc6-i686), apt-get will be confused, and a lot of packages will be installed in both versions. A lot of manual work in aptitude is to be done.

More hardship: Some essential packages can be replaced, so that you will always have the binaries installed for installation, but some packages will have to be removed and installed again, e.g. I had this problem with tar. I wgot the packages on another system, extracted the packages via ar p package.deb data.tar.gz | tar zx and then scped the extracted files via scp -r ./* root@other_computer:/, so the binaries are available again. Rinse and repeat, and the scped files will be overwritten.

What I would do instead

I have done the following, whenever I switched systems:

Back up /home, /etc (and maybe /var, /usr/local, some other files you have changed, /root, ..., YMMV).

Get a list of installed packages with dpkg --get-selections > packagelist and copy the resulting file packagelist as well.

Then do a clean reinstall of Debian, create all users again, maybe roles, etc.

Reinstall all packages with dpkg --set-selections < packagelist; apt-get -f install.

Copy back the backed up directories, files, and you are mostly done.

One downside to that approach: All your packages, including libraries, will be marked as manually installed, so they will not be uninstalled, when no package depends on them any more.

Related Question