[parted-devel] [PATCH v2] Set Disk And Partition UUID on GPT
Brian C. Lane
bcl at redhat.com
Mon Nov 16 23:51:50 GMT 2026
On Fri, Nov 13, 2026 at 12:02:33PM +0100, Arvin Schnell wrote:
>
> Hi,
>
> this version of the patch adds a check in parted/ui.c to map the
> command "u" to "unit" to keep compatibility (in the non-interactive
> mode).
>
> Kind Regards,
> Arvin
Thanks! Could you do a few more things? Comments inline.
Could you split the disk uuid and partition uuid commands into separate
commits? I know they're very similar but having distinct commits for new
features is nice.
> diff --git a/NEWS b/NEWS
> index c359221..bb94c24 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -2,6 +2,9 @@ GNU parted NEWS -*- outline -*-
>
> * Noteworthy changes in release ?.? (????-??-??) [?]
>
> +** New Features
> +
> + Add disk_uuid and uuid commands to set disk and partition UUIDs on GPT.
>
> * Noteworthy changes in release 3.8 (2026-09-23) [stable]
>
Drop the NEWs change, I'll do that at release time. Or you can do it as
a separate commit. Touching NEWS in a commit makes it hard to mix and
match backported changes.
> diff --git a/parted/parted.c b/parted/parted.c
> index f86619f..225111e 100644
> --- a/parted/parted.c
> +++ b/parted/parted.c
> +static int
> +do_uuid (PedDevice** dev, PedDisk** diskp)
> +{
Could we call this do_partition_uuid? Since the other is do_disk_uuid I
think it makes it clearer.
> + if (!*diskp)
> + *diskp = ped_disk_new (*dev);
> + if (!*diskp)
> + goto error;
> +
> + if (!ped_disk_type_check_feature((*diskp)->type, PED_DISK_TYPE_PARTITION_UUID)) {
> + ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
> + _("%s disk labels do not support partition uuid."),
> + (*diskp)->type->name);
Some tabs snuck in instead of spaces.
> + if (!part_uuid)
> + goto error;
And a couple more tabs on these two lines.
> +static int
> +do_disk_uuid(PedDevice** dev, PedDisk** diskp)
> +{
> + if (!*diskp)
> + *diskp = ped_disk_new (*dev);
> + if (!*diskp)
> + goto error;
> +
> + if (!ped_disk_type_check_feature((*diskp)->type, PED_DISK_TYPE_DISK_UUID)) {
> + ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
> + _("%s disk labels do not support disk uuid."),
> + (*diskp)->type->name);
More sneaky tabs here.
> + if (!disk_uuid)
> + goto error;
And two more.
> diff --git a/tests/t0920-uuid-gpt.sh b/tests/t0920-uuid-gpt.sh
> new file mode 100755
> index 0000000..88ef8e0
> --- /dev/null
> +++ b/tests/t0920-uuid-gpt.sh
> @@ -0,0 +1,92 @@
> +# Force 512-byte sector size for this test
> +export PARTED_SECTOR_SIZE=512
> +sector_size_=512
Use 'require_512_byte_sector_size_' instead so that it only runs for the
512b test.
> diff --git a/tests/t0921-uuid-gpt-reproducible.sh b/tests/t0921-uuid-gpt-reproducible.sh
> new file mode 100755
> index 0000000..371407d
> --- /dev/null
> +++ b/tests/t0921-uuid-gpt-reproducible.sh
> @@ -0,0 +1,46 @@
> +# Force 512-byte sector size for this test
> +export PARTED_SECTOR_SIZE=512
> +sector_size_=512
Use 'require_512_byte_sector_size_' here too.
> +dev=dev.img
Use 'dev=loop-file' here for consistency with the other test.
The last thing to point out to everyone is that in interactive mode 'u'
now has two meanings so you can no longer use it as a shortcut. I think
this is probably fine and is consistent with the other interactive mode
behavior. I was mostly concerned with the non-interactive case making
everyone's parted scripts mysteriously fail.
Brian
--
Brian C. Lane (PST8PDT) - weldr.io - lorax - parted - pykickstart - osbuild
More information about the parted-devel
mailing list