In the world of computer data is more important and with increase in internet users it’s increasing very fast and hence now storing data is most challenging task.Now it is not good to store your data on single drive when you know your data is important,because in case of disk failure your data will loss and it will be a huge disaster.So in place of storing data on a single disk it will be intelligent decision to store your data on multiple disk such that if one disk fails your data is still safe on second disk.
Also Read:
How to configure and Delete LVM in Linux.
There are two technology or you can say there are two methods commonly used to store data on multiple disk:
(1)One is to strore data on multiple disk through RAID and
(2)other is through LVM.
Since LVM provides us more flexblity in handling disk and managing data,so most of us prefer configuring LVM.
In This article i have mentioned how to create and configure mirrored logical volume.here we learn the fundamental concept of LVM Mirroring and also learn to create,manage ad maintain LVM mirror in Linux in few simple steps.
While writing this article i assume that you already know how to create partition in linux.But if you don’t know or you a new user you can read our below article.
Read:HOW TO CREATE PARTITION IN LINUX.
Read:HOW TO CREATE STRIPED LOGICAL VOLUME IN LINUX
MIRRORED LOGICAL VOLUME:
Before learning how to create or configure mirrored LVM just have few words about mirrored LVM.When we are using the word mirror it means it maintains identical copies of data on different devices.So in Mirrored Logical Volume when data is written to one device,it is written to a second device as well and hence mirroring the data,which provides protection in case of device failure.
So you will be excited to know what will happen if one leg of mirror fails?
Answer is if one leg of mirror fails the logical volume becomes a Linear Volume and we can still access data.
Note:In above diagram you can see a LOG sector which is used by LVMto keep track of which regions are in syc with the mirror or mirrors.
STEP 1:After creating partitions create Physical Volumes using pvcreate.
[root@localhost ~]# pvcreate /dev/sda{5,6,7,8}
Now see physical volume attributes using pvs command.
[root@localhost ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 lvm2 a- 196.76m 196.76m
/dev/sda6 lvm2 a- 203.92m 203.92m
/dev/sda7 lvm2 a- 407.87m 407.87m
/dev/sda8 lvm2 a- 203.92m 203.92m
STEP 2:Now create Volume Group named “mirror_vg00” using above physical volumes.
[root@localhost ~]# vgcreate mirror_vg /dev/sda{5,6,7,8}
Volume group “mirror_vg” successfully created
Display volume group attributes.
[root@localhost ~]# vgs
VG #PV #LV #SN Attr VSize VFree
mirror_vg 4 0 0 wz–n- 996.00m 996.00m
STEP 3:Now Create a Mirrored LVM.
[root@localhost ~]# lvcreate -L 200M -m1 -n mirror_lv mirror_vg
Logical volume “mirror_lv” created
Display mirrored LVM attributes:
[root@localhost ~]# lvs -a -o +devices
LV VG Attr LSize Origin Snap% Move Log Copy% Convert Devices
mirror_lv mirror_vg mwi-a- 200.00m mirror_lv_mlog 100.00 mirror_lv_mimage_0(0),mirror_lv_mimage_1(0)
[mirror_lv_mimage_0] mirror_vg iwi-ao 200.00m /dev/sda6(0)
[mirror_lv_mimage_1] mirror_vg iwi-ao 200.00m /dev/sda7(0)
[mirror_lv_mlog] mirror_vg lwi-ao 4.00m /dev/sda5(0)
STEP 4: Create File system and mount and confirm mounting of Mirrored LVM.
[root@localhost ~]# mkdir /mirror
[root@localhost ~]# mkfs.ext4 /dev/mirror_vg/mirror_lv
[root@localhost ~]# mount /dev/mirror_vg/mirror_lv /mirror/
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 9.7G 2.8G 6.4G 31% /
tmpfs 504M 524K 504M 1% /dev/shm
/dev/mapper/mirror_vg-mirror_lv
194M 5.6M 179M 4% /mirror
Now Learn how to Delete or Destroy Mirrored LVM.
Step1:Unmount LVM
[root@localhost ~]# umount /mirror/
Step2:Check and confirm your Unmount
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 9.7G 2.8G 6.4G 31% /
tmpfs 504M 524K 504M 1% /dev/shm
Step3:Remove mirrored lvm.
[root@localhost ~]# lvremove /dev/mirror_vg/mirror_lv
Do you really want to remove active logical volume mirror_lv? [y/n]: y
Logical volume “mirror_lv” successfully removed
Step5:Confirm removal of LVM using lvs
[root@localhost ~]# lvs
Step6:Remove volume group and confirm its removal.
[root@localhost ~]# vgremove /dev/mirror_vg
Volume group “mirror_vg” successfully removed
[root@localhost ~]# vgs
No volume groups found
Step7:Check physical volume,if exist them remove it using pvremove and then confirm its removal.
[root@localhost ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 lvm2 a- 196.76m 196.76m
/dev/sda6 lvm2 a- 203.92m 203.92m
/dev/sda7 lvm2 a- 407.87m 407.87m
/dev/sda8 lvm2 a- 203.92m 203.92m
[root@localhost ~]# pvremove /dev/sda{5,6,7,8}
Labels on physical volume “/dev/sda5” successfully wiped
Labels on physical volume “/dev/sda6” successfully wiped
Labels on physical volume “/dev/sda7” successfully wiped
Labels on physical volume “/dev/sda8” successfully wiped
If you like it share it!
If you have any doubts feel free to ask through comment section.
If you have any suggestion,You welcome! just mention your valuable suggestion through comments.