[parted-devel] Some clarification on PedDisk

Kristian - mail.kristian at yahoo.it
Sat Oct 28 10:40:21 UTC 2017


Hello everyone,
   I write this list because the discussion is quite technical.

I was trying to create a test for a program that uses libparted. This program creates random partitions in the available spaces, trying to align them according to the type of table. There is something I do not understand in the libparted behavior and I would like to understand with you if it is correct.

To show you better I created a minimal program that creates a new table and shows the default status. 

>>> WARNING: THIS PROGRAM MODIFIES THE DEVICE! <<<

To compile the code: 

gcc -c -o ped-disk-new-fresh sourcefile.c -lparted

To run the program:

/path/to/ped-disk-new-fresh DEVICE-PATH DISK-TYPE

DISK-TYPE is one of PedDiskType name (msdos|sun|dvh|gpt...).

The first thing is that the sun disklabel type does not support the PED_DISK_TYPE_CYLINDER_ALIGNMENT flag. 

In the file `INCLUDEPATH/parted/disk.h' I read this:


  enum _PedDiskFlag {
    /* This flag (which defaults to true) controls if disk types for
       which cylinder alignment is optional do cylinder alignment when a
       new partition gets added.
       This flag is available for msdos and sun disklabels (for sun labels
       it only controls the aligning of the end of the partition) */
       PED_DISK_CYLINDER_ALIGNMENT=1,
       ...

But running the program I get this output:


user at host:~/$ sudo ./ped-disk-new-fresh /dev/sdb sun
type: sun
Features:
PED_DISK_TYPE_EXTENDED: no
PED_DISK_TYPE_PARTITION_NAME: no
Flags:
PED_DISK_CYLINDER_ALIGNMENT: unavailable
PED_DISK_GPT_PMBR_BOOT: unavailable
Partitions:
---
Num: -1:
Type: 4 (free)
Start: 0s (0.00MiB)
End: 16097129s (7860MiB)
---
Num: -1:
Type: 8 (metadata)
Start: 16097130s (7860MiB)
End: 16099327s (7861MiB)


The second thing concerns dvh disks. When we create a new disk, the parted library automatically creates the header volume. But is it correct to be indicated as (logical|freespace)? This is the output I see:

user at host:~/$ sudo ./ped-disk-new-fresh /dev/sdb dvh
type: dvh
Features:
PED_DISK_TYPE_EXTENDED: yes
PED_DISK_TYPE_PARTITION_NAME: yes
Flags:
PED_DISK_CYLINDER_ALIGNMENT: unavailable
PED_DISK_GPT_PMBR_BOOT: unavailable
Partitions:
---
Num: 9:
Type: 2 (extended)
Start: 0s (0.00MiB)
End: 4095s (2.00MiB)
---
Num: -1:
Type: 9 (metadata)
Start: 0s (0.00MiB)
End: 0s (0.00MiB)
---
Num: -1:
Type: 5 (free)
Start: 1s (0.00MiB)
End: 4095s (2.00MiB)
---
Num: -1:
Type: 4 (free)
Start: 4096s (2.00MiB)
End: 16099327s (7861MiB)

Output of util-linux fdisk on the device shows:

Disklabel type: sgi

Device     Start      End      Sectors  Size Id Type       Attrs
/dev/sdb9  0     4095     4096       2M  0  SGI volhdr 
/dev/sdb11     0 16099327 16099328  7.7G  6  SGI volume 

Is this behavior correct?

One last thing: what does libparted do when a new partition is added? How should alignment be handled? Libparted allows you to add misaligned partitions?

Greetings,
  Christian.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: partitions.c
Type: text/x-csrc
Size: 1897 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/parted-devel/attachments/20171028/53dc433d/attachment.c>


More information about the parted-devel mailing list