Ubuntu 22.04 is the first release of Ubuntu that works well on the Raspberry Pi 4 without any lag or stutter. Most of the credit for this goes to the work done on the Mesa drivers over the last year by Igalia. The 2D graphics support and Vulkan 3D support for the Pi 4 are currently in great shape and continue to pick up improvements.
This article provides a few tips to improve the performance further.
1. Disable Zswap and Enable Zram
Ubuntu 22.04 enables the use of Zswap by default. Zswap works similarly to Zram but requires a swap file stored on disk. If you have the 4GB or 8GB model of Pi 4 you can disable Zswap, and enable Zram instead, to get slightly better performance.
Zswap is built into the Linux kernel while Zram is available as an optional kernel module. Run the following command to install the Zram kernel module.
sudo apt install -y linux-modules-extra-raspi
To configure Zram we have 2 packages to choose from:
zram-config
Developed by Canonical. Simple to use but lacks configuration options.zram-tools
Similar to Zram-config. Provides a configuration file to select the compression algorithm, threshold, size and priority.
Use either zram-config
or zram-tools
. Don’t install both.
Run the following command to install zram-tools
(and remove zram-config
if installed)
sudo apt install -y zram-tools
sudo apt autoremove --purge -y zram-config
Edit the configuration file as shown below:
sudo gedit /etc/default/zramswap
The Zram priority is set to 100. The system will always use Zram first before using the swap file.
Zswap and Zram should not be used together. Run the command below to disable Zswap:
sudo sed -i -e 's/zswap.enabled=1/zswap.enabled=0/' /boot/firmware/cmdline.txt
Reboot the system for the changes to take effect.
After reboot, you can check the Zram usage with the following command:
zramctl
2. Overclock if you have fan and heat sinks
If you have a heat-sink and a fan attached to the Pi 4 you can overclock the CPU and GPU for a nice 25% boost in performance without any downsides.
Don’t try this without a heat sink and fan though. Overclocking your Pi without a fan will result in worse performance, as the Pi will throttle constantly to stay below the 80° C temperature limit.
Edit the config.txt
file:
sudo gedit /boot/firmware/config.txt
Paste the following lines at the end:
over_voltage=6
arm_freq=2000
gpu_freq=750
Change dtoverlay=vc4-kms-v3d
to dtoverlay=vc4-fkms-v3d
to overclock the system successfully. The Full KMS overlay (vc4-kms-v3d
) is not suitable for overclocking. Using the firmware overlay (vc4-fkms-v3d
) allows the system to be properly overclocked.
Save the file and reboot for changes to take effect.
3. Convert the file system to BTRFS
The official pre-installed Ubuntu image uses the EXT4 filesystem by default. You can convert the filesystem to BTRFS to take advantage of the in-built compression features. Using compression can reduce the disk usage by up to 60% without any noticeable impact on CPU usage. It also improves storage performance, since less data needs to be read and written to the SD Card. BTRFS also supports filesystem snapshots that allow you to roll back the system to a previous state in case of issues.
There are tutorials online for converting the filesystem to BTRFS. After converting the filesystem you also need to make some changes to the system configuration, to ensure that it continues to boot successfully after installing kernel updates in the future.
The filesystem can be converted easily using FlashIt.
- Start FlashIt and select the Convert Filesystem action from the main window.
- Select the SD Card (or USB drive) that has the official Ubuntu 22.04 image installed on it. This must be a fresh system, and the initial system setup should have been completed.
- Select the filesystem as BTRFS and click on Convert. The conversion will take about 10 minutes to complete.
- Insert the converted SD Card or USB drive into the Pi4 and boot from it. The system is ready to use.
4. Switch to local mirrors for faster system updates
Switching to a local mirror will max out your internet connection and download package updates as fast as possible. There are many ways to select and use the fastest mirrors. We will install and use Nala.
Nala is a prettier frontend for APT that makes it easier to install packages from the command line. It has the same syntax as apt. Run the below command to install Nala from its official repository.
wget -O - https://teejeetech.com/scripts/jammy/install_nala | bash
Run the command sudo nala fetch
to search for the fastest mirrors in your geographic region. When prompted for a choice enter 1 2
and hit Enter. It will use the first two fastest mirrors in your region.
5. Use Google’s DNS Servers for Faster Internet
Many ISPs have slow DNS servers that cause delays and timeouts when loading web pages. For a faster internet experience, change your WiFi settings to switch to Google’s DNS servers.
Enter the values 8.8.4.4, 8.8.8.8
in the DNS field of the IPv4 tab.
Enter the values 2001:4860:4860::8888, 2001:4860:4860::8844
in the DNS field of the IPv6 tab.
Disconnect and reconnect the WiFi connection to see changes.
Hi
I don’t get timeshift (latest V22) working. The GUI starts always in “Live USB Mode” even OS installed on partition sda1 (Mint, 5.4.0-117-generic #132~18.04.1-Ubuntu SMP, 32bit). Any idea/hint?
root@tuxsrv1:/etc/timeshift# timeshift –list
Mounted ‘/dev/sdf2’ at ‘/run/timeshift/-5260364296465920892/backup’
Device : /dev/sdf2
UUID : 13e3d4a1-c247-47f8-8d1a-f860836b757a
Path : /run/timeshift/-5260364296465920892/backup
Mode : RSYNC
Status : No snapshots on this device
First snapshot requires: 0 B
No snapshots found
Found stale mount for device ‘/dev/sdf2’ at path ‘/run/timeshift/-5260364296465920892/backup’
Unmounted successfully
root@tuxsrv1:/etc/timeshift# lsblk -fs
NAME FSTYPE LABEL UUID MOUNTPOINT
fd0
sda1 ext4 69dcfc6f-3ceb-404c-965a-a20f25562640 /
└─sda
sdf1 vfat BUPUTILS 6262-A846 /media/schobi/BUPUTILS
└─sdf
sdf2 ext3 backup_ext3 13e3d4a1-c247-47f8-8d1a-f860836b757a /media/schobi/backup_ext3
└─sdf
sdg1 ntfs usbdisk F068D1C168D1872E /media/schobi/usbdisk
└─sdg
md0 ext4 788fc87d-2893-4d9e-be2f-22dc6e661a27 /mnt/md0
├─sdb linux_raid_member tuxsrv1:0 ea918639-c79c-939d-bab4-781880ac084f
├─sdc linux_raid_member tuxsrv1:0 ea918639-c79c-939d-bab4-781880ac084f
└─sdd linux_raid_member tuxsrv1:0 ea918639-c79c-939d-bab4-781880ac084f
vg00-temp ext4 4f7f2c64-ccfd-468d-8243-0576d35eeae7 /mnt/lv_temp
└─sde1 LVM2_member D6Axkd-NSVz-O9n5-7AZ2-wFB6-zGg2-NfjetD
└─sde
Timeshift is detecting your system as a Live system (booted from a Live CD/USB). This can be caused by the way your system is set up and needs further investigation.
Please report issues through proper channels:- Issue Tracker
Use the Linux Mint forums if you need support:- Linux Mint Forums