Files
nix-config/modules/nixos/base/zram.nix
2024-03-04 00:48:01 +08:00

21 lines
996 B
Nix
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
# Enable in-memory compressed devices and swap space provided by the zram kernel module.
# By enable this, we can store more data in memory instead of fallback to disk-based swap devices directly,
# and thus improve I/O performance when we have a lot of memory.
#
# https://www.kernel.org/doc/Documentation/blockdev/zram.txt
zramSwap = {
enable = true;
# one of "lzo", "lz4", "zstd"
algorithm = "zstd";
# Priority of the zram swap devices.
# It should be a number higher than the priority of your disk-based swap devices
# (so that the system will fill the zram swap devices before falling back to disk swap).
priority = 5;
# Maximum total amount of memory that can be stored in the zram swap devices (as a percentage of your total memory).
# Defaults to 1/2 of your total RAM. Run zramctl to check how good memory is compressed.
# This doesnt define how much memory will be used by the zram swap devices.
memoryPercent = 50;
};
}