So, how does zswap fit into the picture? Zswap is primarily a compression utility. When a process is ready to be relocated to the swap file, zswap compresses it and determines if the new, smaller size has to be moved or whether it may stay in RAM. Decompressing a 'zswapped' page is significantly faster than accessing the swap file, therefore this is an excellent method to get more bang for your buck from computers with limited RAM.
You can activate zswap with a single command because it is
supported by default.
In your terminal, type the following:
$ sudo sed -i -e 's/$/ zswap.enabled=1/' /boot/firmware/cmdline.txt
This command is essentially a shortcut to modify the cmdline.txt
file in your boot folder and set the zswap.enabled option to 'True' for newer
Linux users (1).
After that, you may restart your device to reap the benefits
of improved performance!
You can stop there if you're not a confident Linux user. On
your existing 4GB or 8GB Raspberry Pi, the above should already increase
performance. However, with a 2GB smartphone, this will not provide the
smoothest performance.
Dave Jones, who oversees Canonical's Ubuntu Raspberry Pi
effort, has a few more changes to share with experienced users. On his own
blog, he wrote a more extensive piece about how he set things up, but we'll
summarise it here.
Changing to z3fold and lz4 compression
The following are two further enhancements we'd want to
make:
- Using an allocator named z3fold to enhance the amount of items compressed.
- To utilise the lz4 compression algorithm, which offers a better combination of speed and compression.
In your terminal, type the following command:
$ sudo -i
# echo lz4 >> /etc/initramfs-tools/modules
# echo z3fold >> /etc/initramfs-tools/modules
# update-initramfs -u
# exit
Finally, identical to previously, we must add the following
commands to your cmdline.txt file:
$ sudo sed -i -e 's/$/ zswap.compressor=lz4/' /boot/firmware/cmdline.txt
$ sudo sed -i -e 's/$/ zswap.zpool=z3fold/' /boot/firmware/cmdline.txt
You may double-check that the modifications were done
appropriately by using grep to look for the parameters:
$ grep -R . /sys/module/zswap/parameters
/sys/module/zswap/parameters/same_filled_pages_enabled:Y
/sys/module/zswap/parameters/enabled:Y
/sys/module/zswap/parameters/max_pool_percent:20
/sys/module/zswap/parameters/compressor:lz4
/sys/module/zswap/parameters/zpool:z3fold
/sys/module/zswap/parameters/accept_threshold_percent:90
Ubuntu Desktop on the Raspberry Pi gets a performance bump!
Don't worry if the above instruction sounded a little
difficult. These optimizations will be implemented by default for all Raspberry
Pi 4 devices, including the 400, when Ubuntu 22.04 is released in April.
If you do make these modifications and test them out on a 2GB Raspberry Pi 4, we'd love to know how much better your performance has become. Please let us know if you think it provides a good Ubuntu Desktop experience for users with 2GB of RAM.
Posts You May like:
- Ubuntu 22.04 to Bring the Desktop to Raspberry Pi 4 2GB Users
- Audio Codec HAT adds sound to your Raspberry Pi
- The KiCad Project Announced Version 6.0.0. #KiCad @kicad_pcb
- LoRa HAT is Finally Out! Supports 915MHz | 868MHz | 433MHz
- How to Block Ads with Pi-hole on a Raspberry Pi Zero 2 W
- Uninterruptible Power Supply UPS HAT For Raspberry Pi
- A hidden speed boost and a 64-bit option are included in the new #RaspberryPi #OS
- Using the On-Board Bluetooth on the Raspberry Pi 4 for Communication
- #ArduinoIDE 2.0 Release Candidate (RC)
- Armbian Linux on the Raspberry Pi 4: A First Look
- NeoPixel Christmas Tree Lights Controlled by a Raspberry Pi
- What Type of LoRa Modules are Available?
- Introducing The Vision Five V1 is a RISC-V Based Raspberry Pi Replacement - Available Soon
- Raspberry Pi Zero 2 W Overclocking - Boost Up To 1.2GHz, or even 1.4GHz
- The Arduino UNO Mini Limited Edition is Now Available
- Scan QR Codes with Raspberry Pi Pico
- Create Barcodes with Pure Python
- The New Version of Raspberry Pi OS, Debian "Bullseye" is Now Available.
- The Raspberry Pi Zero 2 W Arrives Six Years After The First Pi Zero
- Raspberry Pi 4 Has Been Given Vulkan 1.1 Compliance by Khronos
- The Raspberry Pi Build HAT - Complete Guide
- Raspberry Pi Officially Announced Build HAT For Raspberry Pi
- Installing Android on a Raspberry Pi 4 with Google Play Store
- Pop OS Linux is Coming to Raspberry Pi and Other ARM Devices Soon
- How to Immediately Upgrade to Windows 11
- A Secret Update for the Raspberry Pi 4 8GB
- Raspberry Pi Introduces a New Documentation Hub
- Quick start with ESP8266 based Pico WiFi HAT
- Capture local Real-Time Air Quality Data with Raspberry Pi Pico
- Ubuntu 22.04 to Bring the Desktop to Raspberry Pi 4 2GB Users
- Audio Codec HAT adds sound to your Raspberry Pi
- The KiCad Project Announced Version 6.0.0. #KiCad @kicad_pcb
- LoRa HAT is Finally Out! Supports 915MHz | 868MHz | 433MHz
- How to Block Ads with Pi-hole on a Raspberry Pi Zero 2 W
- Uninterruptible Power Supply UPS HAT For Raspberry Pi
- A hidden speed boost and a 64-bit option are included in the new #RaspberryPi #OS
- Using the On-Board Bluetooth on the Raspberry Pi 4 for Communication
- #ArduinoIDE 2.0 Release Candidate (RC)
- Armbian Linux on the Raspberry Pi 4: A First Look
- NeoPixel Christmas Tree Lights Controlled by a Raspberry Pi
- What Type of LoRa Modules are Available?
- Introducing The Vision Five V1 is a RISC-V Based Raspberry Pi Replacement - Available Soon
- Raspberry Pi Zero 2 W Overclocking - Boost Up To 1.2GHz, or even 1.4GHz
- The Arduino UNO Mini Limited Edition is Now Available
- Scan QR Codes with Raspberry Pi Pico
- Create Barcodes with Pure Python
- The New Version of Raspberry Pi OS, Debian "Bullseye" is Now Available.
- The Raspberry Pi Zero 2 W Arrives Six Years After The First Pi Zero
- Raspberry Pi 4 Has Been Given Vulkan 1.1 Compliance by Khronos
- The Raspberry Pi Build HAT - Complete Guide
- Raspberry Pi Officially Announced Build HAT For Raspberry Pi
- Installing Android on a Raspberry Pi 4 with Google Play Store
- Pop OS Linux is Coming to Raspberry Pi and Other ARM Devices Soon
- How to Immediately Upgrade to Windows 11
- A Secret Update for the Raspberry Pi 4 8GB
- Raspberry Pi Introduces a New Documentation Hub
- Quick start with ESP8266 based Pico WiFi HAT
- Capture local Real-Time Air Quality Data with Raspberry Pi Pico