How to: Switch your Raspberry Pi to 64-bit kernel (Raspbian)

 Switch your Raspberry Pi to 64-bit kernel (Raspbian)



As you might know, Raspberry Pi 3/3+/4 all have a 64bit CPU but Raspbian (the official and default system for the Raspberry Pi) is 32-bit.

In this guide I will show you how to switch the kernel to 64-bit, however I only recommend doing this with the latest Rasbian Lite (the one without desktop) and you should take a look at the “known issues” at the bottom of this article before proceeding.

Why Raspbian is 32-bit

This is because the old Raspberry Pis are still supported (which is good) but have a 32-bit CPU, which means they couldn’t run a 64-bit OS, however 64-bit CPUs can run a 32-bit OS. So, it kind of makes sense to make the OS 32-bit for everyone by default. However, there are some performance benefits of using a 64-bit OS on a 64-bit CPU, to leverage the capabilities of the CPU.

64-bit can run 32-bit

There is a compromise, though! It is possible to have a 64-bit CPU with 32-bit OS but having a 64-bit kernel to leverage the CPU capabilities.

This is possible because in the same way a 64-bit CPU can run a 32-bit OS, a 64-bit Linux kernel can run 32-bit applications.

However, the kernel is 32-bit by default on Raspbian. We can change that! We will switch the kernel to 64-bit so it will be able to leverage the 64-bit CPU capabilities.

We will go 64-64-32!

This means we will be running Raspbian on a 64-bit CPU, with a 64-bit Linux kernel, and the rest of the OS 32-bit. This basically means the applications that make up the OS will remain 32-bit, but we will be able to leverage the 64-bit CPU capabilities thanks to the new 64-bit Linux kernel which can give us a performance boost in some situations.

Switching the kernel to 64-bit

Prerequisites

This assumes you are on the latest Raspbian Buster with all the updates installed.

You can check whether you’re on Buster or not with:

lsb_release -a

Which will output something like:

Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 10 (buster)
Release:        10
Codename:       buster

And you want to install all updates with:

sudo apt update
sudo apt upgrade

Now to verify the 64-bit kernel exists:

ls /boot/kernel8.img

If it exists, it will simply print out the path to it. Otherwise, it will tell you: No such file or directory.

Switching

Now that we made sure we’re up to date and the 64-bit kernel exists, let’s switch to it!

Edit /boot/config.txt with your favorite editor, for example nano:

sudo nano /boot/config.txt

Go to the very end of the file and add this line:

arm_64bit=1

Hit CTRL + X, confirm to save with Y, and hit enter twice.

Now reboot to boot with the new, 64-bit kernel!

sudo systemctl reboot

Verifying

Verify you are running the 64-bit kernel with:

uname -a

Which will output something like:

Linux raspberrypi 4.19.97-v8+ #1294 SMP PREEMPT Thu Jan 30 13:27:08 GMT 2020 aarch64 GNU/Linux

As you can see, the kernel version now outputs “v8” at the end, and the architecture is now set to aarch64. This means we’re running the 64-bit kernel!

That’s all there is to it!

Known issues

  • vcsm driver doesn’t work with 64-bit (only the cma version) which will break software decode with Kodi.
  • Mathematica and Wolfram fail to run. Workaround here
  • Java 8 doesn’t work but OpenJDK 11 does.

I don’t need Mathematica or Wolfram and don’t need video functionality on a server and I can live with OpenJDK 11 if I need Java. So, I’m happily running a 64-bit kernel on my Pi!


Post a Comment

0 Comments