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

40,449

Solution 1

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.

Solution 2

The other answers here show that while this is theoretically possible, it is very complex and probably not worth the effort. You can, however, do a clean install and make the process relatively painless if you keep your $HOME the same.

The general process will be

  1. Make a backup of your list of installed packages and the list of automatically-installed packages.

    dpkg --get-selections '*' > package.list
    apt-mark showauto >auto.list
    

    Note that you might also want to remove the architecture from any package names that you have installed using multiarch:

    dpkg --get-selections '*' | sed -e 's/:\(i386\|amd64\)//' > package.list
    
  2. If your /home is a separate partition, just make sure not to format it during the installation process. If it is not on a separate partition, make a backup that you can restore from later:

    tar cvzf home_backup.tgz $HOME/
    
  3. Once you have installed your new system, install the missing packages

    sudo dpkg --set-selections < package.list 
    sudo apt-get update
    sudo apt-get dist-upgrade
    sudo apt-mark auto $(cat auto.list)
    
  4. Restore your $HOME. Copy the tgz file over and extract it in your $HOME directory:

    tar xvzf home_backup.tgz
    

You might also want to have a look at the tools that Mint provides to make this easier. They should all be installable on Ubuntu as well.

Solution 3

It is in theory possible, but likely treacherous. Debian multiarch at current supports multiarch libs, but not binaries. So there's that.

The system primarily understands its own architecture from dpkg-architecture (which is actually a perl script, but it extracts the arch info and displays it), which also claims to be able to set the architecture.


WARNING: I HAVE NOT DONE THIS NOR EVEN ATTEMPTED IT!!!


The rough process would be:

  1. Install the multiarch variant of all of your libraries (most importantly libgcc1)
  2. Use dpkg-architecture -aamd64 to shift your arch (Note, it may complain about GCC)
  3. Download and stage all required components (see next)
  4. Force installing the amd64 variant of dpkg and dependencies
  5. Force installing amd64 variants of essential base system packages, including apt-get and the kernel (Note, it may complain A LOT)
  6. Reboot
  7. Presumably install the rest of the system with apt-get

These steps are based on what I know of the design of Debian having used it almost exclusively among Linux distros over the past 12 years (including having used debtakeover before) and the approach that I would take. So consider this at your own risk. Your system may become unusable any time after attempting step 4. Alternate for steps 4 & 5 might be debbootstrap.

Most importantly, I highly suggest trying this on a VM before doing it on anything you care about.

Good luck, and May the Force be With You.

Solution 4

There are quite a few manuals out there, but hardly any show what to really expect. I am writing this on a Debian Wheezy laptop that I just finished upgrading from 32 bit to 64 and it does indeed work.

I followed these instructions and they were really accurate on what you will actually face:

http://blog.zugschlus.de/archives/972-How-to-amd64-an-i386-Debian-installation-with-multiarch.html

A recommendation is to keep the system powered through the whole process, do not reboot unless you are sure that you have migrated everything and that everything that was removed was installed again (especially essential packages), or you will not get the system running again.

Solution 5

Not an answer to the question, but it may be difficult to upgrade all packages from x86 to amd64, but you can at least easily install the amd64 kernel package, which will at least allow you to run 64 bit applications and virtual machines and containers (which may be enough for what you need).

Just install the amd64 linux-image package with dpkg -i --force-architecture.

Share:
40,449

Related videos on Youtube

tshepang
Author by

tshepang

I do software development for a living and as a hobby. My favorite language is Rust, and I've used Python much in the past. My OS of choice is Debian.

Updated on September 18, 2022

Comments

  • tshepang
    tshepang over 1 year

    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.

    • Admin
      Admin about 11 years
      I'm interested in answers to this question. I've got a 32 bit system on a 64 bit capable machine (which is now 6+ years old, but still going for the moment). The only reason I used 32 bit when I originally installed this machine in 2007, was because I wanted to run 32 bit applications on it. With the new multiarch, if I understand correctly, 32 bit apps can easily be installed on a 64 bit machine. So, it would be nice to convert to 64 bit for wheezy, but I don't know how hard it would be. @bahamat's suggestion of using a VM sounds good. If I manage a successful conversion I'll answer here.
    • Admin
      Admin about 10 years
    • Admin
      Admin over 8 years
      Similar question on AU: askubuntu.com/q/5018/178596
  • jordanm
    jordanm over 11 years
    --force-architecture is not needed, and the amd64 kernel can be installed via apt on i386.
  • Alen Milakovic
    Alen Milakovic almost 11 years
    Interesting to read what is actually involved, but having read this, I think I'm better off with a reinstallation. Thanks.
  • Ludwig Schulze
    Ludwig Schulze over 10 years
    "What I would do instead"... man, I was sure that OP asked without reinstall :/
  • Residuum
    Residuum over 10 years
    @Braiam The OP most likely wanted to do that without a reinstall. I was just reporting my personal experience doing that. The alternative route is simpler to me, and maybe I have made some mistakes while converting the system.
  • Adrien Clerc
    Adrien Clerc over 10 years
    To mark automatically installed packages, you could have used apt-mark showauto to export the auto-installed list and apt-mark auto to mark them in the new installation.
  • jberryman
    jberryman almost 9 years
    Thanks for writing up your experience. "If you want to cope with this, then skip the tricky part ;)" What if my goal is just to be able to develop software for x86_64, and don't care if my system packages aren't using the 64-bit processor optimally? I'm also running a 32-bit OS. I guess I thought my processor was 32-bit when I first did the install :(
  • Toby Speight
    Toby Speight almost 5 years
    That link isn't working for me - has the resource moved?
  • Markus Bawidamann
    Markus Bawidamann almost 5 years
    Oh yeah, did you see the date? I wrote that in 2013, stuff often vanishes on the web in 6 years. Sadly, the web still does not have a very basic function: Showing broken links before you click on a link.
  • Markus Bawidamann
    Markus Bawidamann about 4 years
    In this end, this is a pretty crazy stunt. I tried this back then "just to see if I would pull it off" (TM) Reinstalling is more elegant and justified, considering this is a big architectural change in the OS install.
  • unxed
    unxed over 2 years
    Use --to-64bit switch; see --help for details
  • unxed
    unxed over 2 years