Detailed description and configuration of Linux disk partition alignment

Source: Internet
Author: User

What is Disk Partition Alignment and Partition Alignment)

A Windows disk has a structure called Master Boot Record (MBR). Its default size is 63 blocks and each size is 512 bytes ). Its existence makes the initial position of the disk and the initial position of the first partition of the disk have 63 blocks. If a single Track on a disk is larger than 63 blocks. This will cause the default initial position to start from 64th. Make the Track in the file system and the two Track in the disk. This non-alignment will lead to a reduction in the performance of the storage system, because a single I/O Request spans the Track on multiple disks, resulting in additional performance overhead of the storage system. Especially for some applications with relatively large random I/O, the impact will be greater.

For GPT disks supported after Windows 2003, Disk partitions are not aligned, but the structure is different. In the figure 1, the unit is Block, 512 bytes). All partitions are composed of 1 MB and 2048 blocks). The first partition starts from LBA 34, that is, the location of 17KB. This means that all the partitions will be 17KB out of alignment. It also affects I/O read/write performance.

Alignment between the track area of the storage system and the Linux partition

To maximize performance, any I/O to the back-end storage array needs to be structured by configuring appropriate structures to avoid any cross-border I/O operations. If I/O operations span multiple boundaries, additional resource overhead will occur, resulting in performance degradation. Therefore, in order to avoid performance impact caused by non-alignment of partitions. Use the fdisk or parted tool to create and align partitions.

How to select a correct offset value for the disk partition is usually "64KB" for EMC and other vendors ". Why do we need to select the 64 kB value? Here is an explanation. First, let's talk about the concept of a physical track area. For different types of protection levels, we can also say Raid and disk types. The range of this region is different. Here are two examples:

The disk space in the Symmetrix cache is measured in units of 64 blocks and 32 KB. 2. If the disk partition is not aligned, any 32 kb or larger I/O must be performed across two tracks, 50% of 16 kb I/O may span two tracks, and 25% of 8 KB may span two tracks, resulting in additional storage system performance overhead.

 

After reading the first example, the reader may think, just move the start bit to the right of a Block, MBR + Reserved = 63 Block ), there will be no cross-Track I/O. Next, let's look at another example. The size of a single 3 + 1 RAID 5 band is four tracks, namely, 256 blocks and kb. If 64th blocks are used as the starting position for such disks, when the linux I/O size reaches 64 KB, If I/O is directly cached from a single track to 32 KB ), the read is completed exactly twice. However, if two consecutive 64 kB I/O, and the physical disk reading and writing of the backend RAID 5 need to be involved, as shown in, the second 64 kB will occur across the two bands, therefore, the overhead of reading and writing is doubled.

In this case, you need to adjust the starting position to 64 KB), so that the maximum I/O size of Linux will not occur across multiple strips. Figure 3)

Therefore, whether the data is read from the cache of the storage system or the I/O does not exist in the cache, the data needs to be read from the underlying physical disk. For disks of different types, 64 kB starts with a recommended configuration.

How to create partition alignment in Linux

After describing the principle of disk partition alignment, the following describes how to use fdisk to create an alignment partition. In Linux, the alignment partition operation requires NULL data, because the alignment partition operation will clear the partition table and the data on the LUN will be deleted. In this example, we create a 51281 CylinderCylinder for the/dev/emcpowerfw device, which is the unit of measurement for the Symmetrix. The size of each Cylinder is 960KB, so the disk size is about 50 GB) and Offset misaligned 128 block disk devices. Method and command output figure 4)

Method 1: Use fdisk to create partition alignment

Enter:

# Fdisk/dev/emcpowerfw

Enter n to create a partition:

Enter p to create the primary partition:

Enter the start Cylinder position. The default value is the first one:

Enter the last Cylinder location, which is the last Cylinder of the disk device by default:

Enter x to enter the CT mode:

Enter B, the initial location of a certain partition:

Set the initial position to 128 block128 blocks to 64 KB ):

Enter p again to confirm the initial position of the partition:

Enter w to save and exit:

Method 2: Use parted to create an alignment Partition

Compared with fdisk, Parted supports more types of GPT) and larger partition size. The following example shows an example of creating the start position of the 128bloc partition for the dev/sdb disk. The method and command output are as follows: 5)

Enter:

# Parted/dev/sdb

Adjust the display unit to 512 bytes ):

(Parted) unit s

List the current logical volume:

(Parted) print

Remove the original Number1 and create a primary partition with the starting position of 128 sector, which is smaller than 976735934 sector.

(Parted) rm 1

(Parted) mkpart primary 128 976735934

(Parted) print

Reference

Parted command manual and parameters: http://www.gnu.org/software/parted/manual/parted.html#unit

Fdisk command manual and parameters: http://manpages.courier-mta.org/htmlman8/fdisk.8.html

Disk Partition alignment details and configuration-Windows: https://community.emc.com/docs/DOC-18571

Disk Partition alignment details and configuration-Linux: https://community.emc.com/docs/DOC-18666

Address: http://linux.cn/article-3167-1.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.