Converting a live device to a robust dual rootfs device

30th Mar 2020

Have you ever wanted to robustly update a bunch of devices, but you can't because they're already in the field, and they are not configured for a robust dual root filesystem layout? Today, we are exploring converting live devices from stock single partition devices into robust dual partition devices.

There has been a thread Mender Hub about live migration of devices to the dual partition devices, but today we focus on a method that leverages Update Modules, which were not available when that post was written. Note that this is still highly experimental, and it has only been tested with Beaglebone Black so far. Still, the methods outlined are quite generic, and with adjustments it can be made to work on most boards.

The way it works is this. You start with a device that has a single root filesystem:

Device with single root filesystem

The problem is that you cannot make any changes to the partition table of a running system, much less to the partitions inside of it! So we need to get off the root filesystem somehow. What the module does is that it extracts a mini operating system on the device's RAM, and then switches over to running from there after shutting down all processes on the system. This gives it full access to the partition table and the raw partitions inside it:

Full access to partitions

From here we can make any modification we want, including moving, resizing and creating new partitions, which is exactly what we need. The Update Module proceeds by creating the standard Mender partition layout, and moving and resizing the existing partition to fit within it:

New partition layout

After this it switches off the root filesystem partition B, and then reboots the system. It should now be back in a state where it looks more or less exactly like before, except it now runs with a Mender partition layout:

Running new partition layout

This looks cool, but what about trying it yourself? As mentioned before, this has only been tested on Beaglebone Black, so you will need one of those if you expect things to work out of the box. Head over to the Dual Rootfs Partitioner Update Module on Mender Hub to find instructions!

If you want to experiment with your own board, then you may consider going directly to the Update Module repository to learn more about how it works internally.