fixing badly aligned storage

Table of Contents

In the olden days, one would have to manually calculate[1] to get a file system (FS), in a logical volume (LV) that was part of a volume group (VG) living on a software RAID, properly aligned. I would get this calculation wrong in about 10% of the cases.

These days, modern Linux distributions like Fedora 14 and RHEL 6 parse hints from the storage.

But, I had a VG that I had been using since Fedora 9 and it was one of those 10% I calculated wrong. The following steps got me nicely aligned FS (you want 0 in /sys/block/dm-*/alignment_offset at the end of the procedure):

  • plugged in a temporary HD to contain the LVs while re-doing the RAID
  • pvadd the temporary HD
  • if you have swap on an LV, do `swapoff -a` before attempting to pvmove
  • pvmove from the old PV (where alignment_offset is not 0)
  • pvremove old RAID device
  • tear down the badly aligned software RAID
  • remove RAID component partitions
  • set up in F14/RHEL6 (as per docs linked above)
  • pvadd the newly recreated RAID
  • pvmove away from the temp HD
  • pvremove the temp HD
  • check that `/etc/mdadm.conf` does not contain references to the old RAID
Do keep in mind that, depending on where one messed up the manual calculations, the above might not help. YMMW

[1] links I used previously to calculate the offset