How to increase a virtualbox' disk size?

14

4

The title says it all.

I created the disk and now I would like to increase its size. I know I could add a new one, but I don't want to.

The guest os in question is Ubuntu 11.04

Vinicius Kamakura

Posted 2011-07-02T17:29:47.353

Reputation: 251

This is the community's response to it.

– new123456 – 2011-07-02T19:22:23.997

2that's from 2007. many years have passed. – Vinicius Kamakura – 2011-07-02T20:29:40.037

Answers

11

There is a very good blog entry on this at http://trivialproof.blogspot.com/2011/01/resizing-virtualbox-virtual-hard-disk.html

Basic instructions, to resize to 30G:

  1. Shutdown any VM using the disk.

  2. "c:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifyhd c:\path\to\ubuntu_big.vdi --resize 30000

  3. Download and boot to a Gparted "live CD" ISO (necessary because you can't adjust the partitions on a drive that you have mounted--for instance your boot drive). Linux live CD might work also.
  4. (if you have a swap partition) follow the instructions on the blog post to "move it to the right". If that doesn't work (it doesn't let you resize it--the left arrow doesn't work) then your swap partition might be contained in a secondary partition. In this case right click on the dashed cyan line surrounding the swap partition, and choose move/resize. Now "move" it to also include all the unallocated space (it won't let you move the left-most side yet) and click ok. Then right click on the "internal" partition (now located at the very left most end of the a larger partition), and "move/resize" it to the very end of that partition (you can just click in the middle and drag it to the right). Now move/resize the external partition "all the way to the right" (it lets you now). This should effectively move your unallocated space "next to" your main partition.
  5. Resize your main partition to also include the unallocated space next to it.
  6. Click "apply"
  7. Reboot to your main OS, you should see the new space available.

aaronvargas

Posted 2011-07-02T17:29:47.353

Reputation: 211

I know it's a bit long, but could you summarize the most important steps here, please? – slhck – 2012-03-14T09:26:17.617

0

My root (/) file filesystem was full on Guest VM with OS of Oracle Enterprise Linux (OEL) 7 created on Oracle Virtualbox. I believe similar steps should be present for other Linux flavors like Redhat, Fedora, CentOS or Ubuntu.

To increase disk space I followed below steps:

  1. I powered off the VM. Enabled EFI for the VM settings in Virtual Box.
  2. Increase size of virtual disk using below command:

    C:\Program Files\Oracle\VirtualBox\VBoxManage.exe modifyhd [absolute path to file] --resize [size in MB]
    
  3. Downloaded the Gparted live iso from here

    Mount Gparted iso in Optical Drive of the VM.

  4. Start the VM and booted to Gparted live OS. Default settings worked for me. Increase disk space using the Gpart.
  5. Shutdown the VM
  6. Revert EFI in VM Settings
  7. Login to VM. Su to root user
  8. Increase LVM using below command (assuming root volume is ‘/dev/ol/root‘)

    lvextend -L+10G /dev/ol/root 
    

    OR

    lvextend -l +100%FREE /dev/ol/root 
    
  9. Increase the file system size:

    xfs_growfs  /
    
  10. Verify using:

    df -k /
    

Hope it helps!

Animesh Naskar

Posted 2011-07-02T17:29:47.353

Reputation: 1

0

Updated instructions for VirtualBox 5 and Ubuntu 16, assuming a Windows host:

  1. Shut down the VM.
  2. "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifymedium disk PATH-TO-VDI-FILE --resize NEW-SIZE-IN-MEGABYTES
  3. If you get an error about not being able to register the hard disk because the same hard disk exists, take note of the GUID that looks like {2759db7d-d23b-...} in the message, then rerun the command replacing the path to the VDI file with the GUID, like this: "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifymedium disk GUID --resize NEW-SIZE-IN-MEGABYTES
    • If you're resizing your boot partition, follow the gparted instructions in aaronvargas’s post.
    • If you're resizing a non-boot partition, you can unmount the partition and resize it more directly by doing the following:
      • Start your VM.
      • Use your favorite Ubuntu package manager (e.g., Synaptic) to install gparted on your VM.
      • Start a command prompt.
      • df -k to find the name of the MOUNT-POINT you need to resize (in the right column of the output) and to take note of the name of its corresponding PARTITION-NAME in the left column.
      • sudo umount MOUNT-POINT
      • sudo gparted , choose the correct virtual disk from the dropdown in the top right corner, and in the resulting graphical display, right-click on the PARTITION-NAME's box or its entry in the table, choose resize/move, and in the resulting dialog, resize it to fill the new space. Click the Resize button to close the dialog, then in the main window, choose the checkmark icon from the icon toolbar to apply the change.
      • Reboot. The new space should now be available.

morningstar8

Posted 2011-07-02T17:29:47.353

Reputation: 1

0

There's a section in the VirtualBox Manual which tells you how to resize a VM Hard Disk using a cmd-line tool. Would this be any good?

tombull89

Posted 2011-07-02T17:29:47.353

Reputation: 6 533

This would be better as a comment to the original question, as it solicits a response and isn't an answer. – Ben Richards – 2017-10-18T17:47:12.373

No it isn't :( After I installed the virtualbox-ose pack, VBoxManage list hdds show no HDs, so I can't use it. Maybe this could work if I had another virtualbox, and I could operate on the .vdi file directly. Thanks for the tipo tho – Vinicius Kamakura – 2011-07-02T18:46:02.280

-2

Incase you want to know how to Increase disk space using the Gpart see : https://prasadlinuxblog.wordpress.com/2014/01/23/use-gparted-to-increase-disk-size-of-a-linux-native-partition/

Also i had to download amd64 version of Gparted as the i686 version didn't work

user696202

Posted 2011-07-02T17:29:47.353

Reputation: 1