sd-image.nix: Move the /boot partition up to 8M
Reportedly some ARM boards need some boot code at the start of a SD card that could be larger than a megabyte. Change it to 8M, and while at it reduce the /boot size such that the root partition should now start on a 128M boundary (the flash on SD cards really don't like non-aligned writes these days).
This commit is contained in:
parent
b6621196e0
commit
4cf9bf9eb0
@ -30,7 +30,7 @@ in
|
|||||||
|
|
||||||
bootSize = mkOption {
|
bootSize = mkOption {
|
||||||
type = types.int;
|
type = types.int;
|
||||||
default = 128;
|
default = 120;
|
||||||
description = ''
|
description = ''
|
||||||
Size of the /boot partition, in megabytes.
|
Size of the /boot partition, in megabytes.
|
||||||
'';
|
'';
|
||||||
@ -66,10 +66,10 @@ in
|
|||||||
buildInputs = with pkgs; [ dosfstools e2fsprogs mtools libfaketime utillinux ];
|
buildInputs = with pkgs; [ dosfstools e2fsprogs mtools libfaketime utillinux ];
|
||||||
|
|
||||||
buildCommand = ''
|
buildCommand = ''
|
||||||
# Create the image file sized to fit /boot and /, plus 4M of slack
|
# Create the image file sized to fit /boot and /, plus 20M of slack
|
||||||
rootSizeBlocks=$(du -B 512 --apparent-size ${rootfsImage} | awk '{ print $1 }')
|
rootSizeBlocks=$(du -B 512 --apparent-size ${rootfsImage} | awk '{ print $1 }')
|
||||||
bootSizeBlocks=$((${toString config.sdImage.bootSize} * 1024 * 1024 / 512))
|
bootSizeBlocks=$((${toString config.sdImage.bootSize} * 1024 * 1024 / 512))
|
||||||
imageSize=$((rootSizeBlocks * 512 + bootSizeBlocks * 512 + 4096 * 1024))
|
imageSize=$((rootSizeBlocks * 512 + bootSizeBlocks * 512 + 20 * 1024 * 1024))
|
||||||
truncate -s $imageSize $out
|
truncate -s $imageSize $out
|
||||||
|
|
||||||
# type=b is 'W95 FAT32', type=83 is 'Linux'.
|
# type=b is 'W95 FAT32', type=83 is 'Linux'.
|
||||||
@ -77,8 +77,8 @@ in
|
|||||||
label: dos
|
label: dos
|
||||||
label-id: 0x2178694e
|
label-id: 0x2178694e
|
||||||
|
|
||||||
start=1M, size=$bootSizeBlocks, type=b, bootable
|
start=8M, size=$bootSizeBlocks, type=b, bootable
|
||||||
type=83
|
start=${toString (8 + config.sdImage.bootSize)}M, type=83
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Copy the rootfs into the SD image
|
# Copy the rootfs into the SD image
|
||||||
|
Loading…
x
Reference in New Issue
Block a user