Handle Partition Changes Embedded System
I have to update some outdated embedded systems. But the RAUC Update contains four partitions, while the old systems have only three partitions.
The additional Partition is at the start of the disk and I cannot flash the devices with an external Adapter.
What I have, is SSH access to the existing Linux on the device.
Could I change the partition table somehow from within the running system and thereby move the system partition?
Or could I somehow dd
the whole disk with a new image?
I just cannot get my head around this problem and I am not sure, if I am missing a good solution here.
I did something similar on an embedded system. What saved me was that the compressed image of the new disk (with all its partitions) was small enough to keep in memory.
What I did was to patch the initramfs to include a custom script. At boot, before mounting anything, it copied the (compressed) disk image into a ramfs filesystem, and decompressed it to dd of=/dev/<disk>
, completely overwriting everything, including new partitioning.
(I had to struggle a bit to retain certain files. In the end I did a tarball of what I wanted to retain, put this as well in the tmpfs, and untarred this onto the new filesystem. It’s working pretty well.)
I’m sure that there are prettier solutions, but this worked for me.
[Edited to add:]
Another option would be to add a small script in the initramfs that would pull in the disk image over network. You’d have to figure out IP settings etc without the benefit of the full system, which can be awkward. But I think that putting a script in the initramfs is probably your best option as it can run from ram, without mounting any disks, so that you can overwrite the lot.