How to resize a VirtualBox VDI file on Mac OS

Recently, I had to do this as 10GB was not sufficient for Centos6.7 VM. I would just like to mention simple steps for how to do it.

  1. Shutdown VM and quit from VirtualBox.
  2. Open the terminal and go to the below path (default location). From here you can run the command to resize the VDI file.
    Nils-Mac:MacOS nilnandan$ pwd
    Nils-Mac:MacOS nilnandan$ 
  3. Start another terminal with command + T and find the directory where actually the VDI file stored. Default location would be ,
    Nils-Mac:centos67-mysql nilnandan$ pwd
    /Users/nilnandan/VirtualBox VMs/centos67-mysql
    Nils-Mac:centos67-mysql nilnandan$ ls -alh
    total 21925920
    drwx------   7 nilnandan  staff   238B Aug 11 18:15 .
    drwx------  12 nilnandan  staff   408B Aug 11 17:50 ..
    drwx------   6 nilnandan  staff   204B Aug 11 17:50 Logs
    drwx------   2 nilnandan  staff    68B Aug 11 17:47 Snapshots
    -rw-------   1 nilnandan  staff    10G Aug 11 18:20 centos67-3.vdi
    -rw-------   1 nilnandan  staff   7.7K Aug 11 18:15 centos67-mysql.vbox
    -rw-------   1 nilnandan  staff   7.7K Aug 11 17:50 centos67-mysql.vbox-prev
    Nils-Mac:centos67-mysql nilnandan$ 
  4. Now from the location of step 2, run the command to resize it. I’m going to increase size from 10GB to 25GB
    Nils-Mac:MacOS nilnandan$ VBoxManage modifyhd --resize 25600 /Users/nilnandan/VirtualBox VMs/centos67-mysql/centos67-3.vdi
    Oracle VM VirtualBox Command Line Management Interface Version 5.0.12
    (C) 2005-2015 Oracle Corporation
    All rights reserved.
    VBoxManage modifymedium [disk|dvd|floppy] <uuid|filename>
    [--type normal|writethrough|immutable|shareable|
    [--autoreset on|off]
    [--property <name=[value]>]
    [--resize <megabytes>|--resizebyte <bytes>]
    Syntax error: Invalid parameter 'VMs/centos67-mysql/centos67-3.vdi'
    Nils-Mac:MacOS nilnandan$
  5. Here, I got the error because there is a space between VirtualBox and VMs so I have to use escape character to solve this,
    Nils-Mac:MacOS nilnandan$ VBoxManage modifyhd --resize 25600 /Users/nilnandan/VirtualBox\ VMs/centos67-mysql/centos67-3.vdi
    Nils-Mac:MacOS nilnandan$ 
  6. Now, when you’ll check the size, it will be
    Nils-Mac:MacOS nilnandan$ VBoxManage showhdinfo /Users/nilnandan/VirtualBox\ VMs/centos67-mysql/centos67-3.vdi
    Location:       /Users/nilnandan/VirtualBox VMs/centos67-mysql/centos67-3.vdi
    Storage format: VDI
    Format variant: dynamic default
    Capacity:       25600 MBytes
    Size on disk:   10706 MBytes
    Encryption:     disabled
    Nils-Mac:MacOS nilnandan$ 
  7. It’s done. Just open the VirtualBox and start VM


Leave a Reply

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