Raid1 with LVM from scratch

In this manual will be created RAID1 with LVM. In this tutorial, disk are mounted in system as /dev/sdX and /dev/sdY

Prerequisites

 * 2 empty HDDs with same capacity
 * Kernel with LVM
 * lvm2
 * parted

Software
Install lvm2 package

Install parted

Create partitions on both disks with parted

Start parted for /dev/sdX disk

Set units to mib

Create GPT table on disk

Create primary partition, use all available space

Set partition name to raiddata0

Add lvm flag to new partition

Result should be:

Execute same parted commands for /dev/sdY

LVM
Next steps will be to create physical volumes on both disks, add both physical volume to same volume group and create logical volume with raid1 logic

Physical volume
Create physical LVM volumes on first disk on first partition

Create physical LVM volumes on second disk on first partition

Volume group
Include both physical volumes to one volume group with name *raid0vg0*

Now both disks in same volume group.

Logical Volume
Create logical volume with name *raid0lv0* on volume group *raid0vg0* with RAID1 logic, use all available space. --nosync means skip the ini tial synchronization for raid1 (because this is new raid without any data on it)

Now raid1 created on both disks /dev/sdX and /dev/sdY. Last step left - create FS and mount this FS on boot. see section below

Filesystem creation
Create filesystem on VolumeGroup *raid0vg0* on logical volume r*aid0lv0*

Done

Mount filesystem on boot
Run blkid to find UUID of ext4 filesystem on our LVM raid1


 * UUID="10092fa9-43f5-421e-a0a1-ca96323c6388"* is id of our ext4 filesystem on raid1. Last thing is to add fs uuid to fstab

Create mountpoint /mnt/data

Add to fstab mounting