[parted-devel] [PATCH v2] Set Disk And Partition UUID on GPT

Arvin Schnell aschnell at suse.de
Fri Nov 13 11:02:33 GMT 2026


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

---
 NEWS                                 |   3 +
 doc/C/parted.8                       |   8 ++
 doc/parted.texi                      |  40 +++++++++
 include/parted/disk.in.h             |   6 ++
 libparted/disk.c                     |  34 ++++++++
 libparted/labels/gpt.c               |  40 +++++++++
 parted/command.c                     |   2 +-
 parted/command.h                     |   2 +-
 parted/parted.c                      | 125 ++++++++++++++++++++++++++-
 parted/ui.c                          |   3 +-
 tests/Makefile.am                    |   2 +
 tests/t0920-uuid-gpt.sh              |  92 ++++++++++++++++++++
 tests/t0921-uuid-gpt-reproducible.sh |  46 ++++++++++
 13 files changed, 399 insertions(+), 4 deletions(-)
 create mode 100755 tests/t0920-uuid-gpt.sh
 create mode 100755 tests/t0921-uuid-gpt-reproducible.sh

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]
 
diff --git a/doc/C/parted.8 b/doc/C/parted.8
index 40e6212..42f2d75 100644
--- a/doc/C/parted.8
+++ b/doc/C/parted.8
@@ -138,6 +138,10 @@ On MS-DOS set the type aka. partition id of \fIpartition\fP to
 \fIid\fP. The \fIid\fP is a value between "0x01" and "0xff". On GPT
 the type-uuid of \fIpartition\fP to \fIuuid\fP.
 .TP
+.B uuid \fIpartition\fP \fIuuid\fP
+Set the UUID of \fIpartition\fP to \fIuuid\fP. This will only work if
+the disk label supports it (currently GPT).
+.TP
 .B disk_set \fIflag\fP \fIstate\fP
 Change a \fIflag\fP on the disk to \fIstate\fP. A flag can be either "on" or
 "off".  Some or all of these flags will be available, depending on what disk
@@ -147,6 +151,10 @@ boot flag on the GPT's protective MBR partition.
 .B disk_toggle \fIflag\fP
 Toggle the state of the disk \fIflag\fP.
 .TP
+.B disk_uuid \fIuuid\fP
+Set the UUID of the disk to \fIuuid\fP. This will only work if the disk
+label supports it (currently GPT).
+.TP
 .B version
 Display version information and a copyright message.
 .RE
diff --git a/doc/parted.texi b/doc/parted.texi
index 10a576b..77bef26 100644
--- a/doc/parted.texi
+++ b/doc/parted.texi
@@ -454,6 +454,7 @@ GNU Parted provides the following commands:
 * align-check::
 * disk_set::
 * disk_toggle::
+* disk_uuid::
 * help::
 * mklabel::
 * mkpart::
@@ -468,6 +469,7 @@ GNU Parted provides the following commands:
 * toggle::
 * type::
 * unit::
+* uuid::
 @end menu
 
 Note that after version 2.4, the following commands were removed:
@@ -540,6 +542,25 @@ Set the PMBR's boot flag.
 Toggle the state of the disk flag.
 @end deffn
 
+ at node disk_uuid
+ at subsection disk_uuid
+ at cindex disk_uuid, command description
+ at cindex command description, disk_uuid
+
+ at deffn Command disk_uuid @var{uuid}
+
+Set the UUID of the disk to @var{uuid}. This will only work if the disk
+label supports it (currently GPT). The @var{uuid} is a 36-character string in
+standard UUID format.
+
+Example:
+
+ at example
+(parted) @kbd{disk_uuid 12345678-abcd-1234-abcd-1234567890ab}
+ at end example
+
+ at end deffn
+
 @node help
 @subsection help
 @cindex help, command description
@@ -1182,6 +1203,25 @@ Number  Start   End     Size    Type      File system  Flags
 
 @end deffn
 
+ at node uuid
+ at subsection uuid
+ at cindex uuid, command description
+ at cindex command description, uuid
+
+ at deffn Command uuid @var{number} @var{uuid}
+
+Set the UUID of partition @var{number} to @var{uuid}. This will only work
+if the disk label supports it (currently GPT). The @var{uuid} is a
+36-character string in standard UUID format.
+
+Example:
+
+ at example
+(parted) @kbd{uuid 1 12345678-abcd-1234-abcd-1234567890ab}
+ at end example
+
+ at end deffn
+
 @node Related information
 @chapter Related information
 @cindex further reading
diff --git a/include/parted/disk.in.h b/include/parted/disk.in.h
index e2ee7ca..789ddfb 100644
--- a/include/parted/disk.in.h
+++ b/include/parted/disk.in.h
@@ -231,7 +231,10 @@ struct _PedDiskOps {
         int (*disk_is_flag_available) (
                 const PedDisk *disk,
                 PedDiskFlag flag);
+
+        int (*disk_set_uuid) (PedDisk* disk, const uint8_t* uuid);
         uint8_t* (*disk_get_uuid) (const PedDisk* disk);
+
         /** \todo add label guessing op here */
 
         /* partition operations */
@@ -264,6 +267,7 @@ struct _PedDiskOps {
         int (*partition_set_type_uuid) (PedPartition* part, const uint8_t* uuid);
         uint8_t* (*partition_get_type_uuid) (const PedPartition* part);
 
+        int (*partition_set_uuid) (PedPartition* part, const uint8_t* uuid);
         uint8_t* (*partition_get_uuid) (const PedPartition* part);
 
         int (*partition_align) (PedPartition* part,
@@ -337,6 +341,7 @@ extern int ped_disk_set_flag(PedDisk *disk, PedDiskFlag flag, int state);
 extern int ped_disk_get_flag(const PedDisk *disk, PedDiskFlag flag);
 extern int ped_disk_is_flag_available(const PedDisk *disk, PedDiskFlag flag);
 
+extern int ped_disk_set_uuid (PedDisk* disk, const uint8_t* uuid);
 extern uint8_t* ped_disk_get_uuid (const PedDisk* disk);
 
 extern const char *ped_disk_flag_get_name(PedDiskFlag flag);
@@ -375,6 +380,7 @@ extern uint8_t ped_partition_get_type_id (const PedPartition* part);
 extern int ped_partition_set_type_uuid (PedPartition* part, const uint8_t* uuid);
 extern uint8_t* ped_partition_get_type_uuid (const PedPartition* part);
 
+extern int ped_partition_set_uuid (PedPartition* part, const uint8_t* uuid);
 extern uint8_t* ped_partition_get_uuid (const PedPartition* part);
 
 extern int ped_partition_is_busy (const PedPartition* part);
diff --git a/libparted/disk.c b/libparted/disk.c
index f1da6c4..e0cf3d9 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -906,6 +906,22 @@ _assert_disk_uuid_feature (const PedDiskType* disk_type)
         return 1;
 }
 
+/**
+ * Set the uuid of the disk \p disk. This will only work if the disk label
+ * supports it.
+ */
+int
+ped_disk_set_uuid (PedDisk *disk, const uint8_t* uuid)
+{
+        PED_ASSERT (disk != NULL);
+
+        if (!_assert_disk_uuid_feature (disk->type))
+                return 0;
+
+        PED_ASSERT (disk->type->ops->disk_set_uuid != NULL);
+        return disk->type->ops->disk_set_uuid (disk, uuid);
+}
+
 /**
  * Get the uuid of the disk \p disk. This will only work if the disk label
  * supports it.
@@ -1663,6 +1679,24 @@ ped_partition_get_type_uuid (const PedPartition *part)
         return part->disk->type->ops->partition_get_type_uuid (part);
 }
 
+/**
+ * Set the part-uuid of the partition \p part. This will only work if the disk label
+ * supports it.
+ */
+int
+ped_partition_set_uuid (PedPartition *part, const uint8_t* uuid)
+{
+        PED_ASSERT (part != NULL);
+        PED_ASSERT (part->disk != NULL);
+        PED_ASSERT (ped_partition_is_active (part));
+
+        if (!_assert_partition_uuid_feature (part->disk->type))
+                return 0;
+
+        PED_ASSERT (part->disk->type->ops->partition_set_uuid != NULL);
+        return part->disk->type->ops->partition_set_uuid (part, uuid);
+}
+
 /**
  * Get the uuid of the partition \p part. This will only work if the disk label
  * supports it.
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 5a48b9b..d63482f 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -1578,6 +1578,25 @@ gpt_disk_is_flag_available(const PedDisk *disk, PedDiskFlag flag)
     }
 }
 
+
+static int
+gpt_disk_set_uuid (PedDisk *disk, const uint8_t *uuid)
+{
+  GPTDiskData *gpt_disk_data = disk->disk_specific;
+
+  efi_guid_t* disk_uuid = &gpt_disk_data->uuid;
+  memcpy(disk_uuid, uuid, sizeof (efi_guid_t));
+
+  /* disk_uuid is always LE, while uint8_t is always kind of BE */
+
+  disk_uuid->time_low = PED_SWAP32(disk_uuid->time_low);
+  disk_uuid->time_mid = PED_SWAP16(disk_uuid->time_mid);
+  disk_uuid->time_hi_and_version = PED_SWAP16(disk_uuid->time_hi_and_version);
+
+  return 1;
+}
+
+
 static uint8_t*
 gpt_disk_get_uuid (const PedDisk *disk)
 {
@@ -1790,6 +1809,25 @@ gpt_partition_get_type_uuid (const PedPartition *part)
   return buf;
 }
 
+
+static int
+gpt_partition_set_uuid (PedPartition *part, const uint8_t *uuid)
+{
+  GPTPartitionData *gpt_part_data = part->disk_specific;
+
+  efi_guid_t* part_uuid = &gpt_part_data->uuid;
+  memcpy(part_uuid, uuid, sizeof (efi_guid_t));
+
+  /* part_uuid is always LE, while uint8_t is always kind of BE */
+
+  part_uuid->time_low = PED_SWAP32(part_uuid->time_low);
+  part_uuid->time_mid = PED_SWAP16(part_uuid->time_mid);
+  part_uuid->time_hi_and_version = PED_SWAP16(part_uuid->time_hi_and_version);
+
+  return 1;
+}
+
+
 static uint8_t*
 gpt_partition_get_uuid (const PedPartition *part)
 {
@@ -1907,10 +1945,12 @@ static PedDiskOps gpt_disk_ops =
   partition_get_type_id:	NULL,
   partition_set_type_uuid:	gpt_partition_set_type_uuid,
   partition_get_type_uuid:	gpt_partition_get_type_uuid,
+  partition_set_uuid:	        gpt_partition_set_uuid,
   partition_get_uuid:		gpt_partition_get_uuid,
   disk_set_flag:		gpt_disk_set_flag,
   disk_get_flag:		gpt_disk_get_flag,
   disk_is_flag_available:	gpt_disk_is_flag_available,
+  disk_set_uuid:		gpt_disk_set_uuid,
   disk_get_uuid:		gpt_disk_get_uuid,
 
   PT_op_function_initializers (gpt)
diff --git a/parted/command.c b/parted/command.c
index b5fb399..e7b6524 100644
--- a/parted/command.c
+++ b/parted/command.c
@@ -72,7 +72,7 @@ command_register (Command** list, Command* cmd)
 }
 
 Command*
-command_get (Command** list, char* name)
+command_get (Command** list, const char* name)
 {
 	int		i;
 	int		partial_match = -1;
diff --git a/parted/command.h b/parted/command.h
index 966d96d..3db5985 100644
--- a/parted/command.h
+++ b/parted/command.h
@@ -39,7 +39,7 @@ extern Command* command_create (const StrList* names,
 extern void command_destroy (Command* cmd);
 void command_register (Command** list, Command* cmd);
 
-extern Command* command_get (Command** list, char* name);
+extern Command* command_get (Command** list, const char* name);
 extern StrList* command_get_names (Command** list);
 extern void command_print_summary (Command* cmd);
 extern void command_print_help (Command* cmd);
diff --git a/parted/parted.c b/parted/parted.c
index f86619f..225111e 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -161,6 +161,7 @@ static const char* number_msg = N_(
 static const char* label_type_msg_start = N_("LABEL-TYPE is one of: ");
 static const char* flag_msg_start =   N_("FLAG is one of: ");
 static const char* disk_flag_msg_start =   N_("FLAG is one of: ");
+static const char* disk_uuid_msg =    N_("UUID is a UUID\n");
 static const char* unit_msg_start =   N_("UNIT is one of: ");
 static const char* min_or_opt_msg = N_("desired alignment: minimum or optimal");
 static const char* part_type_msg =    N_("PART-TYPE is one of: primary, logical, "
@@ -177,6 +178,7 @@ static const char* device_msg =       N_("DEVICE is usually /dev/hda or /dev/sda
 static const char* name_msg =         N_("NAME is any word you want\n");
 static const char* type_msg =         N_("TYPE_ID is a value between 0x01 and 0xff, "
                 "TYPE_UUID is a UUID\n");
+static const char* uuid_msg =         N_("UUID is a UUID\n");
 
 static const char* copyright_msg = N_(
 "Copyright (C) 1998 - 2006 Free Software Foundation, Inc.\n"
@@ -1013,6 +1015,60 @@ error:
         return 0;
 }
 
+static int
+do_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_PARTITION_UUID)) {
+                ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
+                                     _("%s disk labels do not support partition uuid."),
+				     (*diskp)->type->name);
+                goto error;
+        }
+
+        PedPartition* part = NULL;
+        if (!command_line_get_partition (_("Partition number?"), *diskp, &part))
+                goto error;
+
+        uint8_t* part_uuid = ped_partition_get_uuid (part);
+	if (!part_uuid)
+	        goto error;
+
+        static char buf[UUID_STR_LEN];
+        uuid_unparse_lower (part_uuid, buf);
+        free (part_uuid);
+
+        char* input = command_line_get_word (_("Partition uuid?"), buf, NULL, 0);
+        if (!input)
+                goto error;
+
+        uuid_t tmp;
+        if (uuid_parse (input, tmp) != 0 || uuid_is_null (tmp)) {
+                ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
+                                     _("Invalid uuid."));
+                goto error_free_input;
+        }
+
+        if (!ped_partition_set_uuid (part, tmp))
+                goto error_free_input;
+
+        free (input);
+
+        if (!ped_disk_commit (*diskp))
+                goto error;
+        return 1;
+
+error_free_input:
+        free (input);
+error:
+        return 0;
+}
+
+
 static char*
 partition_print_flags (PedPartition const *part)
 {
@@ -2066,6 +2122,57 @@ error:
   return 0;
 }
 
+
+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);
+                goto error;
+        }
+
+        uint8_t* disk_uuid = ped_disk_get_uuid (*diskp);
+	if (!disk_uuid)
+	        goto error;
+
+        static char buf[UUID_STR_LEN];
+        uuid_unparse_lower (disk_uuid, buf);
+        free (disk_uuid);
+
+        char* input = command_line_get_word (_("Disk uuid?"), buf, NULL, 0);
+        if (!input)
+                goto error;
+
+        uuid_t tmp;
+        if (uuid_parse (input, tmp) != 0 || uuid_is_null (tmp)) {
+                ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
+                                     _("Invalid uuid."));
+                goto error_free_input;
+        }
+
+        if (!ped_disk_set_uuid (*diskp, tmp))
+                goto error_free_input;
+
+        free (input);
+
+        if (!ped_disk_commit (*diskp))
+                goto error;
+        return 1;
+
+error_free_input:
+        free (input);
+error:
+        return 0;
+}
+
+
 static int
 do_disk_set (PedDevice** dev, PedDisk** diskp)
 {
@@ -2430,6 +2537,14 @@ _("disk_toggle [FLAG]                       toggle the state of FLAG on "
 NULL),
         str_list_create (disk_flag_msg, NULL), 1));
 
+command_register (commands, command_create (
+        str_list_create_unique ("disk_uuid", _("disk_uuid"), NULL),
+        do_disk_uuid,
+        str_list_create (
+_("disk_uuid UUID                           set UUID of disk"),
+NULL),
+        str_list_create (disk_uuid_msg, NULL), 1));
+
 command_register (commands, command_create (
 		str_list_create_unique ("set", _("set"), NULL),
 		do_set,
@@ -2452,10 +2567,18 @@ command_register (commands, command_create (
         str_list_create_unique ("type", _("type"), NULL),
         do_type,
         str_list_create (
-_("type NUMBER TYPE-ID or TYPE-UUID         type set TYPE-ID or TYPE-UUID of partition NUMBER"),
+_("type NUMBER TYPE-ID or TYPE-UUID         set TYPE-ID or TYPE-UUID of partition NUMBER"),
 NULL),
         str_list_create (_(number_msg), _(type_msg), NULL), 1));
 
+command_register (commands, command_create (
+        str_list_create_unique ("uuid", _("uuid"), NULL),
+        do_uuid,
+        str_list_create (
+_("uuid NUMBER UUID                         set UUID of partition NUMBER"),
+NULL),
+        str_list_create (_(number_msg), _(uuid_msg), NULL), 1));
+
 command_register (commands, command_create (
         str_list_create_unique ("unit", _("unit"), NULL),
         do_unit,
diff --git a/parted/ui.c b/parted/ui.c
index 3d491a2..5e7932c 100644
--- a/parted/ui.c
+++ b/parted/ui.c
@@ -1679,7 +1679,8 @@ non_interactive_mode (PedDevice** dev, PedDisk **disk, Command* cmd_list[],
                 if (!word)
                         break;
 
-                cmd = command_get (commands, word);
+                /* keep compatibility of abbreviation "u" for "unit" and not "uuid" */
+                cmd = command_get (commands, strcmp (word, "u") == 0 ? "unit" : word);
                 free (word);
                 if (!cmd) {
                         help_msg ();
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e6bc912..addcd29 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -44,6 +44,8 @@ TESTS = \
   t0901-type-gpt-invalid.sh \
   t0910-type-dos.sh \
   t0911-type-dos-invalid.sh \
+  t0920-uuid-gpt.sh \
+  t0921-uuid-gpt-reproducible.sh \
   t1100-busy-label.sh \
   t1101-busy-partition.sh \
   t1102-loop-label.sh \
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 @@
+#!/bin/sh
+
+# Test disk_uuid and uuid commands with GPT label
+
+# Copyright (C) 2026 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
+
+# Force 512-byte sector size for this test
+export PARTED_SECTOR_SIZE=512
+sector_size_=512
+
+dev=loop-file
+
+# create image
+truncate --size 50MiB "$dev" || fail=1
+
+# create gpt label and one partition
+parted --script "$dev" mklabel gpt > out 2>&1 || fail=1
+parted --script "$dev" mkpart "test1" ext4 10% 20% > out 2>&1 || fail=1
+
+# set disk uuid and partition uuid
+parted --script "$dev" disk_uuid "351df77b-cfce-40fe-8fb2-3fb09ea36b4f" || fail=1
+parted --script "$dev" uuid 1 "f92e01b5-be06-4e95-8957-e97db3be2db1" || fail=1
+
+# print with json format (without replacing UUIDs since they are deterministic)
+parted --script --json "$dev" unit s print > out 2>&1 || fail=1
+
+cat <<EOF > exp || fail=1
+{
+   "disk": {
+      "path": "loop-file",
+      "size": "102400s",
+      "model": "",
+      "transport": "file",
+      "logical-sector-size": 512,
+      "physical-sector-size": 512,
+      "label": "gpt",
+      "uuid": "351df77b-cfce-40fe-8fb2-3fb09ea36b4f",
+      "max-partitions": 128,
+      "partitions": [
+         {
+            "number": 1,
+            "start": "10240s",
+            "end": "20479s",
+            "size": "10240s",
+            "type": "primary",
+            "type-uuid": "0fc63daf-8483-4772-8e79-3d69d8477de4",
+            "uuid": "f92e01b5-be06-4e95-8957-e97db3be2db1",
+            "name": "test1"
+         }
+      ]
+   }
+}
+EOF
+
+# remove full path of device from actual output
+mv out o2 && sed "s,\"/.*/$dev\",\"$dev\"," o2 > out || fail=1
+
+# check for expected output
+compare exp out || fail=1
+
+# test invalid UUIDs
+parted --script "$dev" disk_uuid "invalid-uuid" && fail=1
+parted --script "$dev" disk_uuid "00000000-0000-0000-0000-000000000000" && fail=1
+parted --script "$dev" uuid 1 "invalid-uuid" && fail=1
+parted --script "$dev" uuid 1 "00000000-0000-0000-0000-000000000000" && fail=1
+
+# test non-existent partition
+parted --script "$dev" uuid 2 "704cee3d-3d76-4450-8ed7-3b283325a526" && fail=1
+
+# test unsupported label (msdos)
+dev_msdos=loop-msdos
+truncate --size 20MiB "$dev_msdos" || fail=1
+parted --script "$dev_msdos" disk_uuid "67261cd9-da45-437e-a57c-c2250d0a1aa1" && fail=1
+parted --script "$dev_msdos" mklabel msdos mkpart primary ext4 1MiB 5MiB || fail=1
+parted --script "$dev_msdos" uuid 1 "14a812a3-0633-4069-bd19-79eb6f8fe8b1" && fail=1
+
+Exit $fail
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 @@
+#!/bin/sh
+
+# Test reproducible GPT creation using disk_uuid and uuid commands
+
+# Copyright (C) 2026 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
+
+# Force 512-byte sector size for this test
+export PARTED_SECTOR_SIZE=512
+sector_size_=512
+
+sha256sum --version >/dev/null 2>&1 || skip_ "sha256sum is required for this test"
+
+dev=dev.img
+
+# create zeroed image
+truncate --size 50MiB "$dev" || fail=1
+
+# create gpt label, two partition, and set all UUIDs
+parted --script "$dev" mklabel gpt \
+       disk_uuid "d812fb48-9902-49a1-856a-eee66da8b826" || fail=1
+parted --script "$dev" mkpart "test1" ext4 2048s 10239s \
+       uuid 1 "7b492910-2456-4e62-80aa-0d877df63323" || fail=1
+parted --script "$dev" mkpart "test2" ext4 10240s 20479s \
+       uuid 2 "207d63b5-f9ec-4240-aa00-2fce00656723" || fail=1
+
+# verify exact sha256 checksum for reproducible builds
+sha256sum "$dev" > out || fail=1
+echo "837f295e07a0f0333b142ceb3f6a94d67c7312862615ebd272941c6ad3eb4cdd  $dev" > exp || fail=1
+compare exp out || fail=1
+
+Exit $fail
-- 
Arvin Schnell, <aschnell at suse.com>
Senior Software Engineer, Research & Development

SUSE Software Solutions Germany GmbH
Frankenstr. 146
90461 Nürnberg
Germany

Geschäftsführer: Stefan Gaiser, Jochen Jaser, Abhinav Puri
(HRB 36809, AG Nürnberg)



More information about the parted-devel mailing list