Series of the tutorial to learn LVM commands. In this part of the tutorial, learn different tasks on physical volume (pvchange, pvmove).
This is the second post on the LVM tutorial. Rest posts from this series can be found on the below links.
- Part 1 : Physical Volume (pvcreate, pvdisplay)
- Part 2 : Volume group (vgcreate, vgdisplay, vgscan)
- Part 2 : Volume group (vgextend, vgreduce, vgexport, vgimport)
- Part 2 : Volume group (vgcfgbackup, vgcfgrestore, vgchange)
- Part 2 : Volume group (vgremove, vgsync)
- Part 3 : Logical Volume (lvcreate, lvdisplay, lvremove)
- Part 3 : Logical Volume (lvextend, lvreduce, lvchange)
- Part 3 : Logical Volume (lvsync, lvlnboot)
This is the last post for part 1 which is dedicated to physical volume. In the last post, we saw pvcreate
and pvdisplay
. This post we will be checking out pvchange
and pvmove
commands.
Command: pvchange
pvchange
used for changing attributes of physical volume. There are 6 options switch which can be used with this command. Let’s see them one by one.
-a
This switch used for the availability attribute of PV. This should be accompanied with y or n argument. y making PV available and n making it unavailable. You can see the example below with n argument which turns PV unavailable which can be verified in pvdisplay
output.
# pvchange -a n /dev/disk/disk3
Physical volume "/dev/disk/disk3" has been successfully changed.
# pvdisplay /dev/disk/disk3
--- Physical volumes ---
PV Name /dev/disk/disk3
VG Name /dev/vg01
PV Status unavailable
Allocatable yes
VGDA 2
Cur LV 2
PE Size (Mbytes) 8
----- output truncated -----
-S
This switch enables or disables auto-switching. It also has a y or n argument. If activated it makes the current access path to switch on the better available path. If deactivated, path switching happens only if the current access path goes to an unavailable state (due to hardware, cable failure). This applies to disks with multi-paths only.
-t
It’s a timeout value. This switch should be supplied with a number of seconds. This value determines if IO timeout happens and the problem can be declared for IO on particular PV. Useful in clustering.
# pvchange -t 90 /dev/disk/disk3
Physical volume "/dev/disk/disk3" has been successfully changed.
-x
It enables or disables the extensibility of PV. This switch has y and n arguments that enable admin to add/restrict physical extents to PV. Refer to LVM legends to have a better understanding.
-s
Immediately begin accessing the associated physical volume.
-z
Defines PV is spare or regular. This option has significance in mirroring only.
Command: pvmove
As name suggests, it used to move data (in LVM term PE) from one PV to another PV. Command essential moves PEs and hence data within from source to destination PV. If destination PV is not specified then all available PV’s in the current volume group are considered for move operation. Command decides himself best-suited PV for move operation so that allocation policies can be met correctly.
Also if the command is supplied with a list of PV names then the first PV is always considered as source and rest all PVs are considered as a destination.
# pvmove /dev/disk/disk1 /dev/disk/disk2 /dev/disk/disk3
In above example PEs will be moved from disk 1 to disk2 & disk3.
You can also move data for particular lvol to new PV.
# pvmove -n /dev/vg01/lvol2 /dev/disk/disk1 /dev/disk/disk2
Transferring logical extents of logical volume "/dev/vg01/lvol2"...
Physical volume "/dev/disk/disk1" has been successfully moved.
Volume Group configuration for /dev/vg01 has been saved in /etc/lvmconf/vg01.conf
# /usr/sbin/lvdisplay -v /dev/vg01/lvol2
----- output clipped -----
--- Distribution of logical volume ---
PV Name LE on PV PE on PV
/dev/disk/disk2 1557 1557
--- Logical extents ---
LE PV1 PE1 Status 1
00000 /dev/disk/disk2 00000 current
00001 /dev/disk/disk2 00001 current
00002 /dev/disk/disk2 00002 current
00003 /dev/disk/disk2 00003 current
In above example PE belonging to lvol2 will be moved from disk1 to disk2. PE distribution can be confirmed via lvdisplay
output.
This marks end of part 1 : Physical volume. If you have any questions, please drop in the comments below.