Re: ext4, 4k sector alignment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On 7/26/2011 3:11 AM, Andrzej Szymanski wrote:
> 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:
> fdisk /dev/sdX
> u   -- display units are sectors
> c   -- no DOS compatibility (== no cyllinder rounding, you definitely
> want that)
> 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
> w
>
> mdadm -a /dev/mdX /dev/sdX1
>
> And everything should be fine.

Thank you!  That seems to have worked, but now I'm curious as to why the 
partition on the old drives didn't go to the end of the disk - which I 
had expected would have left no extra room.  Was the dos style rounding 
computing the end of a cylinder wrong?

fdisk -lu /dev/sdh (old 3.5")
Disk /dev/sdh: 750.1 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders, total 1465149168 sectors
Units = sectors of 1 * 512 = 512 bytes
Device Boot   Start         End      Blocks   Id  System
/dev/sdh1       63  1465144064   732572001   fd  Linux raid autodetect

fdisk -lu /dev/sdi (new 2.5")
Disk /dev/sdi: 750.1 GB, 750156374016 bytes
1 heads, 1 sectors/track, 1465149168 cylinders, total 1465149168 sectors
Units = sectors of 1 * 512 = 512 bytes
Device Boot  Start         End      Blocks   Id  System
/dev/sdi1    64   1465144065   732572001   fd  Linux raid autodetect

The laptop drive is still slower, but not 10x slower like before.  I did 
try something like this earlier trying for a 56 sector offset but must 
have done something wrong.

-- 
   Les Mikesell
    lesmikesell@xxxxxxxxx



_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos


[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux