Change ARC limit to 20%

This commit is contained in:
2026-05-07 21:51:46 +02:00
parent 4fc2befee5
commit 25c32cb65d
+3 -4
View File
@@ -2,9 +2,8 @@
{ {
config = lib.mkIf config.boot.zfs.enabled { config = lib.mkIf config.boot.zfs.enabled {
# Set ARC max to 5% of physical RAM at boot
systemd.services."zfs-arc-limit" = { systemd.services."zfs-arc-limit" = {
description = "Set ZFS ARC max to 5% of physical RAM"; description = "Set ZFS ARC max to 20% of physical RAM";
# Ensure the module is loaded before we write to /sys # Ensure the module is loaded before we write to /sys
after = [ "systemd-modules-load.service" ]; after = [ "systemd-modules-load.service" ];
# Run early, but its fine if ZFS has already imported; the limit still applies # Run early, but its fine if ZFS has already imported; the limit still applies
@@ -15,8 +14,8 @@
# Total RAM in kB # Total RAM in kB
mem_kb=$(awk '/MemTotal:/ {print $2}' /proc/meminfo) mem_kb=$(awk '/MemTotal:/ {print $2}' /proc/meminfo)
echo "DEBUG: Total RAM: $mem_kb kB" echo "DEBUG: Total RAM: $mem_kb kB"
# 5%, in bytes # 20%, in bytes
arc_max_bytes=$(( mem_kb * 1024 / 100 * 5 )) arc_max_bytes=$(( mem_kb * 1024 / 100 * 20 ))
echo "DEBUG: Setting ZFS ARC max to: $arc_max_bytes bytes" echo "DEBUG: Setting ZFS ARC max to: $arc_max_bytes bytes"
param="/sys/module/zfs/parameters/zfs_arc_max" param="/sys/module/zfs/parameters/zfs_arc_max"
if [ -w "$param" ]; then if [ -w "$param" ]; then