2025-03-14 22:42:49 +01:00
|
|
|
{
|
2023-01-18 15:40:42 +01:00
|
|
|
name = "zram-generator";
|
|
|
|
|
2023-03-20 22:50:11 +08:00
|
|
|
nodes = {
|
|
|
|
single =
|
|
|
|
{ ... }:
|
|
|
|
{
|
|
|
|
virtualisation = {
|
|
|
|
emptyDiskImages = [ 512 ];
|
2024-12-10 20:26:33 +01:00
|
|
|
};
|
2023-03-20 22:50:11 +08:00
|
|
|
zramSwap = {
|
|
|
|
enable = true;
|
|
|
|
priority = 10;
|
|
|
|
algorithm = "lz4";
|
|
|
|
swapDevices = 1;
|
|
|
|
memoryPercent = 30;
|
|
|
|
memoryMax = 10 * 1024 * 1024;
|
|
|
|
writebackDevice = "/dev/vdb";
|
2024-12-10 20:26:33 +01:00
|
|
|
};
|
2023-03-20 22:50:11 +08:00
|
|
|
};
|
|
|
|
machine =
|
2024-12-10 20:26:33 +01:00
|
|
|
{ ... }:
|
|
|
|
{
|
2023-03-20 22:50:11 +08:00
|
|
|
zramSwap = {
|
|
|
|
enable = true;
|
|
|
|
priority = 10;
|
|
|
|
algorithm = "lz4";
|
|
|
|
swapDevices = 2;
|
|
|
|
memoryPercent = 30;
|
|
|
|
memoryMax = 10 * 1024 * 1024;
|
|
|
|
};
|
|
|
|
};
|
2023-01-18 15:40:42 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
2023-03-20 22:50:11 +08:00
|
|
|
single.wait_for_unit("systemd-zram-setup@zram0.service")
|
|
|
|
|
2023-01-18 15:40:42 +01:00
|
|
|
machine.wait_for_unit("systemd-zram-setup@zram0.service")
|
2023-02-02 11:28:12 +08:00
|
|
|
machine.wait_for_unit("systemd-zram-setup@zram1.service")
|
|
|
|
zram = machine.succeed("zramctl --noheadings --raw")
|
2025-05-09 12:45:57 +02:00
|
|
|
swap = machine.succeed("swapon --show --noheadings --raw")
|
2023-02-02 11:28:12 +08:00
|
|
|
for i in range(2):
|
|
|
|
assert f"/dev/zram{i} lz4 10M" in zram
|
2025-05-09 12:45:57 +02:00
|
|
|
assert f"/dev/zram{i} partition 10M" in swap
|
2023-01-18 15:40:42 +01:00
|
|
|
'';
|
|
|
|
}
|