Resizing rootfs on a live system

Hi Mender team,
Is there a well-supported way to resize the data partitions on an existing Mender device? I am choosing the rootfs size for a new device, but I expect the software to grow over time, and we may need to change the partition size over time.

If growfs option is configured and the data partition is the last parition then its should grow to fill the remaining space of your drive if any exists.

https://docs.mender.io/system-updates-debian-family/variables#mender_data_part_growfs

@mho can you please clarify which partition you would like to resize?
You mentioned both the rootfs partition(s) as well as the data partition. Easiest would be to change the /data partition. This can be done as explained in the discussion linked by @dellgreen .
If you really need to resize the rootfs partition it will be a lot more complicated as you would need to

  1. backup /data and second rootfs partitions’ data
  2. delete /data partition
  3. delete second rootfs partition
  4. enlarge the first rootfs partition
  5. create a new seconds rootfs partition
  6. create a new /data partition
  7. copy data from first (enlarged) rootfs partition to second rootfs partition
  8. copy data from backup to /data partition
  9. make sure that grub is aware of the updated partition IDs or set the new partition IDs to the same as they were before.
  10. Test grub is actually able to boot the partitions.

Best option is to plan ahead with enough space on the rootfs partitions if you need to update it later or store application data on the /data partition

1 Like

Sorry for the confusion. I want to be able to resize the rootfs as well as the data partition as described by @bajo. I’m deciding the size of my rootfs and data partitions now, but once our devices are deployed, I was wondering how difficult it would be to change our minds on the rootfs/data partition allocations. It sounds like it’s difficult, but possible.

A few questions:
For #0, why do we need to backup the second rootfs partition? Shouldn’t the first rootfs partition be enough, assuming there are no outstanding uncommited writes?
For #6 why do we need to copy the first rootfs partition to the second? Wouldn’t the next update handle that for you?

I feel like built-in support for repartitioning would be a really useful feature for Mender - even if you plan ahead, sometimes things change, and there’s a need to udpate devices in the field.

@mho Regarding your questions. I’m also a new user to mender, so my backup remarks in #0 come from my general experience on doing major changes to any system. :sweat_smile:
For #6, I assume a full system update would write this. So no need to manually do it here.

It is technically possible to change partition sizes once deployed but it is not possible to do so in a completely power-safe manner. If you are manipulating the partition tables at the exact time the power goes out, in most cases you will end up with a bricked device. Because of this, it’s not a built-in feature of Mender, and unlikely to ever be one. You can certainly hack something together to change things but it will be tricky.

Drew

@drewmoseley thanks for the context, that’s probably true. I guess if we wanted something more flexible, there’s the LVM update module as well, even though it’s not well supported on devices.