[root@localhost ~] vgdisplay
--- Volume group ---
VG Name vg_root
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 7
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 297,59 GiB
PE Size 4,00 MiB
Total PE 76182
Alloc PE / Size 59392 / 232,00 GiB
Free PE / Size 16790 / 65,59 GiB
VG UUID XXXXXXXXXX
PV:
[root@localhost ~] pvdisplay
--- Physical volume ---
PV Name /dev/mapper/udisks-luks-uuid-ASDFASDF
VG Name vg_root
PV Size 297,59 GiB / not usable 2,00 MiB
Allocatable yes
PE Size 4,00 MiB
Total PE 76182
Free PE 16790
Allocated PE 59392
PV UUID YYYYYYYYYYY
因此,我有一个具有65 GB可用空间的VG。但是,当我要将这个卷组缩小到约50 GB时:
pvresize -tv --setphysicalvolumesize 247G /dev/mapper/udisks-luks-uuid-ASDFASDF
Test mode: Metadata will NOT be updated and volumes will not be (de)activated.
Using physical volume(s) on command line
Test mode: Skipping archiving of volume group.
/dev/mapper/udisks-luks-uuid-ASDFASDF: Pretending size is 517996544 not 624087040 sectors.
Resizing volume "/dev/mapper/udisks-luks-uuid-ASDFASDF" to 624087040 sectors.
Resizing physical volume /dev/mapper/udisks-luks-uuid-ASDFASDF from 0 to 63231 extents.
/dev/mapper/udisks-luks-uuid-ASDFASDF: cannot resize to 63231 extents as later ones are allocated.
0 physical volume(s) resized / 1 physical volume(s) not resized
Test mode: Wiping internal cache
Wiping internal VG cache
因此错误消息是:
cannot resize to 63231 extents as later ones are allocated.
问:如何对vg_root进行碎片整理,以便删除其中不需要的部分?
ps:我已经发现我只需要调整PV的大小来调整VG的大小,或者是否有更好的命令来调整VG的大小(例如:如果我要在PV上放置多个VG怎么办?... )?
sudo pvmove --alloc anywhere /dev/sdX2:60000-76182 /dev/sdX2:3000-19182