Description of problem: part-list Version-Release number of selected component (if applicable): fc-12-1.2.3, latest git version 1.3.9 How reproducible: 100% Steps to Reproduce: 1. create an empty image with dd or qemu-img 2. run guestfish ,add the image, partition the image to "vda1 vda2 vda3<vda4, vda5> with sfdisk cmd, where vda1,vda2 are primary, vda3 is extented, vda4,vda5 are logical partition 3. run part-list, part-set-bootable,part-get-bootable Actual results: cmd not work, Error: Can't have overlapping partitions. Expected results: cmd should work Additional info: logs: ><fs> part-init /dev/vda mbr ><fs> sfdisk /dev/vda 0 0 0 '0,100,83 101,100,83 201,200,5 202,50,83' ><fs> sfdisk-l /dev/vda Disk /dev/vda: 1015 cylinders, 16 heads, 63 sectors/track Units = cylinders of 516096 bytes, blocks of 1024 bytes, counting from 0 Device Boot Start End #cyls #blocks Id System /dev/vda1 0+ 99 100- 50399+ 83 Linux /dev/vda2 101 200 100 50400 83 Linux /dev/vda3 201 400 200 100800 5 Extended /dev/vda4 202 251 50 25200 83 Linux ><fs> part-list /dev/vda Error: Invalid partition table on /dev/vda -- wrong signature 0. ><fs> sfdisk /dev/vda 0 0 0 '0,100,83 101,100,83 201,200,5 202,50,83 252,50,83' ><fs> part-list /dev/vda Error: Can't have overlapping partitions. ><fs> sfdisk-l /dev/vda Disk /dev/vda: 1015 cylinders, 16 heads, 63 sectors/track Units = cylinders of 516096 bytes, blocks of 1024 bytes, counting from 0 Device Boot Start End #cyls #blocks Id System /dev/vda1 0+ 99 100- 50399+ 83 Linux /dev/vda2 101 200 100 50400 83 Linux /dev/vda3 201 400 200 100800 5 Extended /dev/vda4 202 251 50 25200 83 Linux /dev/vda5 252 301 50 25200 83 Linux ><fs> part-get-bootable /dev/vda 1 Error: Can't have overlapping partitions. ><fs> part-set-bootable /dev/vda 1 1 libguestfs: error: part_set_bootable: do_part_set_bootable: parted: /dev/vda: Error: Can't have overlapping partitions.
CC-ing Jim who might have a better idea about this.
This makes my head hurt slightly, but I think parted is correct. Although sfdisk has allowed you to create a partition table layout, the layout is really incorrect. Let me explain. Linux refers to the four fixed primary partitions in the MBR format[1] as /dev/vda1, /dev/vda2, /dev/vda3 and /dev/vda4. These fixed primary partitions must not be overlapping. However one or more may be marked as an extended partition (type 5) which means it's a placeholder for logical partitions. Linux refers to logical partitions starting with /dev/vda5 and up. So this is your second layout: Device Boot Start End #cyls #blocks Id System /dev/vda1 0+ 99 100- 50399+ 83 Linux /dev/vda2 101 200 100 50400 83 Linux /dev/vda3 201 400 200 100800 5 Extended /dev/vda4 202 251 50 25200 83 Linux /dev/vda5 252 301 50 25200 83 Linux This is wrong because primary partitions /dev/vda3 and /dev/vda4 are overlapping. /dev/vda4 is *not* a logical partition! With sfdisk you can get a correct layout with this sequence of commands: ><fs> sparse /tmp/test.img 1G ><fs> run ><fs> sfdisk /dev/vda 0 0 0 '0,100,83 101,100,83 201,200,5 0,0,0 202,50,83 252,50,83' ><fs> sfdisk-l /dev/vda Disk /dev/vda: 2080 cylinders, 16 heads, 63 sectors/track Units = cylinders of 516096 bytes, blocks of 1024 bytes, counting from 0 Device Boot Start End #cyls #blocks Id System /dev/vda1 0+ 99 100- 50399+ 83 Linux /dev/vda2 101 200 100 50400 83 Linux /dev/vda3 201 400 200 100800 5 Extended /dev/vda4 0 - 0 0 0 Empty /dev/vda5 202 251 50 25200 83 Linux /dev/vda6 252+ 301 50- 25199+ 83 Linux And you will see that the part-* commands work correctly: ><fs> part-list /dev/vda [0] = { part_num: 1 part_start: 512 part_end: 51609599 part_size: 51609088 } [1] = { part_num: 2 part_start: 52125696 part_end: 103735295 part_size: 51609600 } [2] = { part_num: 3 part_start: 103735296 part_end: 206954495 part_size: 103219200 } [3] = { part_num: 5 part_start: 104251392 part_end: 130056191 part_size: 25804800 } [4] = { part_num: 6 part_start: 130056704 part_end: 155860991 part_size: 25804288 } So I think this is NOTABUG. Although we let you do stuff with sfdisk to create invalid partition tables, this is basically outside our control, and possibly there is even some use for these invalid partition tables. [1] https://secure.wikimedia.org/wikipedia/en/wiki/Master_boot_record
OK, I have tried with a real example. Install a fc12 system with a 10G raw image in kvm, then launch that img with guestyfish. This time part-* cmd could work. But there is a problem that we can not create this kind of partition layout with sfdisk. And there is one cylinder waste between partitions (0-99 to 101~200, 2 cylinders, 101~200 to 201~400, 1 cylinder). Is this the limit of sfdisk cmd? ><fs> sfdisk-l /dev/vda Disk /dev/vda: 20805 cylinders, 16 heads, 63 sectors/track Units = cylinders of 516096 bytes, blocks of 1024 bytes, counting from 0 Device Boot Start End #cyls #blocks Id System /dev/vda1 * 0+ 203- 204- 102400 83 Linux /dev/vda2 203+ 10361- 10159- 5120000 83 Linux /dev/vda3 10361+ 14425- 4064- 2048000 83 Linux /dev/vda4 14439+ 20798- 6360- 3204967+ 5 Extended /dev/vda5 14439+ 18502- 4064- 2048000 83 Linux /dev/vda6 18502+ 20796- 2294- 1156095+ 82 Linux swap / Solaris ><fs> part-list part-list should have 1 parameter(s) type 'help part-list' for help on part-list ><fs> part-list /dev/vda [0] = { part_num: 1 part_start: 32256 part_end: 104889855 part_size: 104857600 } [1] = { part_num: 2 part_start: 104889856 part_end: 5347769855 part_size: 5242880000 } [2] = { part_num: 3 part_start: 5347769856 part_end: 7444921855 part_size: 2097152000 } [3] = { part_num: 4 part_start: 7452103680 part_end: 10733990399 part_size: 3281886720 } [4] = { part_num: 5 part_start: 7452135936 part_end: 9549287935 part_size: 2097152000 } [5] = { part_num: 6 part_start: 9549288448 part_end: 10733130239 part_size: 1183841792 }
closed this bug per comment 2,3
in response to your comment #3, there must be at least one sector (kernel and newer parted require 2 sectors) in the extended partition before the first logical partition. Since tools prefer to cylinder-align (for performance), that accounts for what appears to be a wasted cylinder before the first logical partition. Regarding the two cylinders left between partition 1 and 2, I don't know. Alignment perhaps? These days, I often make a point of using manually-chosen 1MiB-aligned partition-start-sector numbers with GNU parted when creating partition tables. Then, alignment options don't even come into play.