The materials contained in this web site are for information purposes only. I expressly disclaim all liability to any person in respect of anything and in respect of the consequences of anything done or omitted to be done wholly or partly in reliance upon the whole or any part of the contents of this web site. I am not responsible for any third party contents which can be accessed through this web site.
This tutorial will guide you crossgrade your 32bint Ubuntu installation to 64bit on a RaspberryPi 3B+.
32bit architechure on RaspberryPi 3B+ is known as armhf which is a ‘hard float’ version of armv7, 64bit is called arm64 or aarch64.
Install arm64 bootloader (aka U-Boot) and arm64 linux kernel — Boot into the arm64 kernel — Replace all the packages with their arm64 counterparts
su
dpkg --add-architecture arm64
apt update
apt install u-boot-rpi:arm64 u-boot-tools:arm64 linux-image-raspi:arm64
# SDCard mount points
# lsblk | grep mmcblk0
# mmcblk0 179:0 0 7.4G 0 disk
# |-mmcblk0p1 179:1 0 256M 0 part /boot/firmware
# `-mmcblk0p2 179:2 0 7.2G 0 part /
cd /boot/firmware
# Sample output
ls -al | grep .bin
# -rwxr-xr-x 1 root root 52456 Feb 2 04:35 bootcode.bin
# -rwxr-xr-x 1 root root 52456 Jan 18 12:11 bootcode.bin.bak
# -rwxr-xr-x 1 root root 466672 Jan 18 07:30 uboot_rpi_2.bin
# -rwxr-xr-x 1 root root 516416 Jan 18 07:30 uboot_rpi_3.bin
# -rwxr-xr-x 1 root root 479120 Jan 18 07:30 uboot_rpi_3_32b.bin
# -rwxr-xr-x 1 root root 572064 Jan 18 07:30 uboot_rpi_4.bin
# -rwxr-xr-x 1 root root 536140 Jan 18 07:30 uboot_rpi_4_32b.bin
# -rwxr-xr-x 1 root root 558456 Jan 18 07:30 uboot_rpi_arm64.bin
# An original configuration file from stock 64bit Ubuntu RPI3B+ system image.
cat config.txt
# ...
[pi4]
kernel=uboot_rpi_4.bin
max_framebuffers=2
[pi2]
kernel=uboot_rpi_2.bin
[pi3]
kernel=uboot_rpi_3.bin
[all]
arm_64bit=1
device_tree_address=0x03000000
# ...
enable_uart=1
cmdline=cmdline.txt
include syscfg.txt
include usercfg.txt
# After reboot login as root
arch
# aarch64
apt clean
apt --download-only install dpkg:arm64 tar:arm64 apt:arm64 apt-utils:arm64
cd /var/cache/apt/archives/
dpkg -i *.deb
apt --fix-broken install
# ...
# cd /var/cache/apt/archives/
# dpkg -i apt*
apt full-upgrade
# Make sure default arch has been changed
dpkg --print-architecture
# arm64
dpkg --print-foreign-architectures
# armhf
apt install $(dpkg -l | grep '^.i.*:armhf' | grep :armhf | sed -e s/:armhf/:amd64/ | awk '{print $2}')
reboot
#...
apt purge $(dpkg -l | grep '^.i.*:armhf' | awk '{print $2}')
dpkg --remove-architecture armhf
apt update
You can keep the armhf architecture and some armhf packages.In case some packages do not provide arm64 version, and you need them. Use tty console cable connect to the RaspberryPi, unstable ssh connection may cause unnecessary trouble during the crossgrade process. Besides, you may want to install man-db and some network related service packages at last. Because, first, man-db will be temperory broken if you have not installed its dependences, and you will not be able to use man to check manuals when you forget something, second, if something go wrong with the service packages that related to network, you may not be able to connect to the internet, therefore you can not use apt to install packages online anymore, and you will need another computer to fix this broken.
[1]. Debian Wiki CrossGrading
[2]. Ubuntu RaspberryPi Wiki Multiarch
[3]. Is it possible to “upgrade” from a 32bit to a 64bit installation? the answer by Asterix on AskUbuntu.com
[4]. Convert from armhf to arm64 on Raspberry Pi 3 B running 64-bit Ubuntu Server 18.04 LTS (Bionic) the answer by moonwalker on AskUbuntu.com
— Feb 5, 2022