[Parted-maintainers] Bug#292111: installation-reports: FAILURE TO ... [proposed solution]
Gene Cooperman
Gene Cooperman <gene@ccs.neu.edu>, 292111@bugs.debian.org
Sun, 13 Feb 2005 03:15:42 -0500
Well, I now understand what parted is doing, and why it doesn't work on
my system. Apparently, the extended partition of my partition table
has a hole in it, and a physical partion occupies that hole.
My partition table has:
1. /dev/hde1 -- physical partition (ntfs)
2. /dev/hde2 -- extended partition with hole in it;
i.e. it goes from the end of /dev/hde1 to the end of the disk.
However, there is a region inside the extended partition
that is not occupied by any logical partition.
3. /dev/hde3 -- physical partition (linux-swap);
This partition is located exactly in the hole that is in
the middle of the extended partition, /dev/hde2
4. /dev/hde5, [hole], /dev/hde6, /dev/hde7, /dev/hde8 -- logical partitions
If this is the case, I suspect that I could use a different partition
software such as Mandrake's Drake to delete /dev/hde3 and leave it free.
I could then use parted to recreate a linux-swap partition, but now
as a logical partition using the free disk space. Does this seem
like a reasonable plan, or could it be dangerous?
[ I know, back up my files before I do anything. :-) ]
I include further analysis of what parted does on my system below.
I also suggest where parted could include a warning that would have
diagnosed the current situation quickly and painlessly.
==============================================================
I interject here to illustrate the point with the results of fdisk:
Command (m for help): p
Disk /dev/hde: 163.9 GB, 163928604672 bytes
255 heads, 63 sectors/track, 19929 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hde1 * 1 7654 61480723+ 7 HPFS/NTFS
/dev/hde2 7655 19930 98605773 5 Extended
/dev/hde3 8990 9254 2128581 82 Linux swap
/dev/hde5 7655 8989 10723356 b W95 FAT32
/dev/hde6 9255 13128 31117873+ 83 Linux
/dev/hde7 13129 15651 20265966 83 Linux
/dev/hde8 15652 19930 34369839 83 Linux
==============================================================
Continuing the analysis,
parted correctly identifies /dev/hde3 as a physical partition.
It then checks the overlap constraints, as shown by the following stack trace:
(gdb) where
#0 _partition_get_overlap_constraint (part=0x8059f10, geom=0x8059f1c)
at disk.c:1244
#1 0x4002c3c4 in ped_disk_add_partition (disk=0x8059648, part=0x8059f10,
constraint=0x8059798) at disk.c:1445
#2 0x40030db2 in read_table (disk=0x8059648, sector=0, is_extended_table=0)
at disk_dos.c:832
#3 0x40031004 in msdos_read (disk=0x8059648) at disk_dos.c:880
#4 0x4002845e in ped_disk_new (dev=0x805a5b8) at disk.c:148
#5 0x0804c317 in do_print (dev=0xbffffa94) at parted.c:838
#6 0x0804a79e in command_run (cmd=0x80581a0, dev=0xbffffa94) at command.c:129
#7 0x08050e6c in interactive_mode (dev=0xbffffa94, cmd_list=0x8053420)
at ui.c:1006
#8 0x0804e608 in main (argc=0, argv=0xbffffb28) at parted.c:1636
Within _partition_get_overlap_constraint, it then chooses a
max_end that is the end of the disk, part->disk->dev->length - 1
However, for min_start, it walks through each of those physical and extended
partitions that have a geom.start that is less than the geom.start of
the current partition. It then chooses a min_start equal to the maximum
of each value geom.end+1 among the partitions encountered.
The problem is that this assumes that an extended partition like
/dev/hde2 must be contiguous.
Since /dev/hde3 is in the hole in the middle of /dev/hde2, the result
is that /dev/hde3 begins before /dev/hde2, and so the constraint
insists that /dev/hde2 must end after /dev/hde3. This constraint
is not satisfied.
A fix for my system would be to make the following change to
disk.c(_partition_get_overlap_constraint):
1244 while (walk != NULL
1245 && (walk->geom.start < geom->start
1246 || min_start >= walk->geom.start)) {
1247 if (walk != part)
1248 min_start = walk->geom.end + 1;
1249 walk = walk->next;
1250 }
CHANGE TO:
1247 if (walk != part && walk->type != PED_PARTITION_EXTENDED)
Of course, this is probably not safe for most situations,
and so it would be better for me to try the other plan of simply deleting
my /dev/hde2, and then using parted to recreate it as a logical partition.
Maybe it would be nice if parted reported when it detected a hole
in an extended partition:
disk.c(_partition_get_overlap_constraint):
ADD BEFORE LINE 1247:
if (walk->geom.start <= geom->start && walk->geom.end >= geom->end
&& walk->type == PED_PARTITION_EXTENDED
&& part->type == PED_PARTITION_NORMAL)
PRINT_PED_WARNING("Extended partition has a hole in it, occupied
by a physical partition.");
Or is my situation too unusual to worry about?
=====================================
You can probably skip the rest of this e-mail. But if you want further
details, here are the partition tables as read by parted.
Running parted under gdb:
[ First invocation of disk_dos.c(read_table) ]
(gdb) p is_extended_table
$147 = 0
(gdb) p table.partitions
$148 = {{boot_ind = 128 '\200', chs_start = {head = 1 '\001',
sector = 1 '\001', cylinder = 0 '\0'}, type = 7 '\a', chs_end = {
head = 254 '', sector = ', cylinder = '}, start = 63,
length = 122961447}, {boot_ind = 0 '\0', chs_start = {head = 254 '',
sector = ', cylinder = '}, type = 5 '\005', chs_end = {
head = 254 '', sector = ', cylinder = '},
start = 122961510, length = 197211546}, {boot_ind = 0 '\0', chs_start = {
head = 254 '', sector = ', cylinder = '},
type = 130 '\202', chs_end = {head = 254 '', sector = ',
cylinder = '}, start = 144408348, length = 4257162}, {
boot_ind = 0 '\0', chs_start = {head = 0 '\0', sector = 0 '\0',
cylinder = 0 '\0'}, type = 0 '\0', chs_end = {head = 0 '\0',
sector = 0 '\0', cylinder = 0 '\0'}, start = 0, length = 0}}
[ Second recursive invocation of disk_dos.c(read_table) ]
(gdb) p is_extended_table
$149 = 1
(gdb) p table.partitions
$150 = {{boot_ind = 0 '\0', chs_start = {head = 254 '', sector = ',
cylinder = '}, type = 11 '\v', chs_end = {head = 254 '',
sector = ', cylinder = '}, start = 63, length = 21446712}, {
boot_ind = 0 '\0', chs_start = {head = 254 '', sector = ',
cylinder = '}, type = 5 '\005', chs_end = {head = 254 '',
sector = ', cylinder = '}, start = 25704000,
length = 210901320}, {boot_ind = 0 '\0', chs_start = {head = 0 '\0',
sector = 0 '\0', cylinder = 0 '\0'}, type = 0 '\0', chs_end = {
head = 0 '\0', sector = 0 '\0', cylinder = 0 '\0'}, start = 0,
length = 0}, {boot_ind = 0 '\0', chs_start = {head = 0 '\0',
sector = 0 '\0', cylinder = 0 '\0'}, type = 0 '\0', chs_end = {
head = 0 '\0', sector = 0 '\0', cylinder = 0 '\0'}, start = 0,
length = 0}}
[ Third recursive invocation of disk_dos.c(read_table) ]
(gdb) p is_extended_table
$171 = 1
(gdb) p table.partitions
$172 = {{boot_ind = 0 '\0', chs_start = {head = 254 '', sector = ',
cylinder = '}, type = 131 '\203', chs_end = {head = 254 '',
sector = ', cylinder = '}, start = 63, length = 62235747}, {
boot_ind = 0 '\0', chs_start = {head = 254 '', sector = ',
cylinder = '}, type = 5 '\005', chs_end = {head = 254 '',
sector = ', cylinder = '}, start = 87939810,
length = 251433315}, {boot_ind = 0 '\0', chs_start = {head = 0 '\0',
sector = 0 '\0', cylinder = 0 '\0'}, type = 0 '\0', chs_end = {
head = 0 '\0', sector = 0 '\0', cylinder = 0 '\0'}, start = 0,
length = 0}, {boot_ind = 0 '\0', chs_start = {head = 0 '\0',
sector = 0 '\0', cylinder = 0 '\0'}, type = 0 '\0', chs_end = {
head = 0 '\0', sector = 0 '\0', cylinder = 0 '\0'}, start = 0,
length = 0}}
[ And so on. ]