How to change the properties of VirtualBox virtual machines
It is quite easy to set up virtual machines using VirtualBox and other virtualization programs. You configure a few parameters such as disk size or memory, select an ISO image of an operating system, and wait for the program to create the virtual machine and install the operating system on it.
Virtual machines are useful for many different tasks. You can use them to test updates or new software programs, to browse the Internet, and to chain VPN connections.
VirtualBox users may change some properties of a virtual machine using the graphic user interface and others only from the command line. This guide looks at both options.
Here is a list of situations where you may need to change the properties:
- The disk size of the virtual machine image is not large enough or is too large.
- You want to enable or disable clipboard sharing or drag and drop.
- You want to increase or decrease the memory of the virtual machine.
- You need to increase or decrease video memory.
You open the Settings of any virtual machine image in Virtualbox by right-clicking on it and selecting settings from the context menu.
- General > Advanced: Shared Clipboard and Drag and Drop.
- System > Motherboard: Change base memory and boot order.
- System > Processor: Change number of processors.
- Display > Screen: Change video memory, monitor count, and scale factor. Enable 2D and 3D acceleration.
- Display > Remote Display: enable server mode.
- Storage: Add or remove storage attachments.
- Audio: Enable or disable audio, and configure it.
- Network > Adapter: add network adapters.
- Serial Ports: Add serial ports.
- USB: Change the USB controller and add device filters.
- Shared Folders: Manage shared folders.
And a lot more. You may have noticed already that you cannot change some virtual machine properties using the GUI. It is for instance not possible to change the size of the virtual hard drive; that's reserved to the command line.
VirtualBox command line
VirtualBox supports many different command line options to change the properties of a virtual machine image.
These commands use VBoxManage modifyvm ImagePath as the base command followed by the actual command.
The following instructions are for Windows. Linux and Mac users should not have issues figuring this out for their devices though.
VBoxManage.exe is a file in the root directory of the VirtualBox installation on Windows. You find it under C:\Program Files\Oracle\VirtualBox by default.
Start by opening a new command prompt window and navigating to the VirtualBox folder.
Tip: if you use the command regularly, consider adding it as a system path so that you can run the commands from anywhere.
- Make sure the virtual machine that you want to modify is shut down.
- Tap on the Windows-key, type cmd.exe, and hit the Enter-key to start a command prompt window.
- Type cd C:\Program Files\Oracle\VirtualBox to switch to the VirtualBox root directory.
Here is a short list of important commands:
Resize virtual machine (VDI and VHD)
- Command: VBoxManage modifyhd "PathTOVDIImage" −−resize <megabytes>
- Example: VBoxManage modifyhd "C:\Users\Martin\VirtualBox VMs\windows 7\windows 7.vdi" −−resize 40000
- Explanation: This changes the size of the virtual hard drive to 40000 MB
Move virtual machine image
- Command: VBoxManage modifymedium "PathTOVDIImage" −−move <Path>
- Example: VBoxManage modifymedium "C:\Users\Martin\VirtualBox VMs\windows 7\windows 7.vdi" −−move "C:\virtual"
- Explanation: This moves the virtual machine image to the new location.
Cap Virtual CPUs
- Command: VBoxManage modifyvm "PathTOVDIImage" −−cpuexecutioncap <1-100>
- Example: VBoxManage modifyvm "C:\Users\Martin\VirtualBox VMs\windows 7\windows 7.vdi" −−cpuexecutioncap 50
- Explanation: Caps the CPU use to 50%.
Change memory allocation
- Command: VBoxManage modifyvm "PathTOVDIImage" −−memory <memorysize>
- Example: VBoxManage modifyvm "C:\Users\Martin\VirtualBox VMs\windows 7\windows 7.vdi" −−memory 2048
- Explanation: Sets the memory to 2048 MB.