[Parted-maintainers] Bug#779382: parted: sometimes fails to align new partitions correctly

Andrew T. Young atyoung at mail.sdsu.edu
Fri Feb 27 22:26:52 UTC 2015


Package: parted
Version: 2.3-12
Severity: normal

Dear Maintainer,

While using a script to partition a new disk, I found that parted
sometimes starts a new partition 1 sector past the expected position.

Here are the lines from the script that exercise parted, and some
comments and additional information:
--------------- Begin script and parted output ------------------------------

# Writing a blank msdos label on /dev/sdb:
parted -s /dev/sdb mklabel msdos

# Swap partition is number 8


# adding /dev/sdb1, to be mounted on /boot
parted -s /dev/sdb mkpart primary ext4 0% 115MB

# adding /dev/sdb2, to be mounted on /
parted -s /dev/sdb mkpart primary ext4 115MB 20115MB

# adding /dev/sdb3, to be mounted on /tmp
parted -s /dev/sdb mkpart primary ext4 20115MB 23115MB

# adding /dev/sdb4, the extended partition:
parted -s /dev/sdb mkpart extended 23115MB 100%

# adding /dev/sdb5, to be mounted on /home
parted -s /dev/sdb mkpart logical ext4 23115MB 95340MB

# adding /dev/sdb6, to be mounted on /var
parted -s /dev/sdb mkpart logical ext4 95340MB 102840MB

# adding /dev/sdb7, to be mounted on /usr/local
parted -s /dev/sdb mkpart logical ext4 102840MB 122840MB
Warning: The resulting partition is not properly aligned for best performance.

# adding /dev/sdb8 for swap space:
parted -s /dev/sdb mkpart logical linux-swap 122840MB 127840MB

# adding /dev/sdb9, to be mounted on /spare
parted -s /dev/sdb mkpart logical ext4 127840MB 200060MB
Warning: The resulting partition is not properly aligned for best performance.

----------- End of script and parted o/p ------------------------------------

# The resulting partition table, in MB:

Model: ATA WDC WD5000AAKX-2 (scsi)
Disk /dev/sdb: 500108MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start     End       Size      Type      File system  Flags
 1      1.05MB    115MB     114MB     primary
 2      115MB     20115MB   19999MB   primary
 3      20115MB   23115MB   3000MB    primary
 4      23115MB   500108MB  476993MB  extended               lba
 5      23116MB   95340MB   72224MB   logical
 6      95341MB   102840MB  7499MB    logical
 7      102840MB  122840MB  20000MB   logical
 8      122841MB  127840MB  5000MB    logical
 9      127840MB  200060MB  72220MB   logical


The same partition table, in MiB:

Model: ATA WDC WD5000AAKX-2 (scsi)
Disk /dev/sdb: 476940MiB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start      End        Size       Type      File system  Flags
 1      1.00MiB    110MiB     109MiB     primary
 2      110MiB     19183MiB   19073MiB   primary
 3      19183MiB   22044MiB   2861MiB    primary
 4      22044MiB   476940MiB  454896MiB  extended               lba
 5      22045MiB   90923MiB   68878MiB   logical
 6      90924MiB   98076MiB   7152MiB    logical
 7      98076MiB   117149MiB  19073MiB   logical
 8      117150MiB  121918MiB  4768MiB    logical
 9      121918MiB  190792MiB  68874MiB   logical


The same partition table, in sectors:

Model: ATA WDC WD5000AAKX-2 (scsi)
Disk /dev/sdb: 976773168s
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start       End         Size        Type      File system  Flags
 1      2048s       225279s     223232s     primary
 2      225280s     39286783s   39061504s   primary
 3      39286784s   45146111s   5859328s    primary
 4      45146112s   976773119s  931627008s  extended               lba
 5      45148160s   186210303s  141062144s  logical
 6      186212352s  200859647s  14647296s   logical
 7      200859649s  239921875s  39062227s   logical
 8      239923200s  249688063s  9764864s    logical
 9      249688065s  390742187s  141054123s  logical


Notice that partitions 7 and 9 begin on an odd-numbered sector!

It appears that parted added 1 *twice* to the last sector in partition 6:

200859647 +1 = 200859648 ; and

factor 200859648
200859648: 2 2 2 2 2 2 2 2 2 2 2 2 2 3 11 743

So 200859648 would have been a good place to start the next partition.


Similarly, for partition 9:

factor 249688064
249688064: 2 2 2 2 2 2 2 2 2 2 2 2 47 1297


A curious feature of this bug is that parted returned 0 after reporting
this mis-alignment, either with no alignment option, or with -a opt .
However, it *does* produce an error return with -a min .



-- System Information:
Debian Release: 7.8
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 3.2.0-4-686-pae (SMP w/2 CPU cores)
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  libblkid1           2.20.1-5.3
ii  libc6               2.13-38+deb7u8
ii  libdevmapper1.02.1  2:1.02.74-8
ii  libparted0debian1   2.3-12
ii  libreadline6        6.2+dfsg-0.1
ii  libtinfo5           5.9-10
ii  libuuid1            2.20.1-5.3

parted recommends no packages.

Versions of packages parted suggests:
ii  parted-doc  2.3-12

-- no debconf information



More information about the Parted-maintainers mailing list