VirtualBox set Guest interface as a bridged adapter

A bridged adapter means that the Guest adapter is bridged to the Host adapter i.e. it can see the whole network (request address from DCHP server etc)

VBoxManage modifyvm my-guest-name --nat1 bridged
VBoxManage modifyvm my-guest-name --bridgeadapter1 eth3

nat1 is the first interface of the Guest machine.

VirtualBox clone a virtual drive image

Cloning a drive to a new drive is simple:

VBoxManage clonehd existing_current_version.vdi new_target.vdi

Or if you wish to clone to a existing drive use “–existing”

VBoxManage clonehd existing_current_version.vdi existing_target.vdi --existing

Note on using “–existing”: If the existing_target is smaller than the existing_current_version then only the part that will “fit” is copied … so this usually [for windows at least] means that the resulting virtual drive is corrupted; so make sure the target is as large or larger than the existing_version. To modify the size of a virtual drive image check out how to resize a drive.

Note: Older versions of VirtualBox used the command clonevdi instead. At the moment the manual says the following about this “For compatibility with earlier versions of VirtualBox, the “clonevdi” command is also supported and mapped internally to the “clonehd” command.”

VirtualBox resize an existing vdi file

It is possible to change the size of a existing vdi file.

VBoxManage modifyhd --resize newsizeinmb my_vm_drive.vdi

Then use the guest OS to take advantage of this extra space repartition the drives (or simply clone a from a larger drive if that is suitable).

VBoxManage controlvm reset & poweroff

When you are running for instance a headless host machine it is sometimes needed to turn it off or to restart it from outside the host (for instance as part of a script or if the host is not accessible, no rdp etc).

Word of caution: These operations stops the machine dead in its tracks, any unsaved data is lost!

To turn it off (equivalent of pulling the power cable):

VBoxManage controlvm <vm> poweroff

Note: can be either the registred machine name or the UID of the host

To restart it (equivalent of pushing the reset button):

VBoxManage controlvm <vm> restart

Note: can be either the registred machine name or the UID of the host

For more details, here is what the manual (4.1.2) says:

  • VBoxManage controlvm reset has the same effect on a virtual machine as pressing the “Reset” button on a real computer: a cold reboot of the virtual machine, which will restart and boot the guest operating system again immediately. The state of the VM is not saved beforehand, and data may be lost. (This is equivalent to selecting the “Reset” item in the “Machine” menu of the GUI.)
  • VBoxManage controlvm poweroff has the same effect on a virtual machine as pulling the power cable on a real computer. Again, the state of the VM is not saved beforehand, and data may be lost. (This is equivalent to selecting the “Close” item in the “Machine” menu of the GUI or pressing the window’s close button, and then selecting “Power off the machine” in the dialog.)
    After this, the VM’s state will be “Powered off”. From there, it can be started again; see chapter 8.11, VBoxManage startvm