LVM Alignment

by Frequent Contributor on ‎2010-12-22 09:34 AM

Additional Steps for Correcting Misalignment of Linux Data Disks Using LVM

Below are the steps to correct misalignment on Linux VMs that utilize LVM for the data disks. Note: The examples assume sdc to be the existing disk with a misaligned guest OS partition and sdd to be the new disk. Your configuration may vary.

  1. Create NetApp Snapshot of the datastore volume
  2. Add new VMDK to VM
  3. FDISK to create new aligned partition
    1. fdisk /dev/sdd
      1. u
      2. n
      3. p
      4. 1
      5. 64
      6. <enter>
      7. w
  4. Create a new PV
    1. pvcreate /dev/sdd1
  5. Extend VG
    1. vgextend lm /dev/sdd1
  6. PVMOVE
    1. pvmove /dev/sdc1 /dev/sdd1
  7. Reduce VG
    1. vgreduce lm /dev/sdc1
  8. Destroy old PV
    1. pvremove /dev/sdc1
  9. Remove old disk from VM
  10. Destroy NetApp Snapshot of the datastore volume after verifying that the VM is operating correctly

Backout Plan

  1. Create FlexClone from NetApp Snapshot taken prior to alignment
  2. Mount FlexClone as a datastore
  3. Power off VM
  4. Rename VM directory
  5. Copy VM directory from FlexClone datastore to original datastore
  6. Power on VM
  7. Verify VM operation is normal
  8. Dismount FlexClone datastore
  9. Destroy FlexClone
  10. Destroy NetApp Snapshot taken prior to alignment

Additional Steps for Correcting Misalignment of Linux Boot Disks Using LVM

Below are the steps to correct misalignment on Linux VMs that utilize LVM for the Boot disks. Note: The examples assume sdc to be the existing disk with a misaligned guest OS partition on sdc5 and sdd to be the temp disk. Your configuration may vary.

Create NetApp Snapshot of the datastore volume

Add new VMDK (temp disk) to VM (if the new disk is not automatically detected, execute ls /sys/class/scsi_host/ then echo - - - >/sys/class/scsi_host/Host#/scan where Host# is the output of the previous command)

  1. Create a new PV
    • pvcreate /dev/sdd
  2. Extend VG
    • vgextend lm /dev/sdd
  3. PVMOVE
    • pvmove /dev/sdc5 /dev/sdd
  4. Reduce VG
    • vgreduce lm /dev/sdc5
  5. Destroy old PV
    • pvremove /dev/sdc5
  6. FDISK to create new aligned partition
    • fdisk /dev/sdc
      • u
      • n
      • l
      • <any number evenly divisible by 8>
      • <enter>
      • w
  7. Probe to update partition table
    • partprobe
  8. Create a new PV
    • pvcreate /dev/sdc5
  9. Extend VG
    • vgextend lm /dev/sdc5
  10. PVMOVE
    • pvmove /dev/sdd /dev/sdc5
  11. Reduce VG
    • vgreduce lm /dev/sdd
  12. Destroy old PV
    • pvremove /dev/sdd
  13. Remove temp disk from VM
  14. Destroy NetApp Snapshot of the datastore volume after verifying that the VM is operating correctly
Comments

Great article! Helped me a lot. I am currently developing a variation of you procedure for disks using a normal ext3 partition and a LVM partition. When it's final I'll post on comment. Regards, Pedro.

Hi! Here's the procedure I mentioned: http://communities.netapp.com/docs/DOC-12170

Regrds,

Pedro.

Member

Is there a way to verify if the LVM partition is properly aligned?

Is there a command you can use to check alignment?

How do you know if alignment has fixed?

Can the mbralign tool verify alignment?

Hello,

Yes you can check alignment with mbralign. You can do that with LVM or non LVM partitions. mbralign will give you if some partition is or isn't aligned.

Check my document for more tips:http://communities.netapp.com/docs/DOC-12170

Regards,

Pedro.

Warning!

This NetApp Community is public and open website that is indexed by search engines such as Google. Participation in the NetApp Community is voluntary. All content posted on the NetApp Community is publicly viewable and available. This includes the rich text editor which is not encrypted for https.

In accordance to our Code of Conduct and Community Terms of Use DO NOT post or attach the following:

  • Software files (compressed or uncompressed)
  • Files that require an End User License Agreement (EULA)
  • Confidential information
  • Personal data you do not want publicly available
  • Another’s personally identifiable information
  • Copyrighted materials without the permission of the copyright owner

Files and content that do not abide by the Community Terms of Use or Code of Conduct will be removed. Continued non-compliance may result in NetApp Community account restrictions or termination.