diff options
author | Jim Meyering <meyering@redhat.com> | 2011-02-22 16:12:28 +0100 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2011-03-24 12:54:57 +0100 |
commit | 552805a03a79f7b6badaf26536d86db580360f98 (patch) | |
tree | 32ad117b426c9af4c93053263c95a4ec5f7cc320 /doc | |
parent | 9aff1f202918bc2f4aa958d4744d1216c00ee50c (diff) | |
download | parted-552805a03a79f7b6badaf26536d86db580360f98.tar.gz |
make parted "do what I say" with IEC start and end values like 5GiB
In a command like this,
parted -s -- $dev mklabel gpt mkpart P-NAME 4MB -34s
parted interprets the "4MB" as merely a suggestion for the starting
sector number. It uses half of the MB-units value as a "radius"
about the sector containing byte 4,000,000, and it may choose some
other more appropriate sector, based on partition table or alignment
constraints within the range 3,500,000B..4,500,000B.
Before, parted handled IEC units, i.e., KiB, MiB, GiB, etc.,
with identically "helpful" sloppiness, of course honoring the
power-of-two semantics.
Now, however if you use IEC units, i.e., KiB, MiB, GiB, etc.,
the "radius" is taken to be zero, so parted uses precisely
whatever multiple of a power of two you've specified.
Hence, adjusting the example above to use MiB, rather than "MB",
parted -s -- $dev mklabel gpt mkpart P-NAME 4MiB -34s
With this change, that is equivalent to the following:
parted -s -- $dev mklabel gpt mkpart P-NAME 4194304B -34s
I.e., it uses the sector containing precisely that byte, and
does not perform any "extra" adjustment.
* libparted/unit.c (is_power_of_2): New function.
(ped_unit_parse_custom): Use it to avoid interpreting a large
input string as "sloppy" (i.e. large radius) when it uses IEC
binary notation like 34KiB, 3GiB and 65TiB.
* tests/t0207-IEC-binary-notation.sh: New test.
* tests/Makefile.am (TESTS): Add it.
* doc/parted.texi (unit): Describe the new behavior.
* NEWS (Changes in behavior): Mention it here, too.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/parted.texi | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/doc/parted.texi b/doc/parted.texi index 1a57c07..ecb6574 100644 --- a/doc/parted.texi +++ b/doc/parted.texi @@ -1175,14 +1175,26 @@ which case this unit apply instead of the default unit for this particular number, but CHS and cylinder units are not supported as a suffix. If no suffix is given, then the default unit is assumed. Parted will compute sensible ranges for the locations you specify -(e.g. a range of +/- 500 MB when you specify the location in ``G'') +(e.g. a range of +/- 500 MB when you specify the location in ``G'', +and a range of +/- 500 KB when you specify the location in ``M'') and will select the nearest location in this range from the one you wrote that satisfies constraints from both the operation, the filesystem being worked on, the disk label, other partitions and so on. Use the sector unit ``s'' to specify exact locations (if they do not satisfy all constraints, Parted will ask you for the nearest solution). Note that negative numbers count back from the end of -the disk, with ``-1s'' pointing to the end of the disk. +the disk, with ``-1s'' pointing to the last sector of the disk. + +Note that as of parted-2.4, when you specify start and/or end values +using IEC binary units like ``MiB'', ``GiB'', ``TiB'', etc., parted +treats those values as exact, and equivalent to the same number +specified in bytes (i.e., with the ``B'' suffix), in that it provides +@emph{no} ``helpful'' range of sloppiness. Contrast that with +a partition start request of ``4GB'', which may actually resolve to +some sector up to 500MB before or after that point. +Thus, when creating a partition, you should prefer to specify +units of bytes (``B''), sectors (``s''), or IEC binary units like ``MiB'', +but not ``MB'', ``GB'', etc. Example: |