Monday, February 23, 2015

Windows Virtualbox: increase CentOS 6 VDI size

  1. Create a new VDI disk under Controller: SATA, sized appropriately

  2. Clone existing VDI into new one
  3. C:\Program Files\Oracle\VirtualBox> VBoxManage.exe clonehd "c:\Users\jerome\VirtualBox VMs\Mathusalem\Mathusalem.vdi" --existing "c:\Users\jerome\VirtualBox VMs\Mathusalem\Mathusalem 2.vdi"
    
    0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
    Clone hard disk created in format 'VDI'. UUID: 48da07eb-3395-4fad-95e3-c0615b185da2
  4. Remove legacy VDI

  5. Download GParted ISO from GParted Live CD
  6. Mount GParted ISO under Controller: IDE

  7. Start the VM, which will boot on the GParted live CD
  8. Extend the existing LVM2 partition (/dev/sda2) with the new unallocated space
  9. Stop the VM, detach the GParted ISO, and reboot the VM
  10. Extend the logical volume into the resized partition
  11. By default, CentOS uses LVM (Logical Volume Manager), which requires an extra step.
    Identify the name of the logical volume via df:
    df -h

    Then force the LVM volume to take 100% of the available space on the partition:
    lvextend -l +100%FREE /dev/mapper/vg_mathusalem-lv_root
  12. Resize file system
  13. resize2fs /dev/mapper/vg_mathusalem-lv_root

    After this step, we are now good to go.