Installation guide

Chapter 18. Storage I/O Alignment and Size
112
For instance, a 512-byte device and a 4K device may be combined into a single logical DM device,
which would have a logical_block_size of 4K. File systems layered on such a hybrid device
assume that 4K will be written atomically, but in reality it will span 8 logical block addresses when
issued to the 512-byte device. Using a 4K logical_block_size for the higher-level DM device
increases potential for a partial write to the 512-byte device if there is a system crash.
If combining the I/O parameters of multiple devices results in a conflict, the block layer may issue a
warning that the device is susceptible to partial writes and/or is misaligned.
18.5. Logical Volume Manager
LVM provides userspace tools that are used to manage the kernel's DM devices. LVM will shift the
start of the data area (that a given DM device will use) to account for a non-zero alignment_offset
associated with any device managed by LVM. This means logical volumes will be properly aligned
(alignment_offset=0).
By default, LVM will adjust for any alignment_offset, but this behavior can be disabled by
setting data_alignment_offset_detection to 0 in /etc/lvm/lvm.conf. Disabling this is not
recommended.
LVM will also detect the I/O hints for a device. The start of a device's data area will be a multiple of the
minimum_io_size or optimal_io_size exposed in sysfs. LVM will use the minimum_io_size if
optimal_io_size is undefined (i.e. 0).
By default, LVM will automatically determine these I/O hints, but this behavior can be disabled
by setting data_alignment_detection to 0 in /etc/lvm/lvm.conf. Disabling this is not
recommended.
18.6. Partition and File System Tools
This section describes how different partition and file system management tools interact with a
device's I/O parameters.
util-linux-ng's libblkid and fdisk
The libblkid library provided with the util-linux-ng package includes a programmatic API to
access a device's I/O parameters. libblkid allows applications, especially those that use Direct I/
O, to properly size their I/O requests. The fdisk utility from util-linux-ng uses libblkid to
determine the I/O parameters of a device for optimal placement of all partitions. The fdisk utility will
align all partitions on a 1MB boundary.
parted and libparted
The libparted library from parted also uses the I/O parameters API of libblkid. The Red Hat
Enterprise Linux 6 installer (Anaconda) uses libparted, which means that all partitions created by
either the installer or parted will be properly aligned. For all partitions created on a device that does
not appear to provide I/O parameters, the default alignment will be 1MB.
The heuristics parted uses are as follows:
Always use the reported alignment_offset as the offset for the start of the first primary partition.
If optimal_io_size is defined (i.e. not 0), align all partitions on an optimal_io_size boundary.
If optimal_io_size is undefined (i.e. 0), alignment_offset is 0, and minimum_io_size is a
power of 2, use a 1MB default alignment.