I'm experimenting with mounting the Raspbian .img and adding code/files and then repacking. The purpose of this is to be able to create custom distros for projects (rather than making clones of the SD cards using
I have got the .img file mounting based on this.
However, I very quickly run out of space on the partition (I think there is something like 400mb of free space out of the gate). And so i'd like to resize the partition.
I have tried a few things so far:
First, adding bits to the end of the file with
dd if=/dev/zeros bs=512k count=1000 >> 2018-06-27-raspbian-stretch-lite.img
and then running:
delete the old partition and create a new partition from the start of the original partition to the end (the end is now longer because the .img has been extended)
When I flash an SD card with this img I get a kernel panic.
I resize the .img file directly with:
qemu-img resize 2018-06-27-raspbian-stretch-lite.img 2.8G
This seems to work but when I make an SD card and run it on a PI, it says "resizing sd-card" the first time it boots.
This isn't too bad but I think in an ideal world I would have control over this process and understand it a little better.
EDIT: So, running this actually only extends the .img file size but did not give me more space when I mounted the disk img.
In my mind the
fdisk mechanism should work and/or is ideal and a better understanding of this process would be great!