Today I needed to move 3 lv inside a vg (named VG_NAME) with 3 disk to a new disk (NEW_DISK).

The operation is generaly easy, but if a lv is splited on multiples disks this could be more complicated.

Current map of the whole thing :

1
2
3
4
5
6
7
8
lvs -a -o+devices
LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert Devices
lv_1 VG_NAME -wi-ao--- 5.00g /dev/disk1(2560)
lv_3 VG_NAME -wi-ao--- 97.43g /dev/disk2(0)
lv_3 VG_NAME -wi-ao--- 97.43g /dev/disk1(3840)
lv_3 VG_NAME -wi-ao--- 97.43g /dev/disk3(0)
lv_2 VG_NAME -wi-ao--- 10.00g /dev/disk1(0)

As you can see the lv_3 is split apart 3 disks.

If i don’t want to mix the order, i will have to move the lv in the right order

First, format the new disk with pvcreate, and add it to the VG :

1
2
pvcreate /dev/NEW_DISK
vgextend VG_NAME /dev/NEW_DISK

Now move the two easiest LV from disk1 to NEW_DISK

1
2
pvmove -n lv_1 /dev/disk1 /dev/NEW_DISK
pvmove -n lv_2 /dev/disk1 /dev/NEW_DISK

Now the more complicated :

1
lvdisplay -m /dev/VG_NAME/lv_3

Will display the information of the segment relative to the lv

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
--- Segments ---
Logical extent 0 to 17261:
Type linear
Physical volume /dev/disk2
Physical extents 0 to 17261
Logical extent 17262 to 19894:
Type linear
Physical volume /dev/disk1
Physical extents 3840 to 6472
Logical extent 19895 to 24941:
Type linear
Physical volume /dev/disk3
Physical extents 0 to 5046

So now I’ve to move them in the right order.

1
2
3
pvmove -n lv_3 /dev/disk2 /dev/NEW_DISK
pvmove -n lv_3 /dev/disk1 /dev/NEW_DISK
pvmove -n lv_3 /dev/disk3 /dev/NEW_DISK

Comments

2013-06-13