找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1|回复: 0

Enable ZRAM while disabling swap file in Zorin OS

[复制链接]
发表于 2026-6-7 23:39:06 | 显示全部楼层 |阅读模式
本帖最后由 demo 于 2026-6-8 15:59 编辑

To optimize memory performance in Zorin OS, it is recommended to enable ZRAM while disabling the traditional disk-based swap file, as ZRAM creates a compressed swap space in RAM that is significantly faster and reduces lag.

Enabling ZRAM
Install the necessary tools and configure the compression algorithm and memory percentage:

  1. sudo apt install zram-tools
  2. echo -e "ALGO=zstd\nPERCENT=70" | sudo tee -a /etc/default/zramswap
  3. sudo service zramswap reload
复制代码

Disabling Traditional Swap
To prevent conflict and ensure ZRAM is used exclusively, disable the existing swap file:
  • Open /etc/fstab and comment out the swap line (e.g., #/swapfile).
  • Run sudo swapoff /swapfile to deactivate it immediately.
  • Reboot the system to apply changes.

Optimizing Swappiness
Set the swappiness value to 10 to prioritize RAM usage and reduce swap activity, which improves responsiveness:
  1. echo 'vm.swappiness=10' | sudo tee /etc/sysctl.d/99-swappiness.conf
  2. sudo sysctl -p /etc/sysctl.d/99-swappiness.conf
复制代码


Setup Zswap in Zorin OS


To setup zswap on Zorin OS, you must first ensure a swap file exists, then configure the kernel parameters in GRUB to enable compression and memory pooling.

1. Verify or Create Swap File
Zorin OS typically uses a swap file. Verify it exists with free -h. If missing, create one:
  1. <blockquote>sudo fallocate -l 4G /swapfile
复制代码


2. Configure GRUB for Zswap
Edit the GRUB configuration to enable zswap with the lz4 compressor and z3fold pool:
  1. sudo nano /etc/default/grub
复制代码

Add the following to the GRUB_CMDLINE_LINUX_DEFAULT line:
  1. zswap.enabled=1 zswap.compressor=lz4 zswap.max_pool_percent=50 zswap.zpool=z3fold
复制代码

Save the file and update GRUB:
  1. sudo update-grub   
复制代码

3. Update Initramfs
Ensure the compression modules are loaded at boot:
  1. sudo su
  2. echo lz4 >> /etc/initramfs-tools/modules
  3. echo lz4_compress >> /etc/initramfs-tools/modules
  4. echo z3fold >> /etc/initramfs-tools/modules
  5. update-initramfs -u
  6. exit
复制代码

4. Reboot and Verify
Reboot your system. Verify zswap is active by running:
  1. cat /sys/module/zswap/parameters/enabled   
复制代码

A output of Y confirms zswap is enabled.  You can check compression ratios and pool usage via /sys/kernel/debug/zswap/.

来自圈子: Demo俱乐部
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|Well Moment Website ( Best Deal Inc. 001 )

GMT-8, 2026-7-12 08:09 , Processed in 0.013174 second(s), 16 queries .

Supported by Weloment Group X3.5

© 2008-2026 Best Deal Online

快速回复 返回顶部 返回列表