Hi Hamish,
On 27.11.23 16:50, Hamish Guthrie wrote:
>
> Hi Philippe,
>
>
>
>
>> To avoid this issue, you may use the property "noinuse" :
>>
https://sbabic.github.io/swupdate/handlers.html#disk-partitioner
>>
>> noinuse
>> string
>> “true” or “false” (default=false) If set, it does not require the device to be not in use (mounted, etc.)
>
> I had tried setting the noinuse flag as per the documentation where it describes properties for the diskpart handler (i.e. in the partitions: section of the sw-description file).
These properties are in common between diskpart and gptswap. In your
case, you should set them to gptswap handler, else they have no effect.
> I then added some debug code to the diskpart_handler and in the gpt_swap_function, the value of that flag is reported as being false. I then added those properties to the properties section of the gptswap script and now it works as follows:
>
> scripts: (
> {
> type = "gptswap";
> device = "/dev/mmcblk0";
> properties = {
> nolock = "true";
> noinuse = "true";
> swap-0 = [ "rootfs", "rootfs_r" ];
> };
> },
>
> So I have now managed to get it to work, but the documentation I believe could be extended to point this out. Would you like me to extend the documentation to reflect this?
Any attempt to make documentation clearer is well accepted ;-)
>
> There is another issue, however, and maybe you could assist me with this:
>
> In the partitions section of my sw-description file, I define the partitions on my eMMC, but once I have updated the device, and I attempt to do a second update, the partition table is re-written because the names of the partitions are incorrect,
...well, yes, it is expected, you are changing the table with the swap....
> so in my sw-description file I have:
>
> partitions: (
> {
> type = "diskpart";
> device = "/dev/mmcblk0"
> properties: {
> labeltype = "gpt";
> nolock = "true";
> noinuse = "true";
> partition-1 = [ "size=256M", "start=2048", "name=rootfs",
> "type=B921B045-1DF0-41C3-AF44-4C6F280D3FAE"];
> partition-2 = [ "size=256M", "start=526336", "name=rootfs_r",
> "type=B921B045-1DF0-41C3-AF44-4C6F280D3FAE"];
> partition-3 = [ "size=256M", "start=1050624", "name=data",
> "type=0FC63DAF-8483-4772-8E79-3D69D8477DE4"];
> }
> }
> );
>
Nevertheless, this does not work always. Think about you do not change
the label, but you want to change the size of the partitions. And you
have mounted rootfs on one of that. It does not work. Think like you
shrink partition and then install a new rootfs, damaging where you are
running.
It is common to create the partitions during first system deploying - at
that time, eMMC is empty. You should add partitions when "rescue" (aka a
swupdate running on a ramdisk) is running, not during production.
Of course, it is still possible to change partitions on the field, but a
migration should be designed to avoid to damage where you are running.
In your case, you are "damaging", because you overwrite the label - but
from SWupdate's point of view, this is as changing size, start address,
whatever...
> So during the first update of the device,
First update means first deployment with empty eMMC, you should then
have a case in your sw-description to distinguish from an update in
field, and you shouln't have the partitions during update in field but
just gptswap.
> the new root filesystem image is installed in partition 2 which is named rootfs_r, which is what I would expect, and then the gptswap does it's magic and now on my device, partition 1 is now named rootfs_r and partition 2 is now named rootfs. Now if I do another update, the partitions in the sw-description file are different to the partitions in my device and the partitioning handler swaps them back again, and I am not sure how best to handle this.
> Is it an invalid use-case to attempt to provide the partition table layout in the sw-description file?
It is invalid when you rely on the partitions itself, as in your case.
>
> Would you by any chance have an example of a sw-description file available which illustrates how you handle this?
You should set partitions just in rescue, it is the only case where it
makes sense.
Best regards.,
Stefano