mirror of
https://github.com/nix-community/disko.git
synced 2026-11-30 13:03:28 +01:00
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.
This commit is contained in:
1 parent
c4d34f2031
commit
1c3238a177
1 file changed
+7
@@ -155,6 +155,13 @@ let
|
||||
# systems, while -P 4 is ~30% slower. Cap at 8 but use fewer workers if the
|
||||
# system has fewer cores.
|
||||
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
|
||||
''
|
||||
|
||||
Reference in new issue
Block a user