How to Resize a VirtualBox VDI or VHD File on Mac OS X
發表於 : 2017-05-31 08:19:07
http://osxdaily.com/2015/04/07/how-to-r ... -mac-os-x/
If you use VirtualBox to run guest operating systems within a virtual machine on the Mac, like Windows 10 or Ubuntu Linux, you may find yourself needing to resize the virtual disk size where the OS resides. This is often the case when you inadequately estimate how much space is required for properly installing in a virtual machine with dynamically allocated storage.
To resize a VDI or VHD file in OS X (this may work the same in linux, let us know), you’ll use the VBoxManage tool from the Mac command line. Even if you chose to install the VirtualBox command line tools, it won’t be in your path, so you’ll be heading into the VirtualBox.app contents to use the utility instead.
Since this is modifying the virtual machine, it’s a good idea to back up the VDI or VHD file beforehand, if you’re not comfortable with the terminal at all you should probably back up the entire Mac first. Keep in mind the resize utility uses megabytes for measurement, so if you’re changing a vm file to be 30GB that would be 30000MB, 50GB as 50000, and so forth.
Shutdown the VM and quit VirtualBox
Open the Terminal app and use the following command to navigate to the VirtualBox app directory:
Now in the proper directory, you’re ready to run the resize command with the following syntax:
For example, let’s say there’s a Windows 10 VM VDI file located at /Users/Paul/Documents/VM/Windows10.vdi and we want it to grow from 15GB to 30GB, the syntax would be:
If desired, verify the change has taken place with the showhdinfo command:
Relaunch VirtualBox and boot your newly resized guest OS
If the path to the VM file is in a deeply rooted or complex location, use quotes or using the drag drop to print path trick which works great in Terminal app to properly point to a complex directory hierarchy.
Resizing the drive with VBoxManage is basically instantaneous from the command line, but keep in mind that once you’re back in the virtual OS (Windows, OS X, Linux, or whatever else you have running in VirtualBox) you will probably want to reallocate the partition to use the new space.
VirtualBox manager
I ran this to grow a dynamical allocation minimum size, if the VDI file is a fixed size and you want to shrink it, the VBoxManage tool will still do the job but the –compact flag is what you’re looking for.
VBoxManage is a helpful tool with a lot of great uses, you can also use it to quickly clone a virtual disk and modify nearly anything within VirtualBox from the command line. If you plan on using VBoxManage often, you may want to add it to your path or create an alias for easier access.
Know of another way to resize a VirtualBox VDI? Let us know in the comments.
If you use VirtualBox to run guest operating systems within a virtual machine on the Mac, like Windows 10 or Ubuntu Linux, you may find yourself needing to resize the virtual disk size where the OS resides. This is often the case when you inadequately estimate how much space is required for properly installing in a virtual machine with dynamically allocated storage.
To resize a VDI or VHD file in OS X (this may work the same in linux, let us know), you’ll use the VBoxManage tool from the Mac command line. Even if you chose to install the VirtualBox command line tools, it won’t be in your path, so you’ll be heading into the VirtualBox.app contents to use the utility instead.
Since this is modifying the virtual machine, it’s a good idea to back up the VDI or VHD file beforehand, if you’re not comfortable with the terminal at all you should probably back up the entire Mac first. Keep in mind the resize utility uses megabytes for measurement, so if you’re changing a vm file to be 30GB that would be 30000MB, 50GB as 50000, and so forth.
Shutdown the VM and quit VirtualBox
Open the Terminal app and use the following command to navigate to the VirtualBox app directory:
代碼: 選擇全部
cd /Applications/VirtualBox.app/Contents/Resources/VirtualBoxVM.app/Contents/MacOS/
代碼: 選擇全部
VBoxManage modifyhd --resize [new size in MB] [/path/to/vdi]
代碼: 選擇全部
VBoxManage modifyhd --resize 30000 ~/Documents/VM/Windows10.vdi
代碼: 選擇全部
VBoxManage showhdinfo ~/path/to/vmdrive.vdi
If the path to the VM file is in a deeply rooted or complex location, use quotes or using the drag drop to print path trick which works great in Terminal app to properly point to a complex directory hierarchy.
Resizing the drive with VBoxManage is basically instantaneous from the command line, but keep in mind that once you’re back in the virtual OS (Windows, OS X, Linux, or whatever else you have running in VirtualBox) you will probably want to reallocate the partition to use the new space.
VirtualBox manager
I ran this to grow a dynamical allocation minimum size, if the VDI file is a fixed size and you want to shrink it, the VBoxManage tool will still do the job but the –compact flag is what you’re looking for.
VBoxManage is a helpful tool with a lot of great uses, you can also use it to quickly clone a virtual disk and modify nearly anything within VirtualBox from the command line. If you plan on using VBoxManage often, you may want to add it to your path or create an alias for easier access.
Know of another way to resize a VirtualBox VDI? Let us know in the comments.