From db995f7d77a0ce8a1c37fab0bb21280493cd71d2 Mon Sep 17 00:00:00 2001 From: Astro Date: Thu, 9 Sep 2021 00:14:51 +0200 Subject: [PATCH] layers: add disable-scheduled-defrag --- wfvm/layers/default.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/wfvm/layers/default.nix b/wfvm/layers/default.nix index 8fb9958..c02cdfc 100644 --- a/wfvm/layers/default.nix +++ b/wfvm/layers/default.nix @@ -154,6 +154,16 @@ in win-exec "reg add HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\Personalization /v NoLockScreen /t REG_DWORD /d 1" ''; }; + # Don't let Windows start completely rewriting gigabytes of disk + # space. Defragmentation increases the size of our qcow layers + # needlessly. + disable-scheduled-defrag = { + name = "disable-scheduled-defrag"; + script = '' + echo Disabling scheduled defragmentation service + win-exec 'schtasks /Change /DISABLE /TN "\Microsoft\Windows\Defrag\ScheduledDefrag"' + ''; + }; # Chain together layers that are quick to run so that the VM does # not have to be started/shutdown for each.