LVM: Move extents on same disk
I want to move LVM physical extents on the same disk to avoid gap between logical volumes. To visualize physical allocation I use system-config-lvm. Found unused space which size equal to an LV
Find out the LV location:
lvdisplay -m
Show something like this:
--- Segments ---
Logical extents 0 to 20479:
Type linear
Physical volume /dev/sda2
Physical extents 116224 to 136703
Or use:
pvdisplay -m
--- Physical volume ---
PV Name /dev/sda2
VG Name Vol01
PV Size 931.26 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 238402
Free PE 96578
Allocated PE 141824
--- Physical Segments ---
Physical extent 0 to 38399:
FREE
Physical extent 38400 to 39423:
Logical volume /dev/Vol01/Swap
Logical extents 0 to 1023
Physical extent 39424 to 52223:
Logical volume /dev/Vol01/Fedora-root
Logical extents 0 to 12799
To move:
pvmove --alloc anywhere --atomic /dev/sda2:116224-136703
Or to move to specific location:
pvmove --alloc anywhere --atomic /dev/sda2:116224-136703 /dev/sda2:136704-20480
Wait until it finished
Find out the LV location:
lvdisplay -m
Show something like this:
--- Segments ---
Logical extents 0 to 20479:
Type linear
Physical volume /dev/sda2
Physical extents 116224 to 136703
Or use:
pvdisplay -m
--- Physical volume ---
PV Name /dev/sda2
VG Name Vol01
PV Size 931.26 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 238402
Free PE 96578
Allocated PE 141824
--- Physical Segments ---
Physical extent 0 to 38399:
FREE
Physical extent 38400 to 39423:
Logical volume /dev/Vol01/Swap
Logical extents 0 to 1023
Physical extent 39424 to 52223:
Logical volume /dev/Vol01/Fedora-root
Logical extents 0 to 12799
To move:
pvmove --alloc anywhere --atomic /dev/sda2:116224-136703
Or to move to specific location:
pvmove --alloc anywhere --atomic /dev/sda2:116224-136703 /dev/sda2:136704-20480
Wait until it finished
Comments