1. Introduction
This brief HOWTO shows how to take a working 32 bit 12.04 installation and convert it into a 64 bit system. You will be able to keep all your programs, settings and data. You start with a 32 bit system that can run 64 bit programs, then convert it to a 64 bit system that can run 32 bit programs.
With the upcoming release of Debian GNU/Linux wheezy, a new feature called multiarch is being 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 it has other uses.
With the release of Ubuntu LTS 12.04 (Precise Pangolin), this feature is available now.
Update 2014-06-24: This HowTo has been replaced for the new 14.04 LTS release of Ubuntu. The process is now more straight-forward.
2. Boot into 64 bit
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 is the first thing needed. Run the following in turn to allow 64 bit programs to be installed as a foreign architecture, then install the 64 bit kernel. We also install debootstrap as we will use it later.
echo "foreign-architecture amd64" >/etc/dpkg/dpkg.cfg.d/multiarch
apt-get update
apt-get install linux-image-3.2.0-23-generic:amd64 debootstrap
You may also wish to deinstall all the old 32 bit kernels at this point. Now reboot with the newly installed 64 bit amd64 kernel before continuing.
3. 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.cp0.i386
dpkg --get-selections "*:amd64"|grep -v deinstall >dpkg-get-selections.cp0.amd64
dpkg --get-selections "*:all"|grep -v deinstall >dpkg-get-selections.cp0.all
Download some essential files that we will call upon later. Unpack dpkg and dash as we will need the executables to be available later.
mkdir -p archives/partial
rm archives/*.deb
apt-get install -d -o Dir::Cache::Archives=./archives apt:amd64 dpkg:amd64 bash:amd64 dash:amd64
rm -Rf files/*
dpkg-deb -x archives/dpkg_*.deb files
dpkg-deb -x archives/dash_*.deb files
Also 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
rm -R bootstrap/*
debootstrap --arch=amd64 --download-only --include=openssh-client,openssh-server precise ./bootstrap
ls -1 bootstrap/var/cache/apt/archives/|egrep "\.deb$"|cut -d "_" -f1|awk '{print $1 " install"}' >dpkg-get-selections.base
4. Backups
4.1. PostgreSQL
The controlfile format for PostgreSQL differs on different architectures. Therefore we need to create an architecture-independent backup that can be restored after the migration.
su - postgres -c "umask 77; pg_dumpall >/tmp/pg_dumpall_9_1.sql"
mv /tmp/pg_dumpall_9_1.sql .
bzip2 -f pg_dumpall_9_1.sql
mkdir -p etc/postgresql/9.1/main
cp -pi /etc/postgresql/9.1/main/pg_hba.conf etc/postgresql/9.1/main
apt-get purge postgresql-9.1
5. 32 bit base system
Shrink down the current selection of installed packages on the current 32 bit system to the base system of essential packages only.
dpkg --clear-selections
dpkg --set-selections <dpkg-get-selections.base
apt-get dselect-upgrade
6. Upgrade base system
Install some miscellaneous packages and all the libraries that we will need immediately for our base system upgrade.
apt-get install --no-install-recommends linux-image-3.2.0-23-generic:amd64
apt-get remove ubuntu-minimal
apt-get install gcc-4.6-base:amd64 libc6:amd64 libgcc1:amd64 libssl1.0.0:amd64
dpkg -i archives/lib*.deb archives/zlib*.deb
Start with the installation of 64 bit versions of dpkg and apt. We unpacked apt earlier, so we can use the unpacked version to install the replacement package.
rm /etc/dpkg/dpkg.cfg.d/multiarch
dpkg --force-remove-essential --force-depends -r dpkg:i386
PATH=$PATH:files/usr/bin:files/sbin dpkg -i archives/dpkg_*_amd64.deb
dpkg -r apt:i386
dpkg -i archives/apt_*
Fix the apt dependencies.
apt-get update
apt-get -f install
The installation will halt with the following error. This is because both dash and bash were removed together.
dpkg: error processing dash:i386 (--remove): subprocess installed post-removal script returned error exit status 2
Install our unpacked version of dash to resolve the missing dependency.
cp -pi files/bin/dash /bin/sh
apt-get -f install
The next message concerns a python-minimal dependency problem.
dpkg: dependency problems prevent configuration of python-minimal: python-minimal depends on python2.7-minimal (>= 2.7.3); however: Package python2.7-minimal is not configured yet.
This dependency is simple to resolve. Now continue resolving dependencies that apt cannot automatically resolve.
dpkg -i /var/cache/apt/archives/python-minimal_*_amd64.deb /var/cache/apt/archives/python2.7-minimal_*_amd64.deb
apt-get -f install
dpkg --configure -a
apt-get autoremove
Now install the 64 bit shells. I answer "Yes" to the debconf prompt when configuring dash as the system shell.
cp -pi files/bin/dash /bin/bash
apt-get install dash
dpkg --configure -a
apt-get install bash
dpkg --configure -a
Save another checkpoint to document the state of the architecture migration.
dpkg --get-selections "*:i386"|grep -v deinstall >dpkg-get-selections.cp1.i386
dpkg --get-selections "*:amd64"|grep -v deinstall >dpkg-get-selections.cp1.amd64
dpkg --get-selections "*:all"|grep -v deinstall >dpkg-get-selections.cp1.all
Gradually replace each 32 bit package with its 64 bit equivalent.
apt-get install apt-utils
apt-get install --reinstall locales
#dpkg --get-selections "*:i386"|grep -v deinstall|grep -v ^lib|cut -d: -f1
apt-get install --no-install-recommends sudo bsdutils bzip2 crda logrotate diffutils e2fslibs file gnupg gpgv grep gzip hostname ifupdown iproute iputils-ping isc-dhcp-client initscripts
apt-get install login mawk
apt-get --no-install-recommends install mount mountall
apt-get install module-init-tools multiarch-support ncurses-bin
apt-get --no-install-recommends install net-tools netcat-openbsd passwd ureadahead base-passwd
apt-get install --no-install-recommends vim-common vim-tiny whiptail xz-utils
dpkg --configure -a
apt-get install util-linux
apt-get install udev
apt-get install procps e2fsprogs
dpkg --configure -a
apt-get install sysvinit-utils upstart
dpkg --configure -a
apt-get remove e2fslibs:i386 zlib1g:i386
apt-get --no-install-recommends install openssh-server openssh-client
dpkg --configure -a
We are now down to the last few 32 bit packages, but these are essential and their removal/replacement will break the base system. Thus we manually unpack them now so we can continue to access their programs while they are being replaced.
dpkg-deb -x bootstrap/var/cache/apt/archives/tar_*.deb files
dpkg --force-remove-essential --force-depends -r tar:i386
cp -pi files/bin/tar /bin
dpkg -i bootstrap/var/cache/apt/archives/tar_*.deb
dpkg-deb -x bootstrap/var/cache/apt/archives/findutils_*.deb files
dpkg --force-depends -r initramfs-tools
dpkg --force-remove-essential -r findutils:i386
PATH=$PATH:files/usr/bin dpkg -i bootstrap/var/cache/apt/archives/findutils_*.deb
apt-get install initramfs-tools
dpkg-deb -x bootstrap/var/cache/apt/archives/coreutils_*.deb files
dpkg --force-remove-essential --force-depends -r coreutils:i386
PATH=$PATH:files/bin dpkg -i bootstrap/var/cache/apt/archives/coreutils_*.deb
apt-get install libpam-modules-bin
apt-get remove gcc-4.6-base:i386
The libc6-bin package needs a little nudge to install. When the following message appears, run the commands to resume the package configuration.
dpkg-deb -x bootstrap/var/cache/apt/archives/libc-bin_*.deb files
apt-get install libc-bin
dpkg: warning: 'ldconfig' not found in PATH or not executable. dpkg: error: 1 expected program not found in PATH or not executable.
cp -pi files/sbin/ldconfig files/sbin/ldconfig.real /sbin
apt-get install libc-bin
dpkg --configure -a
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.
dpkg --get-selections "*:i386"|grep -v deinstall >dpkg-get-selections.cp2.i386
dpkg --get-selections "*:amd64"|grep -v deinstall >dpkg-get-selections.cp2.amd64
dpkg --get-selections "*:all"|grep -v deinstall >dpkg-get-selections.cp2.all
7. 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.
apt-get install rsync
dpkg --configure -a
apt-get install ubuntu-desktop ubuntu-minimal ubuntu-standard
dpkg --configure -a
apt-get install ubuntu-desktop ubuntu-minimal ubuntu-standard
dpkg --configure -a
I use the Gnome desktop environment, so I will install the packages now. When asked to choose a display manager I choose "Okay" then "lightdm".
apt-get install gnome-shell gnome-desktop-environment
dpkg --configure -a
Now we are ready to install all the software packages that were previously installed.
cat dpkg-get-selections.cp0.i386 dpkg-get-selections.cp0.all|grep -v deinstall|awk '{print $1 ":amd64 install"}'|dpkg --set-selections
rm /etc/dpkg/dpkg.cfg.d/multiarch
apt-get update
apt-get dselect-upgrade
dpkg --configure -a
apt-get dselect-upgrade
dpkg --configure -a
I saw the following message when running through these steps. I do not know if it is harmful or related to the later message about an invalid debconf value.
Use of uninitialized value $_[0] in join or string at /usr/share/perl5/Debconf/Client/ConfModule.pm line 121, <STDIN> line 30.
Continue with the installation. You will then see another message.
apt-get dselect-upgrade
Package configuration dictionaries-common: wordlists An invalid debconf value [] has been found It does not correspond to any installed package in the system. That is usually caused by problems at some time during packages installation, where the package providing [] was selected for installation but finally not installed because of errors in other packages. To fix this error, reinstall (or install) the package that provides the missing value. Then, if you don't want this package on your system, remove it, which will also remove its debconf entries. Menu to be shown after this message will try to leave the system in a working state until then. <Ok>
Now complete the package installation.
dpkg --configure -a
8. Restore backups
8.1. PostgreSQL
The postgresql package was re-installed for us. Its configuration and data needs to be restored.
cp -p etc/postgresql/9.1/main/pg_hba.conf /etc/postgresql/9.1/main
/etc/init.d/postgresql reload
bzcat pg_dumpall_9_1.sql.bz2 >/tmp/pg_dumpall_9_1.sql
su - postgres -c "cd /tmp; psql <pg_dumpall_9_1.sql >psql.out 2>psql.err"
mv -i /tmp/psql.* .
rm /tmp/pg_dumpall_9_1.sql
9. Allow 32 bit packages
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.
cp -pi files/etc/dpkg/dpkg.cfg.d/multiarch /etc/dpkg/dpkg.cfg.d
apt-get update
apt-get dselect-upgrade
Take one final look at what packages are now installed.
dpkg --get-selections "*:i386"|grep -v deinstall >dpkg-get-selections.cp3.i386
dpkg --get-selections "*:amd64"|grep -v deinstall >dpkg-get-selections.cp3.amd64
dpkg --get-selections "*:all"|grep -v deinstall >dpkg-get-selections.cp3.all
10. Re-install 32 bit-only programs
Re-install any packages that are 32 bit only, for example:
apt-get install googleearth
Notes
There are some packages that pre-depend on bash, but are not documented as such in their control files. I need to raise a bug for these: libssl1.0.0, kismet and grub-pc.
Many thanks for this!
Really great step-by-step explanation, and it actually works! I was prepared to face a few terrible (unforseenable) issues along the way, but the worst things that happened were a) I had to type everything because I didn't dare do it remotely and b) my Internet went down somewhere in the middle (right before the packages for ubuntu-desktop etc. had to be downloaded). Just a bad timing from my provider I guess :-)
I now have a full system, everything that has a amd64 version is amd64, and also Skype (i386 only) with all its dependencies... Thank you so much for this! Although I have to discourage anyone from trying this, I was probably just lucky (and I had a full backup stashed away on disk ;-)) The backup was handy at some point to include in my PATH, to have the coreutils somewhere when needed...
Glad to help, Jo
In reply to Many thanks for this! by Jo Vandeginste (not verified)
So far I have only tried this on a virtual machine clone of my working machine (as I still have not taken the plunge to upgrade to the latest LTS release where the bit migration is possible), but did run through, refining the steps, many, many times. I am pleased the guide was thorough but broad enough to work for you. Thank you for your feedback!
Advise use of console
In reply to Glad to help, Jo by Ewan
I wanted to add that I performed the 32 to 64 bit upgrade entirely in a console session, so any lack of the desktop packages was never an issue for me. The SSH server should also have been accessible throughout the process. Anyway I have now upgraded the 'real' machine from 10.04 LTS (Lucid Lynx) to 12.04 LTS (Precise Pangolin), so the 64 bit migration will be happening soon. The only factor that may stall this is if hibernation does not work with the 64 bit operating system (due to a BIOS bug). The first step is the 64 bit kernel installation, so it won't be too disasterous if this happens to be the case.
Does this process work remotely?
Am I correct is assuming that after I reboot to the 64bit kernel, sshd would be working and I would be able to complete the steps remotely. I only need the kernel and mysql-server to go 64 bit and it would be great to not have to travel to the datacenter for just this.
Please advise,
Thanks
Remote sshd access
In reply to Does this process work remotely? by skystarf (not verified)
As with any operation of this nature it is advisable to have some form of console access available to you, e.g. ILO. Once the system is rebooted with the 64 bit kernel it will start all the 32 bit server processes as normal, including sshd. The ssh client and server dependencies are gathered early on in the process, but there are intervals where, should you lose connectivity, you would be unable to reconnect.
As you can see, I use PostgreSQL primarily for the database, so I don't know the dependencies for MySQL. For example, how much of the system, minimally, needs to be upgraded to 64 bit to support 64 bit MySQL? The whole base system, or just a few libraries?
I suggest you perform multiple dry runs on a virtualised copy of this remote system. I will also test how the migration process behaves over an ssh connection, but may not be able to get around to it this week.
Failed at first step!
In reply to Remote sshd access by Ewan
I tried this on 13.04.
echo "foreign-architecture amd64" >/etc/dpkg/dpkg.cfg.d/multiarch is not needed anymore, it does not fetch amd64 from the repos, dpkg --add-architecture amd64 works though.
However, after apt-get update and apt-get install linux-image-generic:amd64 and rebooting, the server won't boot with warnings like this: http://i.imgur.com/i9bZwLQ.jpg
I tried, changing the uuid to /dev/xxxx etc but to no avail.
I can boot fine into the older 32bit kernel though.
Any ideas?
Thanks!
/proc/partitions
In reply to Failed at first step! by skystarf (not verified)
initrd was not updated (Ubuntu 12.04)
After first reboot I've boot into previous version of kernel. 64-bit one was 3.5.0-37, but I booted into 3.5.0-36 (32-bit). Later I have discovered that corresponding initrd is missing from /boot.
update-initramfs -c -k 3.5.0-37-generic
update-grub
That helped
Kernel origin
In reply to initrd was not updated (Ubuntu 12.04) by Ivan Levashew (not verified)
Hi Ivan, the Linux kernel in my 12.04 LTS installation is version 3.2.0. What was the origin and flavour of your kernel? That may account for the different initrd behaviour.
Hi
Hi
Excellent Writeup. I followed your how-to and it amazingly it worked staright-away. I now have 64-bit ubuntu 12.04. There were little issues with some libs, etc. but I could solve them easily.
Very good work, considering especially how many people on different forums are suggesting a fresh install in order to move to 64-bit.
Thanks a lot and keep up the good work.
14.04 64 bit upgrade
In reply to Hi by Asif (not verified)
You're welcome! For those holding back, the 64 bit migration should be much simpler under 14.04 LTS. I'll get a guide out when the release is available and I've tested the process.
Opposite issue
In reply to Hi by Asif (not verified)
Every step worked perfectly until I got to the end of step 5 where you deselect-upgrade. For some reason, this caused all of my packages to get deleted including the ones that work with apt and terminal. So when i went to do the next step, I kept getting errors and than my terminal shut down and I couldn't open anything. I tried restarting and my operating system was not being shown by the boot loader. In the end i was forced to install a 64 bit os directly.
That is very strange. It
In reply to Opposite issue by ZK (not verified)
That is very strange. It would appear the 'set selections' stage found no packages to mark for installation. Do you remember if you had any errors running the debootstrap in the earlier step? I'd have hoped that the operating system would have thrown up a severe warning before allowing you to remove essential packages – forcing you to confirm. This would have provided an opportunity to abort and review the previous steps.
Upgrading 18.04.3 LTS (Bionic Beaver) from 32 to 64 bit HowTo
Hi, does this steps applicable for Ubuntu 18.04.3 LTS ? To change from 32bit OS to 64bit. My processor is AMD64.
They should work, but I have
In reply to Upgrading 18.04.3 LTS (Bionic Beaver) from 32 to 64 bit HowTo by nabila (not verified)
They should work, but I have not tested yet. It is on my list to check this soon. This would be the final version for conversion since Canonical won't release the next version of Ubuntu in 32-bit.