Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Create RAID with LVM

Many Linux users have created RAID arrays using mdadm and do not realize that you can also create a RAID array without it by using LVM.

Installing LVM

You may need to install the LVM packages in order to build these arrays.

sudo apt-get install lvm2  

Creating RAID 0

sudo vgcreate [vg name] /dev/sd[x]1 /dev/sd[x2]1 ...
lvcreate -i[num drives] -I[strip size] -l100%FREE -n[lv name] [vg name]
sudo mkfs.[ext4/xfs] /dev/[vg name]/[lv name]
  • Stripe size needs to be a number of the power 2, starting with 4. E.g. 4, 8, 16, 32, 64. If your data is mostly small text files, then use 4. If you are mostly dealing with media then you may want something larger.
  • If you want to use the xfs filesystem, you may need to install xfprogs with sudo apt-get install xfsprogs -y

Creating this RAID array will remove the ability to remove a drive from the VOLUME group later.

Creating RAID 1 (Mirror)


sudo vgcreate VG_NAME /dev/sd[x]1 /dev/sd[x]1

sudo lvcreate \
  --mirrors 1 \
  --type raid1 \
  -l 100%FREE \
  --nosync \

sudo mkfs.[ext4/xfs] /dev/$VG_NAME/$LV_NAME

Creating RAID 5 (Parity)


sudo vgcreate $VG_NAME /dev/sd[x]1 /dev/sd[x]1 /dev/sd[x]1

sudo lvcreate \
  --type raid5 \
  -l 100%FREE \
  --nosync \

sudo mkfs.[ext4/xfs] /dev/$VG_NAME/$LV_NAME


If you have any type of raid other than RAID 0, then you can scrub the data every now and then to prevent bitrot.


Last updated: 16th August 2018
First published: 16th August 2018