Just had a CentOS7 VirtualBox VM popup a warning saying I was down to my last few hundred MB of free space. (I installed it as a trial with a 8GB root partition and then started using it as an Apache test VM with heaps of data)
The VM is using LVM and XFS.
So my VM has a virtual disk and it is partitioned into /dev/sda1 ( for /boot ) and /dev/sda2 which contains a 8GB LVM volume group "cl" that has two logical volumes "root" and "swap".
Steps:
- Shutdown the VM if it is running
- Launch a shell and cd to where your virtual disks for the vm are stored
cd ~/virtualbox_vms/CentOS7
- Run the command to enlarge (I chose 100GB as the new size which is 100,000MB)
VBoxManage modifyhd CentOS7.vdi --resize 100000 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
- Download the GParted live iso
- Attach it to your VM and boot from it
- Leave the GParted live settings to boot straight into gparted
- select the partition that is capacity constrained
- Click Move/Resize
- Slide the slider to consume the new space
- click apply (this will extend the /dev/sda2 partition to the full size of the expanded disk)
- You now need to expand the logical volume and the filesystem into the new space
- next activate the volume group
vgscan # find your volume groups vgchange -a y # activate your volume group/s vgs # to display the volume group name ls /dev/<vgname>/ # to see your partitions
- extend the root logical volume
lvextend /dev/cl/root -l '+100%FREE' # use the 100%FREE to expand to the full size of the new physical partition
- mount the newly extended logical volume
mount /dev/cl/root /mnt - use xfs_growfs to extend the filesystem to the full size of the logical volume
xfs_growfs /mnt - Reboot into the CentOS 7 VM and check your diskspace... Space to breathe
Refs:
https://www.centos.org/docs/5/html/Cluster_Logical_Volume_Manager/lv_extend.html
https://forums.virtualbox.org/viewtopic.php?f=35&t=50661
http://gparted.org/livecd.php
0 Comments