BACK UP EVERYTHING BEFORE TRYING THIS.
The entire process can be split into 4 stages.
1. Physically increasing the vdi file size on the host machine.
This requires help from the hypervisor OEM. For VDI, which is a native VirtualBox image, we'll use VBoxManage.
VBoxmanage modifyhd centos.vdi --resize 100000
If the above command doesn't work and throw an error about this feature not being implemented, you might try the following instead.
- Create a new disk with higher capacity
- VBoxManage clonemedium
--existing
2. Resize the LVM.
For this we'll use GParted to resize the image. Boot up a GParted live CD and resize the required LVM partition to suit your need.
3. Resize the LVM-2
Boot up the machine with the newly extended image and check df -h and fdisk -l. You'll see that the disk has indeed grown, but LVM hasn't. Use the following command to resize LVM to full size.
- pvresize /dev/sda2 (assuming your LVM partition is sda2. Replace as required.)
- lvextend /dev/mapper/root -l+100%FREE (or, whatever your root logical volume is called.)
4. Extend the disk file system using appropriate tool.
For example, for XFS use the following commands,
- xfs_info /dev/mapper/centos-root
- xfs_growfs /dev/mapper/centos-root
This should make df as well as fdisk reflect the changes in disk space.
BACK UP EVERYTHING BEFORE TRYING THIS.
Comments
Post a Comment