Aligning disks of virtual machines with the underlying storage system is very important as it helps in the I/O performance. Lets examine aligning an existing misaligned disk on a Linux (Redhat/ CentOS). For NetApp NFS we have to change the starting sector on linux partition to 64 (63 by default). For more information about alignment and recommendations look up NetApp documentation.
Scenario
We have a Logical volume VolGroup01 with 1 disk /dev/sdb which is not aligned with the underlying storage system.
Plan to fix this.
We will add a disk of same size to the VM let say its /dev/sdc.
We partition it with the proper alignment
Add this to the VolGroup01
Move data from /dev/sdb to this new disk
Remove /dev/sdb from the VolGroup01
Remove the disk from the VM.
The process.
Checking the existing disk which which is misaligned.
# sfdisk -uS -l /dev/sdb
Disk /dev/sdb: 13054 cylinders, 255 heads, 63 sectors/track
Units = sectors of 512 bytes, counting from 0
Device Boot Start End #sectors Id System
/dev/sdb1 63 209712509 209712447 8e Linux LVM
/dev/sdb2 0 - 0 0 Empty
/dev/sdb3 0 - 0 0 Empty
/dev/sdb4 0 - 0 0 Empty
Formating the New Disk
# fdisk /dev/sdc
Command (m for help): u
Changing display/entry units to sectors
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First sector (63-209715199, default 63): 64
Last sector, +sectors or +size{K,M,G} (64-209715199, default 209715199):
Using default value 209715199
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
Checking New Disk partition
# sfdisk -uS -l /dev/sdc
Disk /dev/sdc: 13054 cylinders, 255 heads, 63 sectors/track
Units = sectors of 512 bytes, counting from 0
Device Boot Start End #sectors Id System
/dev/sdc1 64 209715199 209715136 8e Linux LVM
/dev/sdc2 0 - 0 0 Empty
/dev/sdc3 0 - 0 0 Empty
/dev/sdc4 0 - 0 0 Empty
# pvcreate /dev/sdc1
Writing physical volume data to disk "/dev/sdc1"
Physical volume "/dev/sdc1" successfully created
# vgextend VolGroup01 /dev/sdc1
Volume group "VolGroup01" successfully extended
#pvmove /dev/sdb1
This will move all data off of the old disk to the new disk. This process will take time depending on the size of the disk.
#vgreduce VolGroup01 /dev/sdb1
Removed "/dev/sdb1" from volume group "VolGroup01"
Remove the other non-aligned disk from the VM after shutting down the VM.
Now the disks are aligned.
In VMware after reboot the disk label changes so checking the alignment on the renamed disk /dev/sdc is re-labeled as /dev/sdb
#sfdisk -uS -l /dev/sdb
Disk /dev/sdb: 13054 cylinders, 255 heads, 63 sectors/track
Units = sectors of 512 bytes, counting from 0
Device Boot Start End #sectors Id System
/dev/sdb1 64 209715199 209715136 8e Linux LVM
/dev/sdb2 0 - 0 0 Empty
/dev/sdb3 0 - 0 0 Empty
/dev/sdb4 0 - 0 0 Empty
Scenario
We have a Logical volume VolGroup01 with 1 disk /dev/sdb which is not aligned with the underlying storage system.
Plan to fix this.
We will add a disk of same size to the VM let say its /dev/sdc.
We partition it with the proper alignment
Add this to the VolGroup01
Move data from /dev/sdb to this new disk
Remove /dev/sdb from the VolGroup01
Remove the disk from the VM.
The process.
Checking the existing disk which which is misaligned.
# sfdisk -uS -l /dev/sdb
Disk /dev/sdb: 13054 cylinders, 255 heads, 63 sectors/track
Units = sectors of 512 bytes, counting from 0
Device Boot Start End #sectors Id System
/dev/sdb1 63 209712509 209712447 8e Linux LVM
/dev/sdb2 0 - 0 0 Empty
/dev/sdb3 0 - 0 0 Empty
/dev/sdb4 0 - 0 0 Empty
Formating the New Disk
# fdisk /dev/sdc
Command (m for help): u
Changing display/entry units to sectors
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First sector (63-209715199, default 63): 64
Last sector, +sectors or +size{K,M,G} (64-209715199, default 209715199):
Using default value 209715199
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
Checking New Disk partition
# sfdisk -uS -l /dev/sdc
Disk /dev/sdc: 13054 cylinders, 255 heads, 63 sectors/track
Units = sectors of 512 bytes, counting from 0
Device Boot Start End #sectors Id System
/dev/sdc1 64 209715199 209715136 8e Linux LVM
/dev/sdc2 0 - 0 0 Empty
/dev/sdc3 0 - 0 0 Empty
/dev/sdc4 0 - 0 0 Empty
# pvcreate /dev/sdc1
Writing physical volume data to disk "/dev/sdc1"
Physical volume "/dev/sdc1" successfully created
# vgextend VolGroup01 /dev/sdc1
Volume group "VolGroup01" successfully extended
#pvmove /dev/sdb1
This will move all data off of the old disk to the new disk. This process will take time depending on the size of the disk.
#vgreduce VolGroup01 /dev/sdb1
Removed "/dev/sdb1" from volume group "VolGroup01"
Remove the other non-aligned disk from the VM after shutting down the VM.
Now the disks are aligned.
In VMware after reboot the disk label changes so checking the alignment on the renamed disk /dev/sdc is re-labeled as /dev/sdb
#sfdisk -uS -l /dev/sdb
Disk /dev/sdb: 13054 cylinders, 255 heads, 63 sectors/track
Units = sectors of 512 bytes, counting from 0
Device Boot Start End #sectors Id System
/dev/sdb1 64 209715199 209715136 8e Linux LVM
/dev/sdb2 0 - 0 0 Empty
/dev/sdb3 0 - 0 0 Empty
/dev/sdb4 0 - 0 0 Empty