From Fedora Project Wiki
Description
Test swap-on-zram with a custom configuration.
Setup
- Make sure your system has swap-on-zram installed and enabled.
How to test
- Create a custom configuration file, which will override the default configuration file:
sudo cp /usr/share/doc/zram-generator/zram-generator.conf.example /etc/systemd/zram-generator.conf
- Edit the configuration file, read the included documentation, and set custom values. (Pay attention to
host-memory-limit
, if you have more total memory than this value, the zram device will not get created at all).sudo nano /etc/systemd/zram-generator.conf
- Restart the swap-on-zram service to apply your changes:
sudo systemctl restart swap-create@zram0.service
- Confirm the swap-on-zram service was run correctly (its status is
active (exited)
):$ sudo systemctl status swap-create@zram0.service ● swap-create@zram0.service - Create swap on /dev/zram0 Loaded: loaded (/usr/lib/systemd/system/swap-create@.service; static; vendor preset: disabled) Active: active (exited) since Sun 2020-06-28 19:52:48 MDT; 1min 0s ago Docs: man:zram-generator(8) man:zram-generator.conf(5) Process: 650 ExecStart=/usr/lib/systemd/system-generators/zram-generator --setup-device zram0 (code=exited, status=0/SUCCESS) Main PID: 650 (code=exited, status=0/SUCCESS) CPU: 28ms Jun 28 19:52:48 fmac.local systemd[1]: Starting Create swap on /dev/zram0... Jun 28 19:52:48 fmac.local zram-generator[653]: Setting up swapspace version 1, size = 512 MiB (536866816 bytes) Jun 28 19:52:48 fmac.local zram-generator[653]: no label, UUID=72991b9c-f8fd-459c-9bb8-6e8ac19a16c2 Jun 28 19:52:48 fmac.local systemd[1]: Finished Create swap on /dev/zram0.
- Look at
zramctl
andswapon
output and confirm the zram device is configured according to your custom values you've set in the configuration file.$ zramctl NAME ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT /dev/zram0 lzo-rle 512M 4K 73B 12K 8 [SWAP] $ swapon NAME TYPE SIZE USED PRIO /dev/sda5 partition 10.4G 0B -2 /dev/zram0 partition 512M 0B 100
- After you verified this test case, return back to the original state by deleting the custom configuration file and again restarting the service (or rebooting):
sudo rm /etc/systemd/zram-generator.conf sudo systemctl restart swap-create@zram0.service
Expected Results
- The swap-on-zram service should start correctly.
- The values you set in the configuration file should correctly affect the zram swap device (size, algorithm, whether it exists at all, etc).