0

I'd like to limit the amount of space used in the SD card because after flashing the RPi I will migrate the boot to an SDD, and the SDD has limited space - so I need to restrict the amount that will be cloned later.

However, although I have created partitions in the SD card, whenever it installs a system, it uses the entire SD card. I can't find a way to direct it to a single partition only.

Thx!

4
  • 2
    It’s not usually the flashing process that fills the sd card but the first boot of the OS that expands the partition. I believe this can be disabled, check the Pi Imager advanced options.
    – CoderMike
    Sep 4, 2023 at 18:13
  • I've just checked and I cannot see any similar option. Thanks anyway!
    – 42piratas
    Sep 4, 2023 at 19:02
  • 1
    If you use rsync it doesn't copy the whole sdcard, just the used files.
    – Dougie
    Sep 4, 2023 at 20:32
  • 1
    Another suggestion, after flashing create another partition to avoid first boot filling entire space forums.raspberrypi.com/viewtopic.php?t=313003#p1906045
    – CoderMike
    Sep 4, 2023 at 21:34

2 Answers 2

1

RPi imager creates at least two partitions. A small boot partition formatted with FAT and a large Linux partition formatted with ext4.

The Linux partition is normally expanded after first boot to use all space remaining on the SD card. I thought that could be disabled by running raspi-config at first boot.

If you can't stop expansion then just use a partition shrinker such as GParted.

1

Any imaging tool overwrites the partition table and erases any partition or structure which may exist - although it will leave unallocated space.

The partition is expanded on first boot by the Pi itself not by the imager.

The exact mechanism used by Raspberry Pi Ltd. has changed in the last couple of years and I don't remember the details BUT if you examine the cmdline.txt file before booting the Pi you will see at the end a script that is run once and later deleted.

You could delete this BUT the current first boot also creates the user (it probably modifies pi) so the image may be unusable (until the very small root partition is expanded there is insufficient space to run effectively).

You could examine /usr/lib/raspberrypi-sys-mods/firstboot and modify it but it is likely to be easier to shrink the newly created root partition, which is simple on any Linux system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.