How to align Logical Volumes on contiguous Physical Extents?

There isn't an lvmove command in standard LVM (though HP may have one in a custom version).

The way to do this would be to move the contents of the volume off somewhere else, then delete it and recreate it, then copy back.

As your volume is swap, then moving the contents isn't necessary. You can swapoff, delete the volume, then create a new swap volume and swapon.

However, a goal of LVM could be said to not have to bother with any of this. Contiguous physical extents are not necessary to create a volume, it will just get inserted into the gaps. The main time you'd get a performance penalty is if you had a file that crossed non-contiguous extents and so would require an extra seek when being read.


According to the pvmove man-page there is the possibility to move extents around on the same device:

If the source and destination are on the same disk, the anywhere allocation policy would be needed, like this:

pvmove --alloc anywhere /dev/sdb1:1000-1999 /dev/sdb1:0-999

Maybe overlapping regions are forbidden but then you could move your volume in 2 steps:

pvmove --alloc anywhere /dev/sda5:21457-24481 /dev/sda:18432-21456
pvmove --alloc anywhere /dev/sda5:24482-25509 /dev/sda:21457-22484