[CentOS] ext4, 4k sector alignment
szymans at agh.edu.pl
Tue Jul 26 08:11:57 UTC 2011
On 2011-07-25 19:10, Les Mikesell wrote:
> My questions for any filesystem experts are:
> Is there a way to adjust the existing md partitions to get the right
> alignment for 4k sectors without having to do a file-oriented copy to
> new partitions? A resize + a dd copy to shift the position might be
> feasible time-wise if that would work.
I think so. Your partition starts at sector 63, you need anything
divisible by 8, so:
- 64 is my expectation,
- 56 is a fallback solution if the partition does not fit on the disk
with 64 sector offset
- 2048 would be perfect (1M alignment is currently preferred by Centos 6
and many other OSs)
To be on the safe side, take the disk out of the array (mdadm -f
/dev/md0 /dev/sdX1 ; mdadm -r /dev/md0 /dev/sdX1) and clear superblock
using mdadm --zero-superblock /dev/sdX1.
Then repartition the disk using fdisk using the following commands:
u -- display units are sectors
c -- no DOS compatibility (== no cyllinder rounding, you definitely
o -- new dos partition table
n -- new partition
p -- primary
1 -- partition 1
64 -- starting offset
1465144065 -- exact size here, because (just to be on the safe side) you
do not want to have a larger partition on a rescue disk than on a base
disk. Your partition sdh1 has 732572001 1k-blocks, as you wrote in one
e-mail, multiply this by 2 (sectors) add 64, (starting offset) subtract
1 because the offset is inclusive. You get 2*732572001+64-1=1465144065.
If fdisk complains that this is too much then offset 64 cannot be used
and you need to repeat the procedure using offset 56 (don't forget to
recalculate ending sector).
t -- type
fd -- linux raid autodetect
mdadm -a /dev/mdX /dev/sdX1
And everything should be fine.
> Is it worth converting to ext4?
I don't know.
> Is there a difference between doing this on 5.6 or 6.x?
Yes, Centos 6 by default aligns partitions on the disk automatically on
1MiB (2048sectors) boundaries. C6 LVM also aligns lv's on 1MiB
boundaries relative to the pv start. Finally md in Centos 6 uses 512KiB
chunks and aligns data on this boundary (default md superblock in Centos
6 Installer is 1.1 so it is on beginning of the partition) so it is also OK.
> If I start over from scratch with 6.x, will the partitioning tools
> automatically align for 4k sector drives (with/without lvm?)?
Yes. But I always check that to be sure :)
More information about the CentOS