All newer Raspberry Pi models, like the 3/3+ series, the 4 and also the 400 all have a 64-bit CPU, but the Raspberry Pi OS still works with 32-bit by default for compatibility reasons.
To take full advantage of the capabilities of a 64-bit CPU, you should also run a 64-bit operating system on it. This can speed up some calculations considerably.
A 64-bit operating system can also run 32-bit programs without any problems, so you usually don't have any disadvantages due to software that doesn't run anymore or similar.
With the conversion of the Raspberry Pi OS to 64-bit, we therefore have both the CPU and the operating system on 64-bit, while most programs still run in 32-bit. So we don't lose anything, but even gain a bit of speed in case of CPU calculations or 64-bit programs.
Note: with this tutorial you can run the kernel from the operating system in 64-bit and thus speed up some calculations. But the programs still run in 32-bit and 64-bit programs can't be run with this :-/
Before we do the actual conversion, we should update the operating system, programs and dependencies:
$ sudo apt update
$ sudo apt upgrade
If the conversion to 64-bit works at all (and is necessary), we find out with these commands:
$ lsb_release -a
The output afterwards should look like the following (the current version at the time of writing this article):
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 10 (buster)
Release: 10
Codename: buster
We can find out if we are currently using 32- or 64-bit with uname:
$ uname -a
The output then tells us exactly which kernel version is currently in use:
Linux pi400 5.10.17-v7+ #1403 SMP Mon Feb 22 11:29:51 GMT 2021 armv7l GNU/Linux
Linux pi400 5.10.17-v8+ #1403 SMP PREEMPT Mon Feb 22 11:37:54 GMT 2021 aarch64 GNU/Linux
If you already have the 64-bit kernel listed, you don't need to do anything else. Find kernel
We use the following command to see if the 64-bit kernel is even present (it should be):
$ ls /boot/kernel8.img
The output should simply give us the path to the kernel image and then the actual conversion can start: Switch Raspberry Pi OS to 64-bit
We open our favorite configuration file again:
$ sudo nano /boot/config.txt
and add this line at the end
arm_64bit=1
Then confirm as usual with CTRL-X, J and Enter, save and then reboot once:
$ sudo reboot -h now
After the reboot, another uname -a will hopefully tell us that we have booted with the 64-bit kernel and we are done.
Added gist for Debian11 upgrade