From 17555cad7965ff70ee857463f69e8b2c696dbb64 Mon Sep 17 00:00:00 2001 From: Graham Dennis Date: Thu, 25 Jul 2024 12:35:37 +1000 Subject: [PATCH] Count hard links when sizing virtual disks cptofs does not preserve hard links, so each hard link needs to be accounted for separately when sizing virtual disks --- nixos/lib/make-disk-image.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/lib/make-disk-image.nix b/nixos/lib/make-disk-image.nix index 208eaf59dc5c..e5b3d1db70c9 100644 --- a/nixos/lib/make-disk-image.nix +++ b/nixos/lib/make-disk-image.nix @@ -470,7 +470,7 @@ let format' = format; in let additionalSpace=$(( $(numfmt --from=iec '${additionalSpace}') + reservedSpace )) # Compute required space in filesystem blocks - diskUsage=$(find . ! -type d -print0 | du --files0-from=- --apparent-size --block-size "${blockSize}" | cut -f1 | sum_lines) + diskUsage=$(find . ! -type d -print0 | du --files0-from=- --apparent-size --count-links --block-size "${blockSize}" | cut -f1 | sum_lines) # Each inode takes space! numInodes=$(find . | wc -l) # Convert to bytes, inodes take two blocks each!