Big partitions in Linux (> 2TB).

Manage partitions larger than 2 TeraBytes (for example in large storage arrays)  was something rare some years ago, now with the Mass-Storage-Devices capacity growing tendency it’s quite frequent to need to set-up a so large FileSystem.

First of all: forget to use fdisk:

WARNING: The size of this disk is 8.0 TB (7970004230144 bytes).
DOS partition table format can not be used on drives for volumes
larger than (2199023255040 bytes) for 512-byte sectors.
<strong>Use parted(1) and GUID partition table format (GPT)</strong>.

So let’s use parted, and create a GPT partition:

(parted) mklabel gpt
(parted) mkpart primary 0 100%
<strong>Warning: The resulting partition is not properly aligned for best performance.</strong>
Ignore/Cancel?

Parted uses the following algorithm to determine optimal alignment for newly created partition. If none of the following conditions, 2a, 2b, or 2c are satisfied, then the warning message “The resulting partition is not properly aligned for best performance” would be displayed by parted utility.

  1. Always use the reported alignment offset as offset.
  2. a) If optimal io size is present in the topology info, use that as grain.
    b) If optimal io size is not present in topology info and alignment offset is 0 and minimum io size is a power of 2, use the default optimal alignment (grain 1MiB).
    c) If not 2a and 2b, use the minimum io size, or if that is not defined the physical sector size as grain (iow the minimum alignment).

To generate a partition with the optimal alignment and avoid the warning too, some steps (most of cases) are required:

First of all let’s get the alignment parameters for the storage device (replace sdX with the name of device seen by the kernel).

# cat /sys/block/sdX/queue/optimal_io_size
1048576
# cat /sys/block/sdX/queue/minimum_io_size
262144
# cat /sys/block/sdX/alignment_offset
0
# cat /sys/block/sdX/queue/physical_block_size
512

After that, add optimal_io_size to alignment_offset and divide the result by physical_block_size.
In the example above this was (1048576 + 0) / 512 = 2048.

This value represents the sector at which the partition should start.

The parted command should now look like:

mkpart primary 2048s 100%

(s is not an option, since it specifies to parted that we are talking about sectors)

It is now possible to finally-check the partition alignment (replacing 1 with the partition number if necessary):

(parted) align-check optimal 1
1 aligned

Comments are closed.