Skip to main content
2 of 2
Added example to copy the image.
bstipe
  • 564
  • 3
  • 5

I think that I have just learned an answer to your question, "Additionally, are there any other facilities for doing what I'm trying to do". On the Pi or Linux type of system, download the image (zip) file. Unzip it, if Raspbian there will be a 2017-04-10-raspbian-jessie.img file. Run sudo fdisk -l 2017-04-10-raspbian-jessie.img. The output should be like:

Disk jessie.img: 4 GiB, 4285005824 bytes, 8369152 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x402e4a57

Device      Boot Start     End Sectors Size Id Type
jessie.img1       8192   92159   83968  41M  c W95 FAT32 (LBA)
jessie.img2      92160 8369151 8276992   4G 83 Linux

You can mount these images files, see 'Mounting an image on the host' https://en.wikibooks.org/wiki/QEMU/Images#Mounting_an_image_on_the_host as loopback with offset. Make mount points and use the offset of sector size times start sector.

sudo mkdir /mnt/d1 /mnt/d2
sudo mount -o loop,offset="$((512 * 8192))" 2017-04-10-raspbian-jessie.img /mnt/d1
sudo mount -o loop,offset="$((512 * 92160))" 2017-04-10-raspbian-jessie.img /mnt/d2

Now you have access to both the boot and root filesystem images to configure, script, and modify as you choose. If you put a script in the boot filesystem, you also have to setup how to execute it from the root filesystem, may be in cron or other means.

Unmount sudo umount /mnt/d[12] and copy the image sudo dd bs-4M if=2017-04-10-raspbian-jessie.img of=/dev/sda if sda is the sd card. Install the sd card in Pi and power/boot up.

bstipe
  • 564
  • 3
  • 5