[linux-lvm] will pvmove'ing (an LV at a time) defragment?

Phillip Susi psusi at cfl.rr.com
Thu Apr 29 18:23:43 UTC 2010


On 4/29/2010 12:59 PM, Brian J. Murrell wrote:
> If I currently have a volume group consisting of two drives and I add a third 
> drive and them pvmove from the two existing drives to the new drive, will that 
> defragment my LVs?  i.e.:
> 
> # pvmove /dev/sda2 /dev/sdb /dev/sdc
> 
> where /dev/sdc is the new empty drive.

That will move all extents OFF of sda2 and onto sdb and sdc.  I believe
that the default allocation policy will try to locate extents on the
same pv as other extents that lv is using.  Whether or not that results
in more or less fragmentation depends on the current layout.

> Or will it just move the PEs from each source disk (in turn) in the order they 
> appear on the source disk, effectively just concatenating the two sources disks 
> to the new target disk?

In the above command there is one source disk and two destination disks,
not the other way around.  Only the first argument to pvmove is the
source, any additional arguments lists valid destination(s), otherwise
any pv other than the first argument is used.

If you want to defrag your lvs then you need to look at the current
layout with lvdisplay -m and then you can tell pvmove exactly what
extents you want moved to where with something like pvmove /dev/sda:x-y
/dev/sda:q-r --alloc anywhere.  The --alloc anywhere is needed if the
source and destination drives are the same, since otherwise pvmove tries
to move the extents to any volume OTHER than the source, and if you
restrict the possible destinations with the second argument to only the
source drive, the allocation will fail.




More information about the linux-lvm mailing list