Fixing “You have only 184MB of freespace….” on a CentOS7 VirtualBox VM

Just had a CentOS7 VirtualBox…

Login

Blog History

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:

  1. Shutdown the VM if it is running
  2. Launch a shell and cd to where your virtual disks for the vm are stored
    cd ~/virtualbox_vms/CentOS7
  3. 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%
  4. Download the GParted live iso
  5. Attach it to your VM and boot from itScreenshot from 2015-03-19 13:27:42Screenshot from 2015-03-19 13:28:08
  6. Leave the GParted live settings to boot straight into gparted
  7. select the partition that is capacity constrained
    Screenshot from 2015-03-19 13:29:55
  8. Click Move/Resize
  9. Slide the slider to consume the new space
    Screenshot from 2015-03-19 13:31:22Screenshot from 2015-03-19 13:31:28
  10. click apply (this will extend the /dev/sda2 partition to the full size of the expanded disk)
  11. You now need to expand the logical volume and the filesystem into the new space
  12. 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
  13. 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

    Screenshot from 2015-03-19 14:02:02

  14. mount the newly extended logical volume
    mount /dev/cl/root /mnt
  15. use xfs_growfs to extend the filesystem to the full size of the logical volume
    xfs_growfs /mntScreenshot from 2015-03-19 14:02:11
  16. Reboot into the CentOS 7 VM and check your diskspace... Space to breatheCentOS7

 

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

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.