RHEL6-21-LOGICAL
VOLUME MANAGER (LVM)-8
LVM OPERATIONS:
VOLUME
RE-LAYOUT:
How to know the
volume layout (Linear, Mirrored and striped) of existing LV’s?
How to change a
linear volume to mirrored volume in LVM?
How to change a stripe
volume to linear volume in LVM?
How to change a mirror
volume to linear volume in LVM?
How to change a
linear volume to stripe volume in LVM?
Well, we had already created LV’s with Linear, Mirrored
and striped volumes.
Now we have to change their layout.
Sounds great, but first question is how do I know that
which LV is created with what layout?
[root@rhel6-client1 ~]# lvs -o segtype,lv_name
Type LV
linear lv01Fvg01
linear lv02Fvg01
linear
testlv01Fvg02
linear
testlv02Fvg02
[root@rhel6-client1 ~]# lvs -o
segtype,devices,lv_name,vg_name
Type Devices LV VG
linear
/dev/sdd2(175) lv01Fvg01 vg01
linear
/dev/sdd2(75) lv02Fvg01 vg01
linear
/dev/sdd5(0) testlv01Fvg02 vg02
linear
/dev/sdd5(75) testlv02Fvg02 vg02
[root@rhel6-client1 ~]# dmsetup status
vg02-testlv01Fvg02: 0 614400 linear
vg01-lv01Fvg01: 0 614400 linear
vg02-testlv02Fvg02: 0 819200 linear
vg01-lv02Fvg01: 0 819200 linear
vg01-testlv01: 0 925696 linear
Now, let’s try to change the layout.
[root@rhel6-client1 ~]# vgs -o
lv_name,vg_name,lv_size,devices,vg_size
LV VG
LSize Devices VSize
lv02Fvg01 vg01 400.00m /dev/sdd2(75) 2.99g
lv01Fvg01 vg01 300.00m /dev/sdd2(175) 2.99g
testlv01Fvg02
vg02 300.00m /dev/sdd5(0) 2.00g
testlv02Fvg02
vg02 400.00m /dev/sdd5(75) 2.00g
LINEAR TO MIRROR:
[root@rhel6-client1 ~]# lvconvert -m 1
/dev/vg01/lv01Fvg01
vg01/lv01Fvg01:
Converted: 2.7%
vg01/lv01Fvg01:
Converted: 100.0%
[root@rhel6-client1 ~]# vgs -o
lv_name,vg_name,lv_size,devices,vg_size
LV VG
LSize Devices VSize
lv02Fvg01 vg01 400.00m /dev/sdd2(75) 2.99g
lv01Fvg01 vg01 300.00m
lv01Fvg01_mimage_0(0),lv01Fvg01_mimage_1(0) 2.99g
testlv01Fvg02
vg02 300.00m /dev/sdd5(0) 2.00g
testlv02Fvg02
vg02 400.00m /dev/sdd5(75) 2.00g
[root@rhel6-client1 ~]# lvs -a -o
devices,lv_name |grep lv01Fvg01
lv01Fvg01_mimage_0(0),lv01Fvg01_mimage_1(0) lv01Fvg01
/dev/sdd2(175)
[lv01Fvg01_mimage_0]
/dev/sdd3(0)
[lv01Fvg01_mimage_1]
/dev/sdd3(75) [lv01Fvg01_mlog]
[root@rhel6-client1 ~]# lvs -a -o
+devices,lv_name |grep lv01Fvg01
lv01Fvg01 vg01 mwi-aom-- 300.00m lv01Fvg01_mlog 100.00 lv01Fvg01_mimage_0(0),lv01Fvg01_mimage_1(0)
lv01Fvg01
[lv01Fvg01_mimage_0] vg01 iwi-aom-- 300.00m
/dev/sdd2(175)
[lv01Fvg01_mimage_0]
[lv01Fvg01_mimage_1] vg01 iwi-aom-- 300.00m /dev/sdd3(0)
[lv01Fvg01_mimage_1]
[lv01Fvg01_mlog] vg01
lwi-aom-- 4.00m
/dev/sdd3(75)
[lv01Fvg01_mlog]
STRIPED TO LINEAR:
[root@rhel6-client1 ~]# lvs -o
segtype,devices,lv_name,vg_name,lv_path
Type Devices LV VG
Path
mirror lv01Fvg01_mimage_0(0),lv01Fvg01_mimage_1(0)
lv01Fvg01 vg01 /dev/vg01/lv01Fvg01
linear /dev/sdd2(75) lv02Fvg01 vg01 /dev/vg01/lv02Fvg01
striped
/dev/sdd2(0),/dev/sdd3(76)
mystripevol01 vg01 /dev/vg01/mystripevol01
linear /dev/sdd5(0) testlv01Fvg02 vg02
/dev/vg02/testlv01Fvg02
linear /dev/sdd5(75) testlv02Fvg02
vg02 /dev/vg02/testlv02Fvg02
[root@rhel6-client1 ~]# mount
/dev/vg01/mystripevol01 /mystripevol01
[root@rhel6-client1 ~]# cd /mystripevol01
[root@rhel6-client1 mystripevol01]# ls -ltr
total 17
drwx------. 2 root root 12288 Apr 4 12:51 lost+found
-rw-r--r--. 1 root root 0 Apr
4 12:52 hh
-rw-r--r--. 1 root root 0 Apr
4 12:52 gg
-rw-r--r--. 1 root root 0 Apr
4 12:52 ff
-rw-r--r--. 1 root root
21 Apr 4 12:52 dd
[root@rhel6-client1 mystripevol01]# cat dd
hi hi hi hi hi hi hi
Unfortunately first we need to make mirror of “mystripevol01”
to convert it to linear.
[root@rhel6-client1 ~]# lvconvert -m 1
/dev/vg01/mystripevol01
Insufficient
suitable allocatable extents for logical volume : 26 more required
Unable to
allocate extents for mirror(s).
[root@rhel6-client1 ~]# pvcreate /dev/sdc1
Physical volume
"/dev/sdc1" successfully created
[root@rhel6-client1 ~]# vgextend vg01 /dev/sdc1
Volume group
"vg01" successfully extended
[root@rhel6-client1 ~]# lvconvert -m 1
--corelog /dev/vg01/mystripevol01
vg01/mystripevol01: Converted: 0.0%/dev/vg01/mystripevol01
vg01/mystripevol01: Converted: 100.0%
[root@rhel6-client1 ~]# lvs -o segtype,lv_name
Type LV
mirror lv01Fvg01
linear lv02Fvg01
mirror
mystripevol01
linear
testlv01Fvg02
linear
testlv02Fvg02
[root@rhel6-client1 ~]# lvs -a -o +devices
|grep mystripevol01
mystripevol01 vg01
mwi-aom-- 104.00m 100.00
mystripevol01_mimage_0(0),mystripevol01_mimage_1(0)
[mystripevol01_mimage_0] vg01 iwi-aom-- 104.00m /dev/sdd2(0),/dev/sdd3(76)
[mystripevol01_mimage_1] vg01 iwi-aom-- 104.00m /dev/sdc1(0)
“mystripevol01” is on /dev/sdd2, /dev/sdd3 &
/dev/sdc1
If we reduce our mirror to 0 by removing disks /dev/sdd2,
/dev/sdd3. Then we have only left disk will /dev/sdc1 and it will automatically
be Linear.
[root@rhel6-client1
~]# lvconvert -m 0 /dev/vg01/mystripevol01 /dev/sdd2 /dev/sdd3
Logical volume
mystripevol01 converted.
[root@rhel6-client1 ~]# lvs -a -o +devices
|grep mystripevol01
mystripevol01 vg01 -wi-ao--- 104.00m
/dev/sdc1(0)
[root@rhel6-client1 ~]# lvs -o segtype,lv_name
Type LV
mirror lv01Fvg01
linear lv02Fvg01
linear
mystripevol01 ççç
linear
testlv01Fvg02
linear testlv02Fvg02
[root@rhel6-client1 ~]#
[root@rhel6-client1 ~]# cd /mystripevol01
[root@rhel6-client1 mystripevol01]# ls -l
total 17
-rw-r--r--. 1 root root
21 Apr 4 12:52 dd
-rw-r--r--. 1 root root 0 Apr
4 12:52 ff
-rw-r--r--. 1 root root 0 Apr
4 12:52 gg
-rw-r--r--. 1 root root 0 Apr
4 12:52 hh
drwx------. 2 root root 12288 Apr 4 12:51 lost+found
[root@rhel6-client1 mystripevol01]# cat dd
hi hi hi hi hi hi hi
MIRROR TO LINEAR:
[root@rhel6-client1 ~]# lvs -a -o +devices
|grep lv01Fvg01
lv01Fvg01 vg01 mwi-aom-- 300.00m lv01Fvg01_mlog 100.00
lv01Fvg01_mimage_0(0),lv01Fvg01_mimage_1(0)
[lv01Fvg01_mimage_0] vg01 iwi-aom-- 300.00m /dev/sdd2(175)
[lv01Fvg01_mimage_1] vg01 iwi-aom-- 300.00m /dev/sdd3(0)
[lv01Fvg01_mlog] vg01
lwi-aom-- 4.00m /dev/sdd3(75)
[root@rhel6-client1 ~]# lvconvert -m 0
/dev/vg01/lv01Fvg01 /dev/sdd3
Logical volume
lv01Fvg01 converted.
[root@rhel6-client1 ~]# lvs -a -o +devices
|grep lv01Fvg01
lv01Fvg01 vg01 -wi-ao--- 300.00m /dev/sdd2(175)
[root@rhel6-client1 ~]# cd /lv01Fvg01
[root@rhel6-client1 lv01Fvg01]# ls -l
total 17
-rw-r--r--. 1 root root
31 Apr 3 16:23 aa
-rw-r--r--. 1 root root 0 Apr
3 16:23 bb
-rw-r--r--. 1 root root 0 Apr
3 16:23 cc
-rw-r--r--. 1 root root 0 Apr
3 16:23 dd
drwx------. 2 root root 12288 Apr 3 16:23 lost+found
[root@rhel6-client1 lv01Fvg01]# cat aa
hi this is test test test test
LINEAR TO STRIPED:
When you're striping a LV, you obviously must have two or
more PVs to stripe it to; otherwise you would gain nothing from striping. So,
let's say that you have the original PV as /dev/sdc1 and you want the striped
version to go to /dev/sdd1 and /dev/sdd2. In this example, the LV that you want
to stripe is /dev/vg01/mystripevol01.
[root@rhel6-client1 lv01Fvg01]# pvs
PV VG
Fmt Attr PSize PFree
/dev/sdc1 vg01 lvm2 a-- 5.00g
4.89g
/dev/sdd1 vg01 lvm2 a-- 2.00g
2.00g
/dev/sdd2 vg01 lvm2 a--
1020.00m 320.00m
/dev/sdd3 vg01 lvm2 a-- 2.00g
2.00g
/dev/sdd5 vg02 lvm2 a-- 2.00g
1.31g
[root@rhel6-client1 lv01Fvg01]# lvs -o
segtype,devices,lv_name,vg_name
Type Devices LV VG
linear
/dev/sdd2(175) lv01Fvg01 vg01
linear
/dev/sdd2(75) lv02Fvg01 vg01
linear
/dev/sdc1(0) mystripevol01 vg01
linear
/dev/sdd5(0) testlv01Fvg02 vg02
linear
/dev/sdd5(75) testlv02Fvg02 vg02
[root@rhel6-client1 ~]# lvconvert -m 1
--mirrorlog core --stripes 2 /dev/vg01/mystripevol01 /dev/sdd1
/dev/sdd2
Using default
stripesize 64.00 KiB
vg01/mystripevol01: Converted: 3.8%
vg01/mystripevol01: Converted: 100.0%
The default stripe size is 64 KB. You can adjust it with
the --stripesize option if you wish.
The "--mirrorlog core" is dangerous: it might
be OK for small and short-lived mirrors only, and only if your system is
protected from power interruptions. But it makes things simpler for testing and
conversions, when the mirror is removed immediately after its creation is
completed.
If you use disk-based mirror log instead (--mirrorlog
disk or --mirrorlog mirrored), you will need one or two small extra PVs in the
VG for the mirror logs, as LVM won't allocate space for the mirror log on PVs
that will contain any of the actual LV mirror components.
[root@rhel6-client1 ~]# lvs -o
segtype,devices,lv_name,vg_name
Type Devices LV VG
linear
/dev/sdd2(175)
lv01Fvg01 vg01
linear
/dev/sdd2(75)
lv02Fvg01 vg01
mirror
mystripevol01_mimage_0(0),mystripevol01_mimage_1(0) mystripevol01 vg01
linear
/dev/sdd5(0)
testlv01Fvg02 vg02
linear
/dev/sdd5(75)
testlv02Fvg02 vg02
[root@rhel6-client1 ~]# lvs -a -o +devices
|grep mystripevol01
mystripevol01 vg01 mwi-aom-- 104.00m 100.00
mystripevol01_mimage_0(0),mystripevol01_mimage_1(0)
[mystripevol01_mimage_0] vg01 iwi-aom-- 104.00m /dev/sdc1(0)
[mystripevol01_mimage_1] vg01 iwi-aom-- 104.00m /dev/sdd1(0),/dev/sdd2(0)
Command to remove the original non-striped mirror:
[root@rhel6-client1 ~]# lvconvert -m 0
/dev/vg01/mystripevol01 /dev/sdc1
Logical volume
mystripevol01 converted.
[root@rhel6-client1 ~]# lvs -a -o +devices
|grep mystripevol01
mystripevol01 vg01
-wi-ao--- 104.00m /dev/sdd1(0),/dev/sdd2(0)
[root@rhel6-client1 ~]# lvs -o
segtype,devices,lv_name,vg_name
Type Devices LV VG
linear /dev/sdd2(175) lv01Fvg01 vg01
linear /dev/sdd2(75) lv02Fvg01 vg01
striped
/dev/sdd1(0),/dev/sdd2(0) mystripevol01 vg01
linear /dev/sdd5(0) testlv01Fvg02 vg02
linear /dev/sdd5(75) testlv02Fvg02 vg02
[root@rhel6-client1 ~]# cd /mystripevol01
[root@rhel6-client1 mystripevol01]# ls -l
total 17
-rw-r--r--. 1 root root
21 Apr 4 12:52 dd
-rw-r--r--. 1 root root 0 Apr
4 12:52 ff
-rw-r--r--. 1 root root 0 Apr
4 12:52 gg
-rw-r--r--. 1 root root 0 Apr
4 12:52 hh
drwx------. 2 root root 12288 Apr 4 12:51 lost+found
[root@rhel6-client1 mystripevol01]# cat dd
hi hi hi hi hi hi hi
No comments:
Post a Comment