bug-parted
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

parted_1G_extended_error_bug


From: Lang ZR
Subject: parted_1G_extended_error_bug
Date: Thu, 2 Sep 2010 13:42:54 +0800

Hello! Recently, because of the need of my work I studied how "parted" works,  in particular its principle of partition. how to ensure the "start" and "end" at last. I added some debug statements for print some useful information. I made a patch about the changes, please watch the below:

address@hidden:~/parted/tmp > diff -Nurp parted-2.2.bak/ parted-2.2
diff -Nurp parted-2.2.bak/libparted/unit.c parted-2.2/libparted/unit.c
--- parted-2.2.bak/libparted/unit.c     2010-02-08 14:48:18.000000000 +0800
+++ parted-2.2/libparted/unit.c 2010-09-02 11:19:57.000000000 +0800
@@ -441,7 +441,13 @@ geometry_from_centre_radius (const PedDe
                              PedSector sector, PedSector radius)
 {
        PedSector start = clip (dev, sector - radius);
+       printf("#######################################################################################################\n");
+       printf("start=%ld\n", start);
+       printf("#######################################################################################################\n");
        PedSector end = clip (dev, sector + radius);
+       printf("#######################################################################################################\n");
+       printf("end=%ld\n", end);
+       printf("#######################################################################################################\n");
        if (sector - end > radius || start - sector > radius)
                return NULL;
        return ped_geometry_new (dev, start, end - start + 1);
diff -Nurp parted-2.2.bak/parted/parted.c parted-2.2/parted/parted.c
--- parted-2.2.bak/parted/parted.c      2010-02-11 00:44:40.000000000 +0800
+++ parted-2.2/parted/parted.c  2010-09-02 11:28:50.000000000 +0800
@@ -63,6 +63,8 @@
 /* minimum amount of free space to leave, or maximum amount to gobble up */
 #define MIN_FREESPACE           (1000 * 2)      /* 1000k */

+int LINX_PRINT_GENO=0;
+
 static int MEGABYTE_SECTORS (PedDevice* dev)
 {
         return PED_MEGABYTE_SIZE / dev->sector_size;
@@ -801,7 +803,14 @@ do_mkpart (PedDevice** dev)
                 goto error_destroy_disk;

         snap_to_boundaries (&part->geom, NULL, disk, range_start, range_end);
-
+/*************************************************************************/
+               if (1 == LINX_PRINT_GENO){
+                       printf("geom->start=%ld\n", part->geom.start);
+                       printf("geom->end=%ld\n", part->geom.end);
+                       printf("geom->length=%ld\n", part->geom.length);
+                       exit(1);
+               }
+/*************************************************************************/
         /* create constraints */
         user_constraint = constraint_from_start_end (*dev, range_start,
                         range_end);
@@ -2719,6 +2728,16 @@ done_ui();
 int
 main (int argc, char** argv)
 {
+/********************************************************************/
+       if ((argc > 1) && (!strcmp(artv[1], "--printgeom"))){
+               LINX_PRINT_GENO = 1;
+               argc = 1;
+               argv[1] = '\0';
+       }
+       else{
+               LINX_PRINT_GENO = 0;
+       }
+/********************************************************************/
         PedDevice*      dev;
         int             status;


Then I parted the /dev/hdb. First, I want to know the "laststart" and "lastend", so I used my argument. then I parted the No.1 partition "primary ext3 from 0B to 976562*512B", and parted all right.

localhost:/home/zrlang/parted # parted --printgeom
GNU Parted 2.2
使用 /dev/hda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) select /dev/hdb
select /dev/hdb
使用 /dev/hdb
(parted) mkpart
mkpart
分区类型?  primary/主分区/extended/扩展分区? primary
primary
文件系统类型?  [ext2]? ext3
ext3
起始点? 0
0
###########################################################################################################################
start=0
###########################################################################################################################
###########################################################################################################################
end=1953
###########################################################################################################################
结束点? 500M
500M
###########################################################################################################################
start=974609
###########################################################################################################################
###########################################################################################################################
end=978515
###########################################################################################################################
geom->start=0
geom->end=976562
geom->length=976563
localhost:/home/zrlang/parted # parted /dev/hdb
GNU Parted 2.2
使用 /dev/hdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mkpart
mkpart
分区类型?  primary/主分区/extended/扩展分区? primary
primary
文件系统类型?  [ext2]? ext3
ext3
起始点? 0
0
###########################################################################################################################
start=0
###########################################################################################################################
###########################################################################################################################
end=1953
###########################################################################################################################
结束点? 499999744B
499999744B
###########################################################################################################################
start=976562
###########################################################################################################################
###########################################################################################################################
end=976562
###########################################################################################################################
警告: The resulting partition is not properly aligned for best performance.
忽略/Ignore/放弃/Cancel? ignore
ignore
(parted) print
print
Model: QEMU HARDDISK (ide)
Disk /dev/hdb: 10.7GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End    Size   Type     File system  标志
 1      512B   500MB  500MB  primary


Second, like the first, the No.2 partition "primary ext3 from 500M to 600M".

localhost:/home/zrlang/parted # parted --printgeom
GNU Parted 2.2
使用 /dev/hda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) select /dev/hdb
select /dev/hdb
使用 /dev/hdb
(parted) mkpart
mkpart
分区类型?  primary/主分区/extended/扩展分区? primary
primary
文件系统类型?  [ext2]? ext3
ext3
起始点? 500M
500M
###########################################################################################################################
start=974609
###########################################################################################################################
###########################################################################################################################
end=978515
###########################################################################################################################
结束点? 600M
600M
###########################################################################################################################
start=1169922
###########################################################################################################################
###########################################################################################################################
end=1173828
###########################################################################################################################
geom->start=976563
geom->end=1171875
geom->length=195313
localhost:/home/zrlang/parted # parted /dev/hdb mkpart p ext3 500000256B 600000000B
###########################################################################################################################
start=976563
###########################################################################################################################
###########################################################################################################################
end=976563
###########################################################################################################################
###########################################################################################################################
start=1171875
###########################################################################################################################
###########################################################################################################################
end=1171875
###########################################################################################################################
警告: The resulting partition is not properly aligned for best performance.
忽略/Ignore/放弃/Cancel? ignore
ignore
信息: You may need to update /etc/fstab.

localhost:/home/zrlang/parted # parted /dev/hdb print
Model: QEMU HARDDISK (ide)
Disk /dev/hdb: 10.7GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End    Size   Type     File system  标志
 1      512B   500MB  500MB  primary
 2      500MB  600MB  100MB  primary


Third, I wanted an extened partition from 1G to 10G.

localhost:/home/zrlang/parted # parted --printgeom
GNU Parted 2.2
使用 /dev/hda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) select /dev/hdb
select /dev/hdb
使用 /dev/hdb
(parted) mkpart
mkpart
分区类型?  primary/主分区/extended/扩展分区? e
e
起始点? 1G
1G
###########################################################################################################################
start=1
###########################################################################################################################
###########################################################################################################################
end=3906249
###########################################################################################################################
结束点? 10G
10G
###########################################################################################################################
start=17578126
###########################################################################################################################
###########################################################################################################################
end=20971519
###########################################################################################################################
geom->start=1171876
geom->end=20971519
geom->length=19799644


I print the "laststart" and "lastend" but the start be sure "1171876" sector. that is the location of 600M of the last time partition end. So I decided to try to parted the No.3 extended part from 1G to 10G.
The result is false, the "start" is not 1G, it really is 601M like the print -- "geom->start=1171876" in the above. I try much times, the result is same.

localhost:/home/zrlang/parted # parted /dev/hdb
GNU Parted 2.2
使用 /dev/hdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mkpart
mkpart
分区类型?  primary/主分区/extended/扩展分区? e
e
起始点? 1G
1G
###########################################################################################################################
start=1
###########################################################################################################################
###########################################################################################################################
end=3906249
###########################################################################################################################
结束点? 10G
10G
###########################################################################################################################
start=17578126
###########################################################################################################################
###########################################################################################################################
end=20971519
###########################################################################################################################
(parted) print
print
Model: QEMU HARDDISK (ide)
Disk /dev/hdb: 10.7GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End     Size    Type      File system  标志
 1      512B   500MB   500MB   primary
 2      500MB  600MB   100MB   primary
 3      601MB  10.7GB  10.1GB  extended               lba

Then, I remove the No.3 part. And I try to parted No.3 extened from 2G to 10G.

localhost:/home/zrlang/parted # parted --printgeom
GNU Parted 2.2
使用 /dev/hda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) select /dev/hdb
select /dev/hdb
使用 /dev/hdb
(parted) mkpart
mkpart
分区类型?  primary/主分区/extended/扩展分区? e
e
起始点? 2G
2G
###########################################################################################################################
start=1953126
###########################################################################################################################
###########################################################################################################################
end=5859374
###########################################################################################################################
结束点? 10G
10G
###########################################################################################################################
start=17578126
###########################################################################################################################
###########################################################################################################################
end=20971519
###########################################################################################################################
geom->start=3906250
geom->end=20971519
geom->length=17065270

localhost:/home/zrlang/parted # parted /dev/hdb
GNU Parted 2.2
使用 /dev/hdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mkpart
mkpart
分区类型?  primary/主分区/extended/扩展分区? e
e
起始点? 2G
2G
###########################################################################################################################
start=1953126
###########################################################################################################################
###########################################################################################################################
end=5859374
###########################################################################################################################
结束点? 10G
10G
###########################################################################################################################
start=17578126
###########################################################################################################################
###########################################################################################################################
end=20971519
###########################################################################################################################
(parted) print
print
Model: QEMU HARDDISK (ide)
Disk /dev/hdb: 10.7GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type      File system  标志
 1      512B    500MB   500MB   primary
 2      500MB   600MB   100MB   primary
 3      2000MB  10.7GB  8738MB  extended               lba

The start of No.3 really is 2G this time. and the debug print--"geom->start=3906250" is right. Then I remove the No.3 again, and parted extended from 800M to 10G, it is right. Other attempts is right, except the 1G.
Then I remove No.3 and No.2, reparted the No.2 primary from 500M to 1G.


 localhost:/home/zrlang/parted # parted --printgeom
GNU Parted 2.2
使用 /dev/hda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) select /dev/hdb
select /dev/hdb
使用 /dev/hdb
(parted) mkpart
mkpart
分区类型?  primary/主分区/extended/扩展分区? p
p
文件系统类型?  [ext2]? ext3
ext3
起始点? 500M
500M
###########################################################################################################################
start=974609
###########################################################################################################################
###########################################################################################################################
end=978515
###########################################################################################################################
结束点? 1G
1G
###########################################################################################################################
start=1
###########################################################################################################################
###########################################################################################################################
end=3906249
###########################################################################################################################
geom->start=976563
geom->end=1953125
geom->length=976563
localhost:/home/zrlang/parted # parted /dev/hdb mkpart p ext3 500000256B 1000000000B
###########################################################################################################################
start=976563
###########################################################################################################################
###########################################################################################################################
end=976563
###########################################################################################################################
###########################################################################################################################
start=1953125
###########################################################################################################################
###########################################################################################################################
end=1953125
###########################################################################################################################
警告: The resulting partition is not properly aligned for best performance.
忽略/Ignore/放弃/Cancel? ignore
ignore
信息: You may need to update /etc/fstab.

localhost:/home/zrlang/parted # parted /dev/hdb print
Model: QEMU HARDDISK (ide)
Disk /dev/hdb: 10.7GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End     Size   Type     File system  标志
 1      512B   500MB   500MB  primary
 2      500MB  1000MB  500MB  primary

localhost:/home/zrlang/parted # parted /dev/hdb rm 3
错误: 分区不存在。
localhost:/home/zrlang/parted # parted /dev/hdb rm 2
信息: You may need to update /etc/fstab.

localhost:/home/zrlang/parted # parted /dev/hdb mkpart p ext3 500M 1G
###########################################################################################################################
start=974609
###########################################################################################################################
###########################################################################################################################
end=978515
###########################################################################################################################
###########################################################################################################################
start=1
###########################################################################################################################
###########################################################################################################################
end=3906249
###########################################################################################################################
信息: You may need to update /etc/fstab.

localhost:/home/zrlang/parted # parted /dev/hdb print
Model: QEMU HARDDISK (ide)
Disk /dev/hdb: 10.7GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End     Size   Type     File system  标志
 1      512B   500MB   500MB  primary
 2      500MB  1000MB  500MB  primary


The debug print and the result is all right. Then I parted No.3 extended from 1G to 10G again.

 localhost:/home/zrlang/parted # parted --printgeom
GNU Parted 2.2
使用 /dev/hda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) select /dev/hdb
select /dev/hdb
使用 /dev/hdb
(parted) mkpart
mkpart
分区类型?  primary/主分区/extended/扩展分区? e
e
起始点? 1G
1G
###########################################################################################################################
start=1
###########################################################################################################################
###########################################################################################################################
end=3906249
###########################################################################################################################
结束点? 10G
10G
###########################################################################################################################
start=17578126
###########################################################################################################################
###########################################################################################################################
end=20971519
###########################################################################################################################
geom->start=1953792
geom->end=20971519
geom->length=19017728
localhost:/home/zrlang/parted # parted /dev/hdb mkpart e 1000341504B 10737417728B
###########################################################################################################################
start=1953792
###########################################################################################################################
###########################################################################################################################
end=1953792
###########################################################################################################################
###########################################################################################################################
start=20971519
###########################################################################################################################
###########################################################################################################################
end=20971519
###########################################################################################################################
信息: You may need to update /etc/fstab.

localhost:/home/zrlang/parted # parted /dev/hdb print
Model: QEMU HARDDISK (ide)
Disk /dev/hdb: 10.7GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type      File system  标志
 1      512B    500MB   500MB   primary
 2      500MB   1000MB  500MB   primary
 3      1000MB  10.7GB  9737MB  extended               lba

localhost:/home/zrlang/parted # parted /dev/hdb rm 3
信息: You may need to update /etc/fstab.

localhost:/home/zrlang/parted # parted /dev/hdb mkpart e 1G 10G
###########################################################################################################################
start=1
###########################################################################################################################
###########################################################################################################################
end=3906249
###########################################################################################################################
###########################################################################################################################
start=17578126
###########################################################################################################################
###########################################################################################################################
end=20971519
###########################################################################################################################
信息: You may need to update /etc/fstab.

localhost:/home/zrlang/parted # parted /dev/hdb print
Model: QEMU HARDDISK (ide)
Disk /dev/hdb: 10.7GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type      File system  标志
 1      512B    500MB   500MB   primary
 2      500MB   1000MB  500MB   primary
 3      1000MB  10.7GB  9737MB  extended               lba

The start debug print is "geom->start=1953792" and 1953792*512=1000341504B, the result of parted two times is right. But I can't sure it is because of the end of No.2 has been 1G, or other reason. However when I part No.2 end as 1G, it is right.

Because I needed to do my work, I have no more time to find the reason. Maybe it is my false, so I push the message which I have done. Please look at it, and give me some suggest. And I am sorry that my English is not so good.

Thank you very much.



FROM:
           ZR_Lang
           2010.09.02

reply via email to

[Prev in Thread] Current Thread [Next in Thread]