Compare commits

...
Author SHA1 Message Date
lassulus 1c3238a177 make-disk-image: limit dirty page accumulation to prevent OOM
Set dirty_bytes and dirty_background_bytes to low thresholds (10MB/5MB)
before copying the nix store into the VM image. This forces the kernel
to write back dirty pages almost immediately instead of letting them
accumulate. Clean page cache is evicted automatically under memory
pressure, so this prevents OOM even when copying files larger than
available VM RAM.
2026-03-14 20:34:58 +01:00
+7
View File
@@ -155,6 +155,13 @@ let
# systems, while -P 4 is ~30% slower. Cap at 8 but use fewer workers if the # systems, while -P 4 is ~30% slower. Cap at 8 but use fewer workers if the
# system has fewer cores. # system has fewer cores.
mkdir -p "$rootMountPoint"/nix/store mkdir -p "$rootMountPoint"/nix/store
# Limit dirty page accumulation to prevent OOM in the VM.
# The kernel evicts clean page cache under memory pressure, but dirty
# pages must be written back first. Low thresholds force early writeback
# so dirty pages never pile up enough to trigger the OOM killer,
# even when copying files larger than available RAM.
echo 10000000 > /proc/sys/vm/dirty_bytes
echo 5000000 > /proc/sys/vm/dirty_background_bytes
${ ${
if cfg.copyNixStoreThreads == "auto" then if cfg.copyNixStoreThreads == "auto" then
'' ''