Amazon Web Services/AWS – EBS XFS LVM RAID 10 Array on AWS

How to set up a RAID 10 array on top of EBS using LVM and XFS as the file system.

Create RAID10 array

4 Disks of 8 GB Each – 16 Gigs available for use
[bash]
$ mdadm –verbose –create /dev/md0 –level=10 –chunk=256 –raid-devices=4 /dev/sdf1 /dev/sdf2 /dev/sdf3 /dev/sdf4
$ blockdev –setra 65536 /dev/md0 # [3]
$ mdadm –detail –scan >> /etc/mdadm/mdadm.conf

#16 GB is not a lot of space, You will have to increase this space as your DB grows. For that we need LVM.

# Create a physical volume
$ pvcreate /dev/md0

# Create a volume group
$ vgcreate VOL_GRP_NAME /dev/md0

# Check available Free Physical Extents (Free PE), use that number in next command
$ vgdisplay VOL_GRP_NAME

$ lvcreate –name LOGICAL_VOL_NAME –extents FREE_PE VOL_GRP_NAME

# Create file system
$ mkfs.xfs -f /dev/VOL_GRP_NAME/LOGICAL_VOL_NAME

# Mount newly created partition
$ mount -t xfs -o noatime,noexec,nodiratime /dev/VOL_GRP_NAME/LOGICAL_VOL_NAME /MOUNT_POINT/

# Put an /etc/fstab entry so the partition will mount automatically if you reboot.
$ echo “/dev/VOL_GRP_NAME/LOGICAL_VOL_GRP /MOUNT_POINT xfs noatime,noexec,nodiratime 0 0” >> /etc/fstab

# When you want to increase the size of an array, create another RAID10 array /dev/md1

# Extend Volume Group
$ vgextend VOL_GRP_NAME /dev/md1

# Extend Logical Volume
$ lvextend -l +100%FREE /dev/VOL_GRP_NAME/LOGICAL_VOL_NAME

# Finally you may extend the file system on it
$ xfs_growfs /MOUNT_POINT
[/bash]

Published on: 8 November 2012
Posted by: Sami K.