Continuing the discussion from Does this even work on a Raspberry Zero !?:
To create an ext2 partition using RPiOS 32bit Lite image; this works on a PiZ v1.3 (not W I used a dongle)
- Flash using Rasp Imager (setting Wi-Fi, SSH etc)
- In Windows, create a partition using the Disk Manager (size is irrelevant) in free space. [this prevents firstboot doing its expansion]
- Boot card in Pi.
- Do the following;
## delete additional partition
sudo parted /dev/mmcblk0 rm 3
## create a new partition at the end - the 20G is the start point for the end partition (rough guess)
## Can vary depending on size of card of course. For testing make it small so the mkfs doesn't take an age!!
echo "20G, +" | sudo sfdisk --force -N 3 /dev/mmcblk0
sudo partprobe
## Expand the root partition in the space available
echo ", +" | sudo sfdisk --force -N 2 /dev/mmcblk0
sudo partprobe
## resize the rootfs
sudo resize2fs /dev/mmcblk0p2
## Format the new partition
sudo mkfs.ext2 -b 1024 /dev/mmcblk0p3
## pull down the fstab as before
wget https://raw.githubusercontent.com/openenergymonitor/EmonScripts/stable/defaults/etc/fstab
sudo mv fstab /etc/fstab
sudo reboot now
And bingo. Thanks to @Bramco for the idea of creating a partition in the free space - inspired.
For the emonSD you can do all this and then use the sfdisk
commands to expand and fill. I’d do it as a separate script so it is clear the mkfs is running as it takes an age (as you know).
Instead of creating the ext2 from a fixed point, you could specify the size of the rootfs and then fill the remaining with the ext2. (only reference I found using sfdisk
this way Karel Zak's blog: resize by sfdisk)
Now to work out why the scripts are not quite running!
Useful commands to see what sizes are what
sudo fdisk -l /dev/mmcblk0*
sudo lsblk
sudo parted -l
sudo sfdisk -d /dev/mmcblk0