Easy LVM + Raid

15, Jul, 2009

Needed to put my LVM + Raid notes somewhere, why not here?

We’ll start with 5 Hard drives.
<span style=”font-family: monospace”>/dev/sda$ partitioned, formated, and mounted on /</span><p></p>
Partition the rest as linux raid auto detect
<span style=”font-family: monospace”>/dev/sdb$
/dev/sdc$
/dev/sdd$
/dev/sde$</span><p></p>

Create raid setup with 3 drives. We’ll add the 4th drive later as an example to grow the array.
<span style=”font-family: monospace”>
mdadm –create –verbose /dev/md0 –level=5 –raid-devices=3 /dev/sd{b,c,d}1
cat /proc/mdstat</span><p></p>
create LVM
<span style=”font-family: monospace”>
pvcreate /dev/md0
vgcreate 001 /dev/md0
lvcreate -l 100%FREE -n stuff 001
{lvcreate -l $SIZE -n $VOLUME_NAME $VOLUME_GROUP_NAME}
mkfs.ext4 /dev/001/stuff
</span>
Grow raid array
<span style=”font-family: monospace”>
mdadm –add /dev/md0 /dev/sde1
mdadm –grow /dev/md0 -n 4
{mdadm –grow /dev/md0 -n {number or orig + 1}}
</span>
Resize LVM
<span style=”font-family: monospace”>
pvresize /dev/md0
(pvdisplay)
lvextend -l +100%FREE -n /dev/001/stuff
</span>
Grow file system
<span style=”font-family: monospace”>
umount /mnt/stuff
e2fsck -f /dev/001/stuff
resize2fs /dev/001/stuff</span>

Add comment

Fill out the form below to add your own comments