Hello All
I want to reduce the disk size of the system which has LVM of partitions. This is KVM VM in a lab environment.
This was before:
Code:
# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 474M 0 474M 0% /dev
tmpfs 491M 0 491M 0% /dev/shm
tmpfs 491M 6.7M 484M 2% /run
tmpfs 491M 0 491M 0% /sys/fs/cgroup
/dev/mapper/vgcnt-root 27G 3.0G 24G 12% /
/dev/vda1 976M 118M 791M 13% /boot
tmpfs 99M 4.0K 99M 1% /run/user/0
# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root vgcnt -wi-ao---- <26.83g
swap vgcnt -wi-ao---- <2.17g
I reduced the size of the root LVM partition to 8GB. I did that by first making a dump of xfs root partition, removing the root partition, creating a new smaller root partition, and finally restoring dump to the newly created root partition.
The new filesystem is like this now
Code:
# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 474M 0 474M 0% /dev
tmpfs 491M 0 491M 0% /dev/shm
tmpfs 491M 6.7M 484M 2% /run
tmpfs 491M 0 491M 0% /sys/fs/cgroup
/dev/mapper/vgcnt-root 8.0G 2.9G 5.2G 37% /
/dev/vda1 976M 118M 791M 13% /boot
tmpfs 99M 4.0K 99M 1% /run/user/0
# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root vgcnt -wi-ao---- 8.00g
swap vgcnt -wi-ao---- <2.17g
# vgs
VG #PV #LV #SN Attr VSize VFree
vgcnt 1 2 0 wz--n- <29.00g <18.83g
# pvs
PV VG Fmt Attr PSize PFree
/dev/vda2 vgcnt lvm2 a-- <29.00g <18.83g
# fdisk -l /dev/vda
Disk /dev/vda: 30 GiB, 32212254720 bytes, 62914560 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x741ab813
Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 2099199 2097152 1G 83 Linux
/dev/vda2 2099200 62914559 60815360 29G 8e Linux LVM
Now, I want to remove that free 18gb in volume group and physical volume and reduce the total disk size from 30G to 12G.
How do I proceed next? First, reduce the physical volume and then reduce the volume group? Or, first, reduce volume group and then go to physical volume?
And what about reducing the total disk size to 12G?
I'm confused? I appreciate any guidance.
Thanks