How to upgrade the VirtualBox extension pack via command line:
1. Download the extension.
2. Install it:
vbox@core:~/.VirtualBox$ [color=green]sudo VBoxManage extpack install --replace Oracle_VM_VirtualBox_Extension_Pack-4.2.16.vbox-extpack[/color] 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% Successfully installed "Oracle VM VirtualBox Extension Pack". vbox@core:~/.VirtualBox$ VBoxManage list extpacks Extension Packs: 1 Pack no. 0: Oracle VM VirtualBox Extension Pack Version: 4.2.16 Revision: 86992 Edition: Description: USB 2.0 Host Controller, VirtualBox RDP, PXE ROM with E1000 support. VRDE Module: VBoxVRDP Usable: true Why unusable:
How to resize VirtualBox disk via command line:
Windows:
C:\Program Files\Oracle\VirtualBox\VboxManage.exe modifyhd gzdisk.vdi --resize size_in_mb
Mac:
$ /Applications/VirtualBox.app/Contents/MacOS/VBoxManage modifyhd gzdisk.vdi --resize size_in_mb
Linux:
$ VBoxManage modifyhd gzdisk.vdi --resize size_in_mb
If you get the following error while trying to expand your vdi disk, you will have to clone your existing disk, resize the cloned one and replace it in your machine.
The error:
vbox@core:~/.VirtualBox/Linux Prod/venus$ VBoxManage modifyhd venus.vdi --resize 20480 0%... Progress state: VBOX_E_NOT_SUPPORTED VBoxManage: error: Resize hard disk operation for this format is not implemented yet!
1. Clone the disk:
vbox@core:~/.VirtualBox/Linux Prod/venus$ VBoxManage clonehd venus.vdi venus-clone.vdi 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% Clone hard disk created in format 'VDI'. UUID: e50c320a-e10b-459d-9ff8-38efe6c7fcaf
2. resize the cloned disk:
vbox@core:~/.VirtualBox/Linux Prod/venus$ VBoxManage modifyhd venus-clone.vdi --resize 20480 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
3. Replace the disk in the vm and that is it! Enjoy ;)
How to shrink a dynamically-expanding guest virtual box image:
1. delete whatever you do not need anymore from the disk;
2. zero out the free space (this step is important - if you skip it, the shrink command will not save any space);
3. shutdown the guest machine;
4. Shrink the virtual disk;
core:pool# du -sh Stuff.vdi 276G Stuff.vdi core:pool# [color=green]VBoxManage modifyhd Stuff.vdi -compact[/color] 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% core:pool# du -sh Stuff.vdi 362M Stuff.vdi
How to add a 5th network interface to VirtualBox virtual machine:
If you need more than four interfaces on your guest you will see that you cannot add it from the interface. Instead you have to fire up the console and do the following.
Nat mode:
VBoxManage modifyvm pluto --nic5 nat
Internal networking:
VBoxManage modifyvm pluto --nic5 intnet VBoxManage modifyvm pluto --intnet5 "iscsi"
Host-Only networking:
VBoxManage modifyvm pluto --nic5 hostonly VBoxManage modifyvm pluto --hostonlyadapter5 "vboxnet69"
Bridged adapter:
VBoxManage modifyvm pluto --nic5 bridged VBoxManage modifyvm pluto --bridgeadapter5 "bond0"
To select the hardware type (Intel Pro/1000 MT Server for this example):
VBoxManage modifyvm pluto --nictype5 82545EM
Enable Promiscuous mode:
VBoxManage modifyvm pluto --nicpromisc5 allow-all
Disconnect/Connect cable:
VBoxManage modifyvm pluto --cableconnected5 off/on
How to make a machine to start automatically on boot:
VBoxManage modifyvm gate --autostart-enabled on
How to stop a machine automatically on shutdown/halt/reboot:
For this example I choose savestate but you have many other options to choose from (pause, resume, reset, poweroff, savestate, acpipowerbutton, acpisleepbutton, etc.). Of course, the most suitable would be savestate and acpipowerbutton
VBoxManage modifyvm gate --autostop-type savestate
How to delay the automatic startup of a machine:
VBoxManage modifyvm gate --autostart-delay 5
How to change the resolution on efi machines (e.g. macos):
EFI provides two distinct video interfaces: GOP (Graphics Output Protocol) and UGA (Universal Graphics Adapter). Mac OS X uses GOP, while Linux tends to use UGA. VirtualBox provides a configuration option to control the framebuffer size for both interfaces.
To control GOP, use the following VBoxManage command:
VBoxManage setextradata "VM name" VBoxInternal2/EfiGopMode N
Where N can be one of 0,1,2,3,4 referring to the 640x480, 800x600, 1024x768, 1280x1024, 1440x900 screen resolution respectively.
The video mode for both GOP and UGA can only be changed when the VM is powered off and remains persistent until changed.