[Git-commits] [grml/grml-debootstrap] 7b2b4c: VMs: create partition with alignment starting at 4...

Michael Prokop noreply at github.com
Tue Dec 7 08:55:55 CET 2021


  Branch: refs/heads/master
  Home:   https://github.com/grml/grml-debootstrap
  Commit: 7b2b4c88dba2687cef0b511dd474160bf7ebd480
      https://github.com/grml/grml-debootstrap/commit/7b2b4c88dba2687cef0b511dd474160bf7ebd480
  Author: Michael Prokop <mika at grml.org>
  Date:   2021-12-06 (Mon, 06 Dec 2021)

  Changed paths:
    M grml-debootstrap

  Log Message:
  -----------
  VMs: create partition with alignment starting at 4MiB + ending at 100%

Our partition creation process inside VMs used parted with "mkpart
primary ext4 2M -1", which could end up with unaligned partitions (as
reported in #185):

| (parted) mkpart primary ext4 2M -1
| Warning: The resulting partition is not properly aligned for best performance: 3906s % 4096s != 0s

This depends on the I/O settings of the underlying storage.

The mkpart start at "2M" is interpreted as 2 Megabyte (2000000 bytes or
3906 sectors) from the disk start.  The end "-1" is interpreted as 1
Megabyte (1000000 bytes or 1953 sectors) before the disk end.

On the other hand, "2MiB" is interpreted as 2 Mebibyte (2097152 bytes or
4096 sectors) from the disk start, and "100%" is interpreted as the disk
end.

Quoting from https://www.gnu.org/software/parted/manual/html_node/unit.html:

| Parted will compute sensible ranges for the locations you specify (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.
| [...]
| 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 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.

Furthermore quoting from https://www.gnu.org/software/parted/manual/html_node/mkpart.html#FOOT2:

| Cheap flash drives will be with us for a long time to come, and, for
| them, 1MiB alignment is not enough. Use at least 4MiB-aligned
| partitions. For details, see Arnd Bergman’s article,
| http://lwn.net/Articles/428584/ and its many comments.

A better default should be usage of an IEC binary unit with a
4MiB-aligned partition, so let's switch to "4MiB 100%".

Thanks: David Gnedt for the bug report and analysis, Darshaka Pathirana and Chris Hofstaedtler for further information and feedback
Closes: grml/grml-debootstrap#185


  Commit: 3da69b03791880fa5fa19c749e30c310cafa4f2e
      https://github.com/grml/grml-debootstrap/commit/3da69b03791880fa5fa19c749e30c310cafa4f2e
  Author: Michael Prokop <mika at grml.org>
  Date:   2021-12-07 (Tue, 07 Dec 2021)

  Changed paths:
    M grml-debootstrap

  Log Message:
  -----------
  Merge remote-tracking branch 'origin/pr/190'


Compare: https://github.com/grml/grml-debootstrap/compare/ea978f623109...3da69b037918


More information about the Git-commits mailing list