VirtualBox (Oracle)

From Andreida
Jump to: navigation, search

command line

https://www.oracle.com/technical-resources/articles/it-infrastructure/admin-manage-vbox-cli.html

setup

Find "VBoxManage.exe" and either put it into the PATH variable or make sure your calls see the .exe. If you just plan to create some scripts, you should not need to modify the PATH variable, but if you really want to work with the command line with VirtualBox, then you really should put it into your path.

start a virtual machine without starting the GUI "VirtualBox Manager"

  • list your VMs
VBoxManage list vms
  • right click on your desktop: New shortcut...
  • browse to VBoxManage.exe (location of the item)
  • Next
  • Name: "Start v-dev" or whatever makes sense for the VM you will be starting
  • Finish
  • Right click the new link / Properties
  • in the "Target" line behind the .exe insert a space and give as parameters "startvm <name from list vms"
D:\tools\system\VirtualBox\VBoxManage.exe startvm v-dev
  • OK

Now you can start your VM with double click on the new link. If your VM has a weird name, put it into quotes.

Misc

ssh (port forwarding)

If you do not want to have the machine attackable in the normal network you will set the network as NAT. If you now want to connect to services of the machine, you'd have to know the current IP. You can circumvent this problem.

machine/Settings/Network/Advanced/Port Forwarding


Example for ssh
Name Protocol Host IP Host Port Guest IP Guest Port
ssh TCP 127.0.0.1 40022 (empty) 22


Headless start

When you don't want to use the machine via the view opened by VirtualBox but instead with RDP or ssh, then you don't want an extra window to be opened when you start a VM. Headless start (selectable with the combo of the "play" button) can be set as the default, so you don't have to select "headless" in the list each time you start a VM.


  • You set a directory for your VMs.
  • There you will find a .vbox for each VM.
  • Close all virtual machines
  • close VirtualBox GUI
  • do the following changes
  • BOOT


In the .vbox search for

<Clipboard/>
<GuestProperties>

Add <Frontend> like in the following sample:

<Clipboard/>
<Frontend>
  <Default type="headless"/>
</Frontend>
<GuestProperties>

The exact spot is not important. What is important is that the entry has this level.


Guest Addition, Debian

  • In Settings/Storage/Controller:IDE
    • Choose Virtual Optical Disk File
  • C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso
  • In der Console in Debian
sudo apt-get install 'linux-headers-'`uname -r`
    • cd /media/cdrom
    • sudo sh VBoxLinuxAdditions.run
  • Debian booten (System/Shutdown.../Restart)