bug#80093: libparted: gpt: Partition type is not updated after changing file system

Pascal Hambourg <[email protected]> Wed, 25 Mar 2026 00:32:37 +0100
Newsgroups gmane.comp.gnu.parted.bugs
Organization Plouf !
Message-ID <[email protected]>
On 24/03/2026 at 16:29, Brian C. Lane wrote:
> On Mon, Mar 23, 2026 at 09:37:47PM +0100, Pascal Hambourg wrote:
>> On 23/03/2026 at 19:49, Brian C. Lane wrote:
>>>
>>> This isn't a bug. The partition GUID is only set at creation time, using
>>> input from the user to pick the most appropriate type. But parted isn't
>>> (and should not be) tracking filesystem changes and changing the GUID.
>>
>> This does not match my observations:
>> - ped_partition_set_system() can set the 'msftdata' or 'swap' flag on an
>> existing partition, it just cannot clear it.
>> - ped_partition_set_flag() sets the 'msftdata' or 'swap' flag in accordance
>> with the detected filesystem when clearing the GUID type flag (esp, raid...)
>> on an existing partition. Easy to reproduce with parted.
> 
> I must not be understanding, do you have an example script to
> demonstrate the problem?

AFAIK parted does not call directly ped_partition_set_system() on an 
existing partition. But the code in gpt.c is quite clear:

gpt_partition_set_system(part, fs_type)
	part->fs_type = fs_type
	if is_skip_guid(gpt_part_data->type) # esp, swap, msftdata...
		return 1
	if fstype == fat* | udf | ntfs
		gpt_part_data->type = PARTITION_BASIC_DATA_GUID
	else
		gpt_part_data->type = PARTITION_LINUX_DATA_GUID

gpt_partition_set_flag(part, flag, state)
	if gpt_find_flag_uuid_mapping(flag)
		if state
			gpt_part_data->type = type_uuid
		else if gpt_part_data->type == type_uuid
			gpt_part_data->type = PARTITION_LINUX_DATA_GUID;
			gpt_partition_set_system (part, part->fs_type)

The problem occurs with partman, the Debian installer partitioning tool, 
when calling ped_partition_set_system() or ped_partition_set_flag() on 
an existing partition.

Here is a procedure demonstrating the second point with parted (clearing 
the current type flag can set another type flag depending on the 
detected file system):

Step 1: create a standard EFI partition.

# parted /dev/vdb
mklabel gpt
mkpart EFI 0% 100%
set 1 esp on
# mkfs.vfat /dev/vdb1

Step 2: Clear the 'esp' flag.

# parted /dev/vdb
print
  File system  Flags
  fat32        boot, esp
set 1 esp off
print
  File system  Flags
  fat32        msftdata