[Parted-maintainers] Bug#491511: off-by-one: parted should consider cylinders one-indexed rather than zero-indexed

xsdg xsdg at mit.edu
Sun Jul 20 02:48:58 BST 2008


Package: parted
Version: 1.8.8.git.2008.03.24-7
Severity: normal

While trying to manually copy a few entries of the partition table on one drive
to another drive, I run into the following problem, which is likely related to
some discrepancy in how parted sets and/or displays cylinders.

fdisk says:
###############################################################################
#fdisk -l /dev/hda

Disk /dev/hda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1        1216     9767488+  83  Linux
/dev/hda2           14532       14593      498015    5  Extended
/dev/hda3            1217        2432     9767520   83  Linux
/dev/hda4            2433       14531    97185217+  83  Linux
/dev/hda5           14532       14544      104391   83  Linux
/dev/hda6           14545       14593      393561   82  Linux swap / Solaris

Partition table entries are not in disk order
###############################################################################


Note that when displaying, all of the cylinder numbers are shifted toward 0 by
1 cylinder.

###############################################################################
01:28:44> [root{perl}@~]
#parted /dev/hda unit cyl print
Model: WDC WD1200JB-00EVA0 (ide)
Disk /dev/ide/host0/bus0/target0/lun0/disc: 14593cyl
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 14593,255,63.  Each cylinder is 8225kB.
Partition Table: msdos

Number  Start     End       Size      Type      File system  Flags
 1      0cyl      1215cyl   1215cyl   primary   xfs          boot 
 3      1216cyl   2431cyl   1216cyl   primary   xfs               
 4      2432cyl   14530cyl  12099cyl  primary   xfs               
 2      14531cyl  14592cyl  62cyl     extended                    
 5      14531cyl  14543cyl  12cyl     logical   ext2              
 6      14544cyl  14592cyl  48cyl     logical   linux-swap        


01:28:54> [root{perl}@~]
#parted /dev/sdc unit cyl print
Model: ATA MAXTOR STM332062 (scsi)
Disk /dev/scsi/host3/bus0/target0/lun0/disc: 38913cyl
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 38913,255,63.  Each cylinder is 8225kB.
Partition Table: msdos

Number  Start  End  Size  Type  File system  Flags


01:29:06> [root{perl}@~]
#parted /dev/sdc unit cyl mkpart
Partition type?  primary/extended? p                                      
File system type?  [ext2]? xfs                                            
Start? 0                                                                  
End? 1215                                                                 
Information: You may need to update /etc/fstab.                           


01:29:26> [root{perl}@~]
#parted /dev/sdc unit cyl print
Model: ATA MAXTOR STM332062 (scsi)
Disk /dev/scsi/host3/bus0/target0/lun0/disc: 38913cyl
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 38913,255,63.  Each cylinder is 8225kB.
Partition Table: msdos

Number  Start  End      Size     Type     File system  Flags
 1      0cyl   1214cyl  1214cyl  primary                    
###############################################################################

However, looking at the partition table with fdisk again shows what really
happened: gparted assumes that cylinder numbers entered by the user are not
shifted by a cylinder, and thus sets the boundary in a way that (I imagine) is
compatible with fdisk.  The start cylinder is likely clamped to a reasonable
value (namely, "1") somewhere during the write process.

###############################################################################
#fdisk -l /dev/sdc

Disk /dev/sdc: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000385a6

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1        1215     9759456   83  Linux
###############################################################################



The most likely solution to this discrepancy is for gparted to stop pretending
that cylinders are zero-indexed


-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.25 (PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages parted depends on:
ii  libc6             2.7-11                 GNU C Library: Shared libraries
ii  libncurses5       5.6+20071124-1         Shared libraries for terminal hand
ii  libparted1.8-9    1.8.8.git.2008.03.24-7 The GNU Parted disk partitioning s
ii  libreadline5      5.2-3                  GNU readline and history libraries

parted recommends no packages.

Versions of packages parted suggests:
pn  parted-doc                    <none>     (no description available)

-- no debconf information





More information about the Parted-maintainers mailing list