HOW TO CONFIGURE RAID OVER LOOP DEVICES WITH SPARE DEVICE AND LVM OVER RAID

 

In this article we will learn how to create raid with spare devices and lvm over that raid 

Mainly we use spare devices when our active device fails then it automatically use spare devices so that our work  should not stop.

raid with spare device

Follow these steps to configure :

  • First we create four files, give file size by disk dumping(dd) and convert into loop device.
[root@localhost ~]# touch a.txt
[root@localhost ~]# touch b.txt
[root@localhost ~]# touch c.txt
[root@localhost ~]# touch d.txt
[root@localhost ~]# dd if=/dev/zero of=a.txt bs=1M count=500
500+0 records in
500+0 records out
524288000 bytes (524 MB) copied, 2.33079 seconds, 225 MB/s

[root@localhost ~]# dd if=/dev/zero of=b.txt bs=1M count=500
500+0 records in
500+0 records out
524288000 bytes (524 MB) copied, 4.2383 seconds, 124 MB/s

[root@localhost ~]# dd if=/dev/zero of=c.txt bs=1M count=500
500+0 records in
500+0 records out
524288000 bytes (524 MB) copied, 4.48607 seconds, 117 MB/s

[root@localhost ~]# dd if=/dev/zero of=d.txt bs=1M count=500
500+0 records in
500+0 records out
524288000 bytes (524 MB) copied, 2.37018 seconds, 221 MB/s
[root@localhost ~]# losetup /dev/loop0 a.txt
[root@localhost ~]# losetup /dev/loop1 b.txt
[root@localhost ~]# losetup /dev/loop2 c.txt
[root@localhost ~]# losetup /dev/loop3 d.txt
  • After creating loop device we will add raid5 with /dev/loop3 as spare device
[root@localhost ~]# mdadm --create /dev/md5 --level=5 --raid-devices=3 /dev/loop0 /dev/loop1 /dev/loop2 --spare-devices=1 /dev/loop3

mdadm: array /dev/md5 started.
[root@localhost ~]# cat /proc/mdstat
md5 : active raid5 loop2[4] loop3[3](S) loop1[1] loop0[0]
      1023872 blocks level 5, 64k chunk, algorithm 2 [3/2] [UU_]
      [======>..............]  recovery = 33.0% (169728/511936) finish=2.7min speed=2055K/sec
  • You can see raid 5 is active spare device in above coding
  • Now we will convert this raid5 into physical volume and create volume group above that.
[root@localhost ~]# pvcreate /dev/md5
  Physical volume "/dev/md5" successfully created
[root@localhost ~]# vgcreate vg00 /dev/md5
  Volume group "vg00" successfully created
  • After creating volume group our next step is going to be creating logical volume
[root@localhost ~]# lvcreate -L +300M -n lv1 vg00
  Logical volume "lv1" created
[root@localhost ~]# lvcreate -L +500M -n lv2 vg00
  Logical volume "lv2" created

So this is how we can configure raid over loop device with spare devices and lvm over raid

WHAT IS LOOP DEVICE AND HOW TO CONFIGURE

HOW TO CONFIGURE SWAP OVER LVM

HOW TO CREATE RAID OVER LOOP DEVICE

2 thoughts on “HOW TO CONFIGURE RAID OVER LOOP DEVICES WITH SPARE DEVICE AND LVM OVER RAID

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s