I am trying to create a third FAT32 partition on the SD card that consumes the free space on the card not used by the image. I want this instead of the root partition being resized.
Creating the partition works, and fsck shows no problems with any partition and the other two partitions are untouched.
The procedure I am using:
sudo dd if=2017-03-02raspbian-jessie.img of=/dev/sdd BS=1M
Code to automate creating a partition using the free space:
parted -m /dev/sdd print free
/dev/sdd:62.9GB:scsi:512:512:msdos:>TS-RDF5 SD Transcend;
Parse to find the line 6 which is always the free space on a new dd of the image, which is:
Get the start location and end location columns (columns 2 and 3):
Then create the partition and file system:
parted -m /dev/sdd mkpart primary 6226MB 62.9GB mkdosfs -F 32 /dev/sdd3
Then I copy over a cmdline.txt file which changes:
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=798cce24-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh
dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
Without changing the root=, the pi just sits on a black screen with the logo in the upper left corner. Adding this line, it gets further than that but fails to mount rootfs.
[FAILED] Failed to start Remount Root and Kernel File System
[FAILED] Fao;ed tp start Various fixups to make sysmted work better on debian
And some other failures.. ending up booted into an "Emergency mode" prompt.
If I dd the image over, let it run the init_resize script, then shrink the fs back down, add the new fs ... it works...
Doing it this way, I don't even need to change the cmdline.txt file to point to /dev/mmcblk0p2..
What am I missing here?
I have to be able to add the partition before the first boot in an automated way.