This is usually done, when the hardisk space for the CentOS VM is running low.
Check your current disk size
# fdisk -lu /dev/sda
To increase the size of the hardisk image, shutdown the centos VM
# poweroff
Increase the hardisk image in VMware
Power on the centos VM
Once logged in, check back whether you have increased your disk size
# fdisk -lu /dev/sda
Create new partition on the new disk space
# fdisk /dev/sda
Press:
n {new partition}
p {primary partition}
3 {partition number}
t {change partition id}
8e {Linux LVM partition}
w {write partition change to disk}
Reboot the vm
# reboot
Check the new partition
# fdisk -lu /dev/sda
Create physical volume (PV) on the new partition
# pvcreate /dev/sda3
Check list of PV
# pvs
Extend the current Volume Group (VG) to include the new PV, and check the new VG size
# vgextend centos /dev/sda3
# vgs
Extend the current Logical Volume (LV), and check the new size of logical volume
# lvextend /dev/mapper/centos-root /dev/sda3
# lvs
Resize / partition
# resize2fs /dev/mapper/centos-root
Check the new size
# df -h /
before resize:
after resize:
No comments:
Post a Comment