NOOBs fails to resize partitions created with rpi-imager on very large (>64, <=400GB) SDXC cards. #589
Description
I found a bug in rpi-imager that affects very large SD cards.
In my particular setup, the smallest card that I have which works with rpi-imager v1.2 and NOOBS 3.4 is a 64GB PATRIOT U(1) Class 10 card.
I have 3 cards larger than 64GB, which ALL fail when using rpi-imager to erase & load NOOBS during the partition resizing phase after booting into the NOOBS installer.
I have narrowed this down to the 4MiB empty space that rpi-imager puts at the front of the SD card. For some reason, on very large SD cards, this causes a failure.
I have reproduced this with gparted and manual NOOBS copy to the SD card. I can confirm that 4MiB of empty space at the beginning of the SD card fails, however, if I format these very large cards with 1MiB of empty space (which is the minimum that gparted allows) then NOOBS can resize them just fine.
I'm not exactly sure why this is happening, since the error message NOOBS give doesn't exactly state a reason other than:
"Error resizing existing FAT partition
Error: Unable to satisfy all constraints on the partition."
However, I can confirm that the following cards all fail with the rpi-imager method, but they work fine if I format with gparted and only use 1MiB of empty space at the front of the card:
SanDisk Ultra 400GB U(1) A1
These card, however, still fail UNLESS I also shrink the partition to 375623 MiB, which is the size of the 400GB card (and why I chose such an arbitrary value):
PNY PRO Elite 512GB U(3) A2
SanDisk Extreme 1TB U(3) A2
I have more details about the steps I went through to figure this out over in the forums at:
https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=275772&p=1670957
It seems like large cards should not have the 4MiB of empty space at the start of the disk.
I can also confirm that on the 64GB card which works with 4MiB of empty space, ALSO works with 1MiB of empty space at the beginning of the disk.
Perhaps cards >= 64GB in size should be formatted to have 1MiB of empty space and no more than a 375623 MiB large fat32 partition?
I'm running some additional tests to determine where the maximum partition size for 512GB and 1TB cards is, and I'll report back.