0% found this document useful (0 votes)
20 views2 pages

LVM-Move a logical volume from one PV to another PV

LVM move pv to another pv/disk

Uploaded by

gemma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

LVM-Move a logical volume from one PV to another PV

LVM move pv to another pv/disk

Uploaded by

gemma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

LVM: Move a Logical Volume from one PV to another PV

Tuesday, May 28, 2019 1:25 PM

Move a Logical Volume from one PV to another, remove PV after


*Note: in order to do a pvmove, all physical volumes(source and destination) should be a part of the same volume group.

Merge 2 Volume Groups if needed

example: Merge the inactive volume group named "my_vg" into the active or inactive volume group named "databases" giving verbose runtime
information

# vgmerge -v -t databases my_vg


-t --test
- Do a test run WITHOUT making any real changes.

# pvmove
- pvmove allows you to move the allocated physical extents (PEs) on SourcePhysicalVolume to one or more other physical volumes (PVs). You can
optionally specify a source LogicalVolume in which case only extents used by that LV will be moved to free (or specified) extents on
DestinationPhysicalVolume(s). If no DestinationPhysicalVolume is specified, the normal allocation rules for the Volume Group are used.

Example:
Usage: pvmove -v -n [LogicalVolume] SourcePhysicalVolume DestinationPhysicalVolume

# pvmove -v -n lvol1 /dev/sdb1 /dev/sdd1


- To perform the action only on extents belonging to the single Logical Volume lvol1 do this:

Before:
sapvmtst02:~ # lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 64G 0 disk
└─sdb1 8:17 0 9.3G 0 part
└─vg01-lvol1 254:10 0 9.3G 0 lvm /lvol1

sapvmtst02:~ # pvmove -v -n lvol1 /dev/sdb1 /dev/sdd1


Cluster mirror log daemon is not running.
Finding volume group "vg01"
Archiving volume group "vg01" metadata (seqno 4).
Creating logical volume pvmove0
Moving 2383 extents of logical volume vg01/lvol1
activation/volume_list configuration setting not defined: Checking only host tags for vg01/lvol1
Setting up pvmove in on-disk volume group metadata.
Creating vg01-pvmove0
Loading vg01-pvmove0 table (254:12)
Loading vg01-lvol1 table (254:10)
Suspending vg01-lvol1 (254:10) with device flush
activation/volume_list configuration setting not defined: Checking only host tags for vg01/pvmove0
Resuming vg01-pvmove0 (254:12)
Loading vg01-pvmove0 table (254:12)
Suppressed vg01-pvmove0 (254:12) identical table reload.
Resuming vg01-lvol1 (254:10)
Creating volume group backup "/etc/lvm/backup/vg01" (seqno 5).
Checking progress before waiting every 15 seconds.
/dev/sdb1: Moved: 0.0%
/dev/sdb1: Moved: 20.1%
/dev/sdb1: Moved: 39.9%
/dev/sdb1: Moved: 60.2%
/dev/sdb1: Moved: 84.9%
/dev/sdb1: Moved: 100.0%
Loading vg01-lvol1 table (254:10)
Loading vg01-pvmove0 table (254:12)
Suspending vg01-lvol1 (254:10) with device flush
Suspending vg01-pvmove0 (254:12) with device flush
Resuming vg01-pvmove0 (254:12)
Resuming vg01-lvol1 (254:10)
Removing vg01-pvmove0 (254:12)
Removing temporary pvmove LV
Writing out final volume group after pvmove

RHCSA - v2 Page 1
Writing out final volume group after pvmove
Creating volume group backup "/etc/lvm/backup/vg01" (seqno 7).

After:
sapvmtst02:~ # lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 64G 0 disk
└─sdb1 8:17 0 9.3G 0 part

Remove the physical volume


# vgreduce vg01 /dev/sdb1
Removed "/dev/sdb1" from volume group "vg01"

# pvremove /dev/sdb1
Labels on physical volume "/dev/sdb1" successfully wiped

Move a logical volume scattered across 3 physical volumes

# pvs --segments -o+lv_name,devices


/dev/sdc1 vg01 lvm2 a-- 4.00g 0 0 1023 lvol2 /dev/sdc1(0)
/dev/sdc2 vg01 lvm2 a-- 4.00g 0 0 1023 lvol2 /dev/sdc2(0)
/dev/sdc3 vg01 lvm2 a-- 4.00g 0 0 1023 lvol2 /dev/sdc3(0)

# lvchange -an /dev/vg02/lv02


# vgmerge vg01 vg02
# pvmove -n lvol2 /dev/sdc1 /dev/sdd1
# pvmove -n lvol2 /dev/sdc2 /dev/sdd1
# pvmove -n lvol2 /dev/sdc3 /dev/sdd1

# pvs --segments -o+lv_name,devices


/dev/sdc1 vg01 lvm2 a-- 4.00g 4.00g 0 1023
/dev/sdc2 vg01 lvm2 a-- 4.00g 4.00g 0 1023
/dev/sdc3 vg01 lvm2 a-- 4.00g 4.00g 0 1023
/dev/sdd1 vg01 lvm2 a-- 30.00g 8.70g 0 2383 lvol1 /dev/sdd1(0)
/dev/sdd1 vg01 lvm2 a-- 30.00g 8.70g 2383 3069 lvol2 /dev/sdd1(2383)
/dev/sdd1 vg01 lvm2 a-- 30.00g 8.70g 5452 2227

# vgreduce vg01 /dev/sdc1


Removed "/dev/sdc1" from volume group "vg01"
# vgreduce vg01 /dev/sdc2
Removed "/dev/sdc2" from volume group "vg01"
# vgreduce vg01 /dev/sdc3
Removed "/dev/sdc3" from volume group "vg01"

RHCSA - v2 Page 2

You might also like