Want to run the full Ubuntu desktop on a Raspberry Pi 4 with 2GB of RAM? Well, now you can.

Ubuntu already supports the Raspberry Pi 4 Model B 4GB and 8GB versions (and has done since the Ubuntu 20.10 release). Now the team building the distro plan to go further by supporting the Raspberry Pi 4 2GB model too (which costs around £40, if you’re considering one).

However, making Ubuntu run decently on devices with modest amounts of memory is difficult.

Enter zswap, Ubuntu’s ‘secret weapon’ in targeting low-memory Pis with the full-blown Ubuntu experience.

Most Ubuntu systems come with a swap file. This acts as an ‘overflow’ for RAM, caching processes and tasks that aren’t immediately needed to free up RAM for ones that are. The existing Ubuntu Raspberry Pi builds are no exception to this.

But all that reading to and from an SD card isn’t the fastest fallback. So Ubuntu is swapping — yes, pun intended 😉— to a compression tool like Zswap.

“When a process is about to be moved to the swap file, zswap compresses it and checks whether the new, smaller size still needs to be moved or if it can stay in your RAM. It is much quicker to decompress a ‘zswapped’ page than it is to access the swap file so this is a great way of getting more bang for your buck from systems with smaller amounts of RAM,” Canonical’s Oliver Smith explains.

Result? A smoother, faster Ubuntu desktop experience.

You don’t have to wait for Ubuntu 22.04 LTS to be released to take advantage of this, either. You can enable Zswap in Ubuntu right now to enjoy the performance boosts it proffers.

Assuming you have a modern version of Ubuntu running on a Raspberry Pi 4 already, just open a your favourite terminal emulator and run:

sudo sed -i -e 's/$/ zswap.enabled=1/' /boot/firmware/cmdline.txt

Then, reboot and enjoy.

ZSwap isn’t the only modification Ubuntu will make to meet its low-memory minimum. Canonical’s Dave Jones details other efforts being taken to support this goal in a post on his blog, name checking z3fold & lz4 compression.

In all, pretty great news.

Dev raspberry pi raspberry pi 4 Ubuntu 22.04 LTS zswap