#!/bin/bash +ex dd if=/dev/zero of=build/rpi.img bs=1M count=4096 # Copy the first 8k from the original rpi.img, which seems to have # non-zeroed content #dd if=rpi.img of=build/rpi.img bs=8192 count=1 conv=notrunc sudo losetup -Pf build/rpi.img # Partition: # start: 8192, size 256M typ W95 FAT32 DEVICE=$(losetup -j build/rpi.img | cut -d ':' -f 1) mkfs.msdos "${DEVICE}" sfdisk "${DEVICE}" <