====== Advanced Format (4K Sector) Drive Partitioning ======
:!: If in doubt or you just don't want to read this page, start your partition at **sector 2048** (''1MiB'').
**Background**: https://www.ibm.com/developerworks/linux/library/l-linux-on-4kb-sector-disks/
**Great info**: http://petersmithphotog.no-ip.biz/wiki/index.php/Partition_Alignment
:!: This information is equally or more important for SSD's as it is for spinning hard drives.
===== Partition Alignment and 4K Sector Disk Drives =====
http://www.ibm.com/developerworks/linux/library/l-4kb-sector-disks/index.html
The physical sector layout of Advanced Format (4K sector) drives cannot be reliably detected by OS utilities. Check the manufacturer's web site to determine if you have an Advanced Format drive.
There may also be a label on the drive advising that it is an Advanced Format drive.
**A simple rule to go by for creating properly aligned partitions on AF drives:**
Verify that every partition begins on a **sector** which is a multiple of 8. If your partitioning tool is showing **bytes**, make sure the beginning is divisible by 4096, the new Advanced Format sector size.
This is because ''8 x 512 = 4096''. (ie.the new 4K sector size is 8 times the old 512 byte sector size)
==== Partitioning Tools ====
**''parted''** aligns partitions automatically and supports GPT partition tables.
* Versions of ''parted'' prior to 2.2 defaulted to cylinder-based alignment
* Use ''unit s'' to set older parted to sector-based
* Start first partition at ''1M'' to assure proper alignment
* ''1M'' equals ''2048s'' with 512-byte blocks
* Additional partitions will also be aligned
* Using the graphical ''gparted'', be sure to clear the "Round to cylinders" check box in the Create New Partition dialog box
**''fdisk''** still uses cylinder-based alignment and does not support GPT partition tables.
* Newer versions of ''fdisk'' default to using ''2048s'' as the starting point
* Creates aligned partitions
* Same default as newer Windows
===== Partitions over 2TB =====
http://rainbow.chard.org/2013/01/30/how-to-align-partitions-for-best-performance-using-parted/
http://h10025.www1.hp.com/ewfrf/wc/document?docname=c03479326&cc=us&dlc=en&lc=en
http://www.ibm.com/developerworks/linux/library/l-gpt/
http://www.cyberciti.biz/tips/fdisk-unable-to-create-partition-greater-2tb.html
**For RAID arrays**: http://ubuntuforums.org/archive/index.php/t-1715375.html
Install ''parted'' if it's not already installed:
yum install parted
==== Display Partitions ====
parted /dev/sdb print
or
parted /dev/sdb
(parted) unit s
(parted) p
Note the partition alignment by verifying the start point is **divisible by 8**.
Model: ATA OCZ-AGILITY2 (scsi)
Disk /dev/sda: 78161328s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 2048s 24578047s 24576000s primary ext4 boot
2 24578048s 49154047s 24576000s primary ext4
3 49154048s 73730047s 24576000s primary ext4
4 73730048s 78159871s 4429824s primary linux-swap(v1)
You can easily check for the correct alignment in ''parted'' by using the command
(parted) align-check opt 1
where '1' is the number of the partition you want to check for correct alignment.
==== Partition the Drive ====
Common filesystems:
* ''ext3''
* ''ext4''
* ''xfs''
''mkpart'' command syntax:
mkpart PART-TYPE [FS-TYPE] START END
:!: Many newer partition tools make the assumption that ''2048s'' (or ''1MiB'') is a fairly safe assumption to create an aligned partition. This is not always true, but is very common. See here for more info: https://communities.netapp.com/message/97449
This partitions a 'data' drive with a single large, properly aligned, primary partition that will have an XFS filesystem:
parted /dev/sdb
(parted) mklabel gpt
(parted) u s
(parted) mkpart primary xfs 0% 100%
(parted) p
(parted) q
===== Create the Filesystem =====
The XFS filesystem is a good choice for very large disks.
This example creates an XFS filesystem labelled 'Backup':
mkfs.xfs -L Backup /dev/sdx1
==== Enable XFS on CentOS 5 ====
yum --enablerepo=centosplus install kmod-xfs xfsdump xfsprogs dmapi
==== Enable XFS on CentOS 6 ====
yum install xfsdump xfsprogs