[parted-devel] Re: Hello, I've got error

Håkon Løvdal hlovdal at gmail.com
Tue Aug 15 00:03:03 UTC 2006


On 14/08/06, Yuriy Padlyak <yura at tenpostadsl.lviv.farlep.net> wrote:
> Håkon Løvdal wrote:
> > On 14/08/06, Yuriy Padlyak <yura at tenpostadsl.lviv.farlep.net> wrote:
> >> It still shows:
> >> "(parted) print
> >> Error: Can't have overlapping partitions."
> >>
> >> May be it's problem with my partitions?
> >>
> >
> > It could be. If you send me the output from "fdisk -l" as well as
> > one run of "fdisk /dev/the_name_of_your_disk" where you give
> > the commands "x", "p" and "q" to print the table in expert mode.
> > Then I can analyse that and see if I find something that looks
> > unnormal.
> >
> > BR Håkon Løvdal
> yura at yura:~$ sudo fdisk -l
> omitting empty partition (5)
>
> Disk /dev/sda: 80.0 GB, 80026361856 bytes
> 255 heads, 63 sectors/track, 9729 cylinders
> Units = cylinders of 16065 * 512 = 8225280 bytes
>
>    Device Boot      Start         End      Blocks   Id  System
> /dev/sda1   *           1         766     6152863+   7  HPFS/NTFS
> /dev/sda2             767        1372     4867695   83  Linux
> /dev/sda3            1373        9729    67127602+   f  W95 Ext'd (LBA)
> /dev/sda4            1404        9729    66878563+   7  HPFS/NTFS
> /dev/sda5            1373        1403      248944+  82  Linux swap / Solaris
>
> Disk /dev/sdc: 1025 MB, 1025998848 bytes
> 16 heads, 63 sectors/track, 1988 cylinders
> Units = cylinders of 1008 * 512 = 516096 bytes
>
>    Device Boot      Start         End      Blocks   Id  System
> /dev/sdc1   *           1        1987     1001416+   6  FAT16
>
>
>
> yura at yura:~$ sudo fdisk /dev/sda
>
> The number of cylinders for this disk is set to 9729.
> There is nothing wrong with that, but this is larger than 1024,
> and could in certain setups cause problems with:
> 1) software that runs at boot time (e.g., old versions of LILO)
> 2) booting and partitioning software from other OSs
>    (e.g., DOS FDISK, OS/2 FDISK)
> omitting empty partition (5)
>
> Command (m for help): x
>
> Expert command (m for help): p
>
> Disk /dev/sda: 255 heads, 63 sectors, 9729 cylinders
>
> Nr AF  Hd Sec  Cyl  Hd Sec  Cyl     Start      Size ID
>  1 80   1   1    0 254  63  765         63   12305727 07
>  2 00   0   1  766 254  63 1023   12305790    9735390 83
>  3 00   0   1 1023 254  63 1023   22041180  134255205 0f
>  4 00   1   1 1023 254  63 1023   22539258  133757127 07
>  5 00   2   1 1023 254  63 1023        126     497889 82
>
> Expert command (m for help): q
>
> yura at yura:~$


Hi. Those numbers reveals a strange layout. Partitions
1 to 4 are the primary partitions. One of them can be an
extended partition which then are divided in one or more
logical partitions, numbered from 5 and onwards. In your
case however one of the primary partitions lie within the
extended partition. Drawing your partitions with ascii-art
gives something like the following:


                       +------------------------------+
                     0 |                              |
                       |             sda1             |
                   765 |                              |
                       +------------------------------+
                   766 |                              |
                       |             sda2             |
                  1371 |                              |
     + - - - - - - - - +------------------------------+
     .            1372 |                              |
     .                 |             sda5             |
     .            1402 |                              |
  h d a 3              +------------------------------+
     .            1403 |                              |
     .                 |             sda4             |
     .            9728 |                              |
     + - - - - - - - - +------------------------------+



So it is not so strange that parted complains about
overlapping partitions because sda3 and sda4 are indeed
so. If that had been the result of any parted editing it
truly would have been a bug. However this is the already
existing layout read from disk when parted starts, and I
think it would be nice if parted was able to handle that
in a slightly nicer way than crashing with a false bug
report. Would it not be possible to let parted run all
constraints on a device after opening it and then warn
the user (or maybe refuse to run) if any of those fail?


I think the correct change to get your partition table
back in order would be to shrink sda3 so that it only
contains sda5. As far as I have calculated the only change
needed would be to change number of sectors from 134255205
to 498015.

(1402+1) - 1372 = 31 cylinders
31 * 255 * 63 = 498015 sectors

 +------+-----+---------------+------+---------------+----------+----------+
 |parti-|boot-|     Start     |      |      End      | Relative |Number of |
 |tion  |table|Head Cyl Sector|System|Head Cyl Sector|Start Sect| Sectors  |
 +------+-----+---------------+------+---------------+----------+----------+
-| sda3 | 0x00|   0  1023   1 | 0x0f | 254  1023  63 | 22041180 | 134255205 |
+| sda3 | 0x00|   0  1023   1 | 0x0f | 254  1023  63 | 22041180 |   498015 |
 +------+-----+---------------+------+---------------+----------+----------+


There are two ways you can do this, either edit the partition table in
raw mode using a disk editor with special support for this.
I would say that this is the best solution, but it is some time
since I last did this myself, and I have no clear recommendation
of what tool to use. I did some search and I think maybe some
of these should work. Does anyone else have recommendations
for this kind of tool?

cfdisk
Ranish Partition Manager
http://mirror.href.com/thestarman/asm/mbr/BootToolsRefs.htm
DiskEdit from Norton Utilities (not free)

Alternatively you can first delete sda5 and sda3 and then recreate
sda3 with correct size followed by recreating sda5. For this to work
however requires the partition program to create the "new" partition
at the exact same start/end positions as the originals and is
quite error prone.

BR Håkon Løvdal


More information about the parted-devel mailing list