Repartition partitions on "active" disk

22 views
Skip to first unread message

Christian Schaefer

unread,
Aug 25, 2026, 2:08:43 AM (yesterday) Aug 25
to swup...@googlegroups.com
Hello everyone,

I have an A/B system and would like to know if it is possible to modify partitions which are on the same disk as the root partition before an update.

For instance, the layout would be as follows:

$ lsblk -o NAME,PARTLABEL,SIZE,TYPE,MOUNTPOINTS
NAME PARTLABEL SIZE TYPE MOUNTPOINTS
nvme0n1 55.9G disk
|-nvme0n1p1 boot 32M part /mnt/boot
|-nvme0n1p2 root-a 4G part /
|-nvme0n1p3 root-b 4G part
`-nvme0n1p4 data 47.9G part /data

The active partition is "root-a".
With the next update, I would like to:

- wipe & split the "data" partition into two, e.g:
- "data-a": 32M
- "data-b": 32M
- write the new update image to "root-b"

In my sw-description I have described the new partitioning as follows:

partitions": {
"type": "diskpart",
"device": "/dev/nvme0n1",
"properties": {
"labeltype": "gpt",
"noinuse": "true",
"nolock": "true",
"partition-1": [
"size=32M",
"name=boot",
"start=2048",
"type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B",
"fstype=vfat",
"flags=boot"
],
"partition-2": [
"size=4096M",
"name=root-a",
"start=67584",
"type=0FC63DAF-8483-4772-8E79-3D69D8477DE4",
"fstype=ext4"
],
"partition-3": [
"size=4096M",
"name=root-b",
"start=8456192",
"type=0FC63DAF-8483-4772-8E79-3D69D8477DE4",
"fstype=ext4"
],
"partition-4": [
"size=32M",
"name=data-a",
"start=16844800",
"type=0FC63DAF-8483-4772-8E79-3D69D8477DE4",
"fstype=ext4",
"force=true"
],
"partition-5": [
"size=32M",
"name=data-b",
"start=16910336",
"type=0FC63DAF-8483-4772-8E79-3D69D8477DE4",
"fstype=ext4",
"force=true"
]
}
},

However, when running swupdate, I get this error:

[TRACE] : SWUPDATE running : [install_single_image] : Found installer for stream diskpart
[TRACE] : SWUPDATE running : [diskpart] : Force flag explicitly mentioned, value 1
[TRACE] : SWUPDATE running : [diskpart] : partition-5:data-b size 33554432 start 16910336 type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 partuuid automatic
[TRACE] : SWUPDATE running : [diskpart] : Force flag explicitly mentioned, value 1
[TRACE] : SWUPDATE running : [diskpart] : partition-4:data-a size 33554432 start 16844800 type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 partuuid automatic
[TRACE] : SWUPDATE running : [diskpart] : partition-3:root-b size 4294967296 start 8456192 type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 partuuid automatic
[TRACE] : SWUPDATE running : [diskpart] : partition-2:root-a size 4294967296 start 67584 type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 partuuid automatic
[TRACE] : SWUPDATE running : [diskpart] : partition-1:boot size 33554432 start 2048 type C12A7328-F81F-11D2-BA4B-00A0C93EC93B partuuid automatic
[TRACE] : SWUPDATE running : [diskpart_table_cmp] : Number of partitions differs on disk: 4 <--> requested: 5
[TRACE] : SWUPDATE running : [diskpart_write_table] : Partitions on disk differ, write to disk;
[WARN ] : SWUPDATE running : [diskpart_blkdev_lock] : /dev/nvme0n1: device is in use, force set
[TRACE] : SWUPDATE running : [install_single_image] : Installer for diskpart not successful !
[ERROR] : SWUPDATE failed [1] Installation failed !

Obviously I don't want to modify the active root partition during the update.
But, regarding the change on the "data" partition, can I even modify it with swupdate, if it is on the same disk as my "active" rootfs?
How would one go about such a scenario?

Thanks & BR,
Christian

Stefano Babic

unread,
Aug 25, 2026, 3:52:55 AM (yesterday) Aug 25
to Christian Schaefer, swup...@googlegroups.com
Hi Christian,

On 8/25/26 07:55, 'Christian Schaefer' via swupdate wrote:
> Hello everyone,
>
> I have an A/B system and would like to know if it is possible to modify partitions which are on the same disk as the root partition before an update.
>

During an update..
First at all, do not rely on the value provided by df / lsblk. They gave
you values for humans. If the untouched partitions do not have exactly
the same start / end, they will be broken.

So gets the exact number of sectors, for example with "sfdisk -d
/dev/nvme0n1", and add in the description both start and size. Do not
add fstype for that partition: fstype is thought to format the
partition. Be sure to use also the same labels (I think you already did).

> However, when running swupdate, I get this error:
>
> [TRACE] : SWUPDATE running : [install_single_image] : Found installer for stream diskpart
> [TRACE] : SWUPDATE running : [diskpart] : Force flag explicitly mentioned, value 1
> [TRACE] : SWUPDATE running : [diskpart] : partition-5:data-b size 33554432 start 16910336 type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 partuuid automatic
> [TRACE] : SWUPDATE running : [diskpart] : Force flag explicitly mentioned, value 1
> [TRACE] : SWUPDATE running : [diskpart] : partition-4:data-a size 33554432 start 16844800 type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 partuuid automatic
> [TRACE] : SWUPDATE running : [diskpart] : partition-3:root-b size 4294967296 start 8456192 type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 partuuid automatic
> [TRACE] : SWUPDATE running : [diskpart] : partition-2:root-a size 4294967296 start 67584 type 0FC63DAF-8483-4772-8E79-3D69D8477DE4 partuuid automatic
> [TRACE] : SWUPDATE running : [diskpart] : partition-1:boot size 33554432 start 2048 type C12A7328-F81F-11D2-BA4B-00A0C93EC93B partuuid automatic
> [TRACE] : SWUPDATE running : [diskpart_table_cmp] : Number of partitions differs on disk: 4 <--> requested: 5
> [TRACE] : SWUPDATE running : [diskpart_write_table] : Partitions on disk differ, write to disk;
> [WARN ] : SWUPDATE running : [diskpart_blkdev_lock] : /dev/nvme0n1: device is in use, force set
> [TRACE] : SWUPDATE running : [install_single_image] : Installer for diskpart not successful !
> [ERROR] : SWUPDATE failed [1] Installation failed !
>
> Obviously I don't want to modify the active root partition during the update.
> But, regarding the change on the "data" partition, can I even modify it with swupdate, if it is on the same disk as my "active" rootfs?

SWUpdate does not modify directly the raw disk, but it uses the libfdisk
library, that is thought to manage partitions. The library has also for
GPT a mechanism to safe update the tables and be power-cut safe.

Anyway, the library makes also some strong checks to avoid that a user
(even root) destroys the disk. There is a flag to set "noinuse" and
"nolock". SWUpdate can set these flags before calling libfdisk.

You can:
"partition-4": [
"size=32M",
"name=data-a",
"start=16844800",
"type=0FC63DAF-8483-4772-8E79-3D69D8477DE4",
"fstype=ext4",
"force=true",

"nolock=true",
"noinuse=true"
],

This avoids most checks from libfdisk, but the call can still be
rejected if something opened is found.

> How would one go about such a scenario?

The best way to do this is to add a migration step. We all know that
changing the partitions on a running system is dangerous.

I have in most cases an A/B + rescue system. In such cases, the update
triggers the rescue and system restarts in rescue mode - this is a
ramdisk. This gives me plenty of power, because I can completely rewrite
the disk, including the root partitions. And of course, the ramdisk has
not mounted the disk at all, then there is no block from libfdisk and /
or kernel.

Best regards,
Stefano Babic


--
_______________________________________________________________________
Nabla Software Engineering GmbH
Hirschstr. 111A | 86156 Augsburg | Tel: +49 821 45592596
Geschäftsführer : Stefano Babic | HRB 40522 Augsburg
E-Mail: sba...@nabladev.com

Christian Schaefer

unread,
Aug 25, 2026, 10:26:12 AM (yesterday) Aug 25
to Stefano Babic, swup...@googlegroups.com
Hi Stefan,

thanks for the explanation and the hint to get the exact sector numbers with "sfdisk -d /dev/nvme0n1".
I too think using a rescue system is definitely the safer option with fewer headaches; will do that :)

BR, Christian


________________________________________
From: Stefano Babic <stefan...@swupdate.org>
Sent: Tuesday, August 25, 2026 09:52
To: Christian Schaefer <christian...@at.abb.com>; swup...@googlegroups.com <swup...@googlegroups.com>
Subject: Re: [swupdate] Repartition partitions on "active" disk

Reply all
Reply to author
Forward
0 new messages