VirtualBoxI decided the other night to begin doing some testing using my headless Mac Mini. I use VirtualBox for all my testing on my Mac OS X systems. Since the Mini is headless, I decided now was as a good a time as any to start using VirtualBox via the command line. Obviously, installing VirtualBox via the command line is not the same as running VirtualBox via the command line, but installing any package from the command line must be practiced to be remembered.

Download the latest package. I'm using wget which you'll only have if you've specifically installed it. I use MacPorts, but Homebrew is another option.

$ wget

Mount the disk image (.dmg). The disk image contents will now be mounted on /Volumes/VirtualBox.

$ hdiutil mount VirtualBox-4.2.12-84980-OSX.dmg

Now, install the package. Note that the target is set to /. In addition to installing VirtualBox in /Applications, this will also put the command line tools in /usr/bin.

$ sudo installer -pkg /Volumes/VirtualBox/VirtualBox.pkg -target /

Now unmount the disk image and clean up.

$ hdiutil unmount /Volumes/VirtualBox/
$ rm VirtualBox-4.2.12-84980-OSX.dmg

Download and install the VirtualBox Extension Pack.

$ wget
$ sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.2.12-84980.vbox-extpack
$ rm Oracle_VM_VirtualBox_Extension_Pack-4.2.12-84980.vbox-extpack