mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-12-25 19:32:44 +01:00
scripts/mkimg.arm.sh: build Pi img as resizable FAT16 partition
Construct a partitioned disk, resizable with libparted-based tools (gparted and al.). libparted has limitations to cross cluster size boundaries in resize operations [1]. Use the minimum image file size to ensure FAT16 partition crosses the 2K/4K cluster size boundary (128MB+)[2]. In MB alignment, this is a full image 130MB = 129MB + 1MB offset for partition table (sector 2048 =1MB). [1] https://www.gnu.org/software/parted/manual/html_node/parted_58.html [2] https://www.pctechguide.com/hard-disks/file-systems-fat-fat8-fat16-fat32-and-ntfs-explained
This commit is contained in:
parent
6afe4d3803
commit
657b468231
@ -52,12 +52,14 @@ profile_rpi() {
|
||||
}
|
||||
|
||||
create_image_imggz() {
|
||||
MIN_IMG_SIZE=130 # exceed 128MB minimum FAT16 partition size in MB to cross 4k cluster size boundary
|
||||
sync "$DESTDIR"
|
||||
local image_size=$(du -L -k -s "$DESTDIR" | awk '{print $1 + 8192}' )
|
||||
local imgfile="${OUTDIR}/${output_filename%.gz}"
|
||||
dd if=/dev/zero of="$imgfile" bs=1M count=$(( image_size / 1024 ))
|
||||
mformat -i "$imgfile" -N 0 ::
|
||||
mcopy -s -i "$imgfile" "$DESTDIR"/* "$DESTDIR"/.alpine-release ::
|
||||
local image_size=$(du -L -k -s "$DESTDIR" | awk '{print int(($1 + 8192) / 1024)}' )
|
||||
dd if=/dev/zero of="$imgfile" bs=1M count=$(( image_size > $MIN_IMG_SIZE ? image_size : $MIN_IMG_SIZE ))
|
||||
echo 'start=2048, type=6, bootable' | sfdisk "$imgfile" # create partition table with FAT16 at standard 2048 sector (1MB)
|
||||
mkfs.vfat -n PIBOOT -F 16 --offset 2048 "$imgfile"
|
||||
mcopy -s -i "$imgfile"@@2048s "$DESTDIR"/* "$DESTDIR"/.alpine-release ::
|
||||
echo "Compressing $imgfile..."
|
||||
pigz -v -f -9 "$imgfile" || gzip -f -9 "$imgfile"
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user