[Beware this may not reflect the current mechanism as it is some years old.]
There is a two part mechanism which takes responsibility for this on Raspbian; likely the best idea is to take care of both parts if they are enabled.
The first is that the original
/boot/cmdline.txt includes this:
Referring to a script with that path on the root partition, which will be used as the init process at boot. Without that bit, it would default to a value built into the kernel,
/sbin/init, which on Raspbian is a symbolic link to
By removing that portion of
cmdline.txt, the system should then boot normally.
What that script actually does is resize the partition on the SD card. This is a distinct process from resizing the filesystem in the partition,1 which is what happens next.
The way that happens is the system is immediately rebooted normally (that is, via systemd) and an
init.d script is set to trigger early on, which should be removed from the second partition:
And the symbolic link to it, which should also be removed:
You can keep a copy for later use if you want, but
raspi-config can create it again for you (it's embedded in the
raspi-config shell script). If it actually runs, it deletes itself, so it will not happen again.
What it also does is resize the filesystem in the newly resized partition.
No harm should be done if just one or the other part happens; in the first case you end up with a filesystem that doesn't fill the enlarged partition, in the second nothing will happen, because the filesystem already fills the partition.
If you later use
raspi-config to enlarge the filesystem, it does the partition resize right away, then sets up the init script (as already mentioned).
cmdline.txt on the first partition is simple on any computer since it is a VFAT partition. Removing the
init.d file requires a system that can access and edit ext4 filesystems.
Both tasks can instead be done to the image file itself prior to burning the card; to mount and modify a Raspbian image on a GNU/Linux system, see here. There is a parallel Q&A for Windows.
This is also reversible, but you'll need to put back both parts of the mechanism as just described, since the first one does not include automatically staging the second one.
- Although an error message from that script arguably confuses those terms by claiming it failed to resize the root filesystem, when what it really failed to do is resize the partition on which the root filesystem resides. Doing one does not automatically accomplish the other.
raspi-configis run at first boot, and would be easy to disable. I can have a look but I'll have to download a new image, the last one I have is from May. Check back in few hours.