Ubuntu: Change from 32 Bit to 64 Bit (Mostly)

Tested on Ubuntu 16.04. Here are the commands, life story and explanation is below:

echo foreign-architecture amd64 | tee /etc/dpkg/dpkgcfgd/multiarch

dpkg --add-architecture amd64

apt update
apt install linux-image-4.15.0-50:amd64
apt install gcc-multilib
apt upgrade


(Reboot, make sure you boot on to the new kernel), and then set sources.list to only have amd64 (Put [ arch=amd64 ] before each URL)

apt update
dpkg --get-selections | grep -v deinstall | cut -f1 > list.log

for i in $(cat list.log); do apt install --reinstall "$i"; done


Not all packages will reinstall, just ones with 64 bit versions. Remove amd64 requirement from sources.list.

Explanation

I hope this isn’t a common problem. As is stated somewhere on this website (I think), we’re all students at the same college. For one of our classes we were given an environment to complete some assignments in, and let’s just say it’s a bit old. Initially it had 32 bit Ubuntu 12 and Windows Sever 2012 (not r2).

After version hopping to Ubuntu 16, we decided to try and make it 64 bit so that we could install a personal project of mine called Gogios. Surprisingly, it worked decently well. It is not a perfect switch though. The resulting system will be a multiarch one, not pure 64 bit.

Now for the explanation.

echo foreign-architecture amd64 | tee /etc/dpkg/dpkgcfgd/multiarch
dpkg --add-architecture amd64


These lines inform dpkg that 64 bit packages should also be installable. This is what allows the system to become multiarch and have a 64 bit kernel.

apt update
apt install linux-image-4.15.0-50:amd64
apt install gcc-multilib
apt upgrade


Standard apt stuff mostly. First update the package list to include 64 bit packages. Then install a 64 bit kernel. As of writing this 4.15 is the latest available. I’ve tried this with generic and lowlatency and both worked fine, so pick either. The second install is for gcc-multilib, as the currently one is probably only for 32 bit. Finally, upgrade all current packages.

At this point, reboot and make sure that you boot onto the x86_64 kernel that was just installed. After you’re back up, add [arch=amd64] before each URL in sources.list.

apt update
dpkg --get-selections | grep -v deinstall | cut -f1 > list.log

for i in $(cat list.log); do apt install --reinstall "$i"; done


apt update again to remove 32 bit packages from the package list temporarily. The dpkg line gets a list of all currently installed packages, removes the ones marked as uninstallable, and then outputs them to a file.

The final line reads through that file and passes each entry to apt for it to install. If it finds a 64 bit version in the current repo list, then it will install that version of the package.

About: Bailey Kasin

I build virtual environments and challenges for Cybersecurity students to complete as a way to gain experience before graduating and entering the workforce.


2 thoughts on “Ubuntu: Change from 32 Bit to 64 Bit (Mostly)”

  1. Hello ,
    At present I have 32bit install of 18.04 and yours is the first site I found that explains how to get to 64bit, I get lost on some of the lines to type in and the explanation. I ned to upgrade the OS to 20.04 but I am not allowed due to 32bit. Just please explain how to convert over to 64bit. I have AMD 4300 and the lscpu says 32, 64-bit. I need to fix this so upgrades can be had.
    Thank you

  2. After 5 + hours of files updating, I gave up and just downloaded the 64 bit .iso for Ubuntu and updated my system that way. You might want to let ppl know this process takes a looooong time.

Leave a Reply

Your email address will not be published. Required fields are marked *