git.iko.soy/typeable/nixpkgs
on master help sign in
sd-image: Pull less slack in the image by accounting for slack

The slack, seemingly, accounted for more than the minimum required for slack plus the two partitions. This change makes the gap a somewhat abstracted amount, but is not configurable within the derivation.

commitc113c094cf1b8e6c344178aa420c679baef33e17 authorSamuel Dionne-Riel <samuel@dionne-riel.com> dateTue 4 Jun 2019, 21:33 (7 years ago) parent1843e00
1 file changed+7−4
nixos/modules/installer/cd-dvd/sd-image.nix+7−4
nixos/modules/installer/cd-dvd/sd-image.nix+7−4
@@ -125,10 +125,13 @@ in
125125 echo "${pkgs.stdenv.buildPlatform.system}" > $out/nix-support/system
126126 echo "file sd-image $img" >> $out/nix-support/hydra-build-products
127127
128− # Create the image file sized to fit /boot/firmware and /, plus 20M of slack
128+ # Gap in front of the first partition, in MiB
129+ gap=8
130+
131+ # Create the image file sized to fit /boot/firmware and /, plus slack for the gap.
129132 rootSizeBlocks=$(du -B 512 --apparent-size ${rootfsImage} | awk '{ print $1 }')
130133 firmwareSizeBlocks=$((${toString config.sdImage.firmwareSize} * 1024 * 1024 / 512))
131− imageSize=$((rootSizeBlocks * 512 + firmwareSizeBlocks * 512 + 20 * 1024 * 1024))
134+ imageSize=$((rootSizeBlocks * 512 + firmwareSizeBlocks * 512 + gap * 1024 * 1024))
132135 truncate -s $imageSize $img
133136
134137 # type=b is 'W95 FAT32', type=83 is 'Linux'.
@@ -138,8 +141,8 @@ in
138141 label: dos
139142 label-id: ${config.sdImage.firmwarePartitionID}
140143
141− start=8M, size=$firmwareSizeBlocks, type=b
142− start=${toString (8 + config.sdImage.firmwareSize)}M, type=83, bootable
144+ start=''${gap}M, size=$firmwareSizeBlocks, type=b
145+ start=$((gap + ${toString config.sdImage.firmwareSize}))M, type=83, bootable
143146 EOF
144147
145148 # Copy the rootfs into the SD image