A short description and all necessary scripts to deploy VMs on a headless Virtualbox

Patrick Jaeger a2f93494ed Preliminaries done 8 gadi atpakaļ
LICENSE 7562d3a04b initial commit 8 gadi atpakaļ
README.md a2f93494ed Preliminaries done 8 gadi atpakaļ

README.md

VMsWithHeadlessVirtualBox

A short description and all necessary scripts to deploy VMs on a headless Virtualbox

Introduction

This is a collection of all commands necessary to create a virtual machine on a headless VirtualBox

The following steps will be performed:

  1. Create and register the necessary frame
  2. Attach hardware
    1. Attach network device
    2. Attach storage controller
  3. Set properties
    1. RAM and number of CPUs
    2. Enable ACPI
    3. Enable IOAPIC
    4. Set boot sequence
    5. Configure network
  4. Create harddisk image file
  5. Attach harddisk
  6. Attach installer dvd-image
  7. Enable VRDE
  8. Set VRDE password

Create and register frame with virtualbox

Since virtualbox manages virtual machines on a per user basis, all commands will be executed using the system user, who will be using the virtual machine later. The machine will be called MyMachine (but hold before you execute the following command):

VBoxManage --createvm MyMachine

This will create the base for all later actions. But since VirtualBox needs to know about the machine, we should register it with VirtualBox (again: hold the presses):

VBoxManage --createvm MyMachine --register

If you want to store all of your virtual machine stuff some place else than ~/VirtualBox VMs, you should tell VirtualBox also about your desired location, e.g. /srv/vms (while still holding back on pressing Return):

VBoxManage --createvm MyMachine --register --basefolder /srv/vms

Be patient, we are almost there, but why not telling VirtualBox at the same time about the intenden operating system (Debian 64bit):

VBoxManage --createvm MyMachine --register --basefolder /srv/vms --ostype Debian_64

And last but not least, if you intend to run more than one virtual machine with virtual box and machines are intended for different purposes, you could even group your machines. In my case I decided to go with a grouping logic that consists of stage (e.g. development, testing, production), purpose (i.e. office, services, network) and type (i.e. server, workstation), which led me to a nested grouping:

VBoxManage --createvm MyMachine --register --basefolder /srv/vms --ostype Debian_64 --groups "/Production/Office/Server"

This will create a frame for your virtual machine in /srv/vms/Production/Office/Server.