2

I'm having a little trouble getting parted 3.2 to accept a partitioning scheme that was valid in parted 2.3 (tested on Debian with jessie vs. wheezy).

parted 3.2 will not accept a partition that goes all the way to the end of a volume (marker 1024MiB on a volume with size 1024MiB), instead it errors out with:
Error: The location 1024MiB is outside of the device /dev/loop0.

Here is a little script to reproduce (also happens when using GPT):

#!/bin/bash -x
truncate disk.raw --size="1024M"
device_path="$(losetup -f --show disk.raw)"
parted --script --align none $device_path -- mklabel msdos
parted --script --align none $device_path -- unit mib print free
parted --script --align none $device_path -- mkpart primary 0MiB 1024MiB
losetup -d $device_path
rm disk.raw

Output with parted 2.3

+ truncate disk.raw --size=1024M
++ losetup -f --show disk.raw
+ device_path=/dev/loop0
+ parted --script --align none /dev/loop0 -- mklabel msdos
+ parted --script --align none /dev/loop0 -- unit mib print free
Model:  (file)
Disk /dev/loop0: 1024MiB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start    End      Size     Type  File system  Flags
        0.02MiB  1024MiB  1024MiB        Free Space

+ parted --script --align none /dev/loop0 -- mkpart primary 0MiB 1024MiB
+ losetup -d /dev/loop0
+ rm disk.raw

Output with parted 3.2

+ truncate disk.raw --size=1024M
++ losetup -f --show disk.raw
+ device_path=/dev/loop0
+ parted --script --align none /dev/loop0 -- mklabel msdos
+ parted --script --align none /dev/loop0 -- unit mib print free
Model: Loopback device (loopback)
Disk /dev/loop0: 1024MiB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start    End      Size     Type  File system  Flags
        0.03MiB  1024MiB  1024MiB        Free Space

+ parted --script --align none /dev/loop0 -- mkpart primary 0MiB 1024MiB
Error: The location 1024MiB is outside of the device /dev/loop0.
+ losetup -d /dev/loop0
+ rm disk.raw

As you can see 3.2 differs slightly in where the partition starts, but that shouldn't make a difference since mkpart only accepts [start] [end] and not [start] [size].

There are of course workarounds for this, like making the last partition smaller or making the volume larger, but I would like to get to the bottom of this and understand why this happens.

1 Answer 1

2

Well, technically, 1024MiB is outside if it's only 1024MiB large and you consider the end to be inclusive...

Try unit s and print free, that should you show exactly what's available to the sector and let you create a maximum size partition. It probably won't show correctly with unit mib since there's too much rounding going on.

Also, you can just use 100% for the [end]; although it might still leave some sectors free anyway, probably due to alignment?

Also with GPT partition scheme, you won't be able to go all the way to the end since there is a secondary GPT header located there.

Leaving a bit free at the end also makes sense for other reasons, not all drives have the exact same size and even if you still use msdos partitions now you might want to be able to convert them to GPT at a later point in time.

2
  • Thank you. I wouldn't ever consider the end inclusive though - just like the 30cm on a ruler marks the beginning of the 30th centimeter :-) The reason I'm not using 100% is because I have the partitions abstracted through a linked list where each partition only knows about the previous one (bit.ly/1z9QCfq). I sense that I will probably have to abstract things into sectors if I want to be precise.
    – andsens
    Dec 14, 2014 at 12:50
  • You could always report it as a bug... maybe it is supposed to work after all, if it used to work in an older version... who knows? Dec 14, 2014 at 13:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .