How to re-size the size of the virtual disk image in VirtualBox

Home > Search > How-to
  by

I wanted the ability to increase/decrease the size, in GB, of the VDI. I was unable to accomplish this. Here are my notes. In VirtualBox > Settings > Stoarge, if you select the .VDI, you can see both the virtual size and actual size of the .VDI. We are concerned with the virtual size. There is no option in the VirtualBox GUI to modify the size of the .VDI, so these commands need to be entered in the host OS to resize the .VDI:

cd c:\program files\oracle\virtualbox
vboxmanage modifyhd "c:\users\jeremy\virtualbox vms\linux mint 17 lamp 2\linux mint 17 lamp 2.vdi" --resize 40960

 

For the second command, the path will be different for every .VDI. Also, the resize is in MB. 1,024 MB = 1 GB, so 40,960 MB = 40 GB.



 

Let's say we started with 10GB, and used the above commands to resize to 40GB. This is going to add an additional 30GB. However, this 30GB will be unallocated. If we go into Linux > Menu > Accessories > Disks, we'll see the 30GB is unallocated. There is no option in Linux or VirtualBox to allocate the 30GB. (needs editing . . . there might be a way to allocate using fdisk or cfdisk)  Instead, the program GParted is meant to be used to allocate the 30GB. I've the GParted ISO in Documents of my Host OS. To use GParted, follow these steps:

  • Shut down the Guest OS, Linux
  • In VirtualBox > Settings > System, set CD/DVD as the top most item in the boot order
  • In VirtualBox > Settings > Storage > Controller: IDE, click the disk plus, choose disk, and select the GParted ISO
  • Now, Start Linux, and it will boot into GParted. There will be a series of questions. Just press enter for each question. In GParted, there will be a GUI with an option to resize each partition of the .VDI. Also, there will be a 30GB partition for the unallocated space. There should be a primary/boot partition list, with filesystem EXT4.

The problem here is that GParted will not let us take any of the unallocated space and allocate it to the EXT4 primary partition. I even tried setting up two different partitions, where 1 was the primary/boot partition with filesystem EXT4, and 2 was the logical partition with filesystem EXT4. Still, GParted wouldn't let me resize either of these. This lead me to suspect that GParted just can't resize a partition that uses the EXT4 filesystem. To further support this theory, GParted does let me resize a partition that uses the SWAP filesystem. And to further support this theory more, I found a tutorial online that shows GParted resizing an NTFS partition. During the install of Linux Mint 17, there is no option to use NTFS. This is why I just ended up carving out a large 160GB .VDI for my LAMP server.

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments