Preventing root partition resizing

I’m trying to install DietPi onto a Pi CM4 that’s got an attached SSD card. I’m doing a “Make your own distribution” install so the CM4 has Raspberry PI OS Lite installed first. As part of that original install I create a 64GB root partition on the SSD and migrate rootFS across to it. This is working well and there’s space left on the SSD for me to use for other partitions later on.

However, when I run the DietPi installer it automatically resizes the root partition to fill the entire SSD. I don’t need a rootFS that’s nearly 1TB though. Is there a way to prevent this automatic resizing during the install, i.e. rootFS just keeps the 64GB partition that it’s already in?

So the script creates a service dietpi-fs_partition_resize.service, which will enlarge the filesystem to max size at first boot, unless it finds a file /dietpi_skip_partition_resize in your root directory, then it will skip the resize. It will also disable itself (the service) on first execution.

So after the conversion scripts is finished and before the device reboots you would need to mount the disk on another linux machine and create the file dietpi_skip_partition_resize in the root directory.

touch  /dietpi_skip_partition_resize

But I don’t know if this comes with some side effect, but @MichaIng will know.

1 Like

Thanks. I can try that later this evening. The Pi is initially set up using Pi OS so I can create the file before I run the DietPi installer script.

You can also “disable” the service, i.e. remove /etc/systemd/system/local-fs.target.wants/dietpi-fs_partition_resize.service or run systemctl disable dietpi-fs_partition_resize right after dietpi-installer (before shutting down).

Another idea would be to create the tailing partition(s) right away. Btw, what is the reason for creating additional partitions instead of just using the a larger rootfs? I found barely any use case where it would make sense to have multiple partitions on a single drive/card, unless of course it is required for booting, like EFI or FAT partition on RPi.

And of course, you can also shrink the rootfs and partition afterwards, when you mount attach the card on another system, at the time when you want to create other tailing partitions.

1 Like

I want to create some Longhorn storage and it’s recommended to put that on a separate partition rather than on the root partition.

The disks are built into a case so removing them to adjust partition sizes on another computer is more than just plug and play. That’s why I want to try do this all from the Pi in situ in it’s slot on the cluster board with the storage attached to the board.

Edit: I’ve tried creating the extra partitions first but for some reason I can’t get the Pi to boot when there’s a formatted but empty partition on the SSD. I’m still trying to debug that but being able to stop resizing means I can go with a process that I know works (apart from the resizing).

Makes sense. I guess this is a case which benefits from Btrfs or similar filesystem features, instead of ext4.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.