VirtualBox sem interface gráfica



Step by step: creating a virtual machine on a headless server

The following instructions may give you an idea how to create a virtual machine on a headless server over a network connection. We will create a virtual machine, establish a VRDP connection and install a guest operating system -- all without having to touch the headless server. All you need is the following:

  1. VirtualBox on a server machine with a supported host operating system; for the following example, we will assume a Linux server;

  2. an ISO file on the server, containing the installation data for the guest operating system to install (we will assume Windows XP in the following example);

  3. a terminal connection to that host over which you can access a command line (e.g. via telnet or ssh);

  4. an RDP viewer on the remote client; on a Linux client, you could use rdesktop to connect; from a Windows machine, you could use the RDP viewer that comes with Windows (usually found in "Accessories" -> "Communication" -> "Remote Desktop Connection").

Note again that on the server machine, since we will only use the headless server, neither Qt nor SDL nor the X Window system will be needed.

  1. On the headless server, create a new virtual machine:

    VBoxManage createvm --name "Windows XP" --register

    Note that if you do not specify --register, you will have to manually use the registervm command later.

  2. Make sure the settings for this VM are appropriate for the guest operating system that we will install. For example:

    VBoxManage modifyvm "Windows XP" --memory "256MB"
    --acpi on --boot1 dvd --nic1 nat
  3. Create a virtual hard disk for the VM (in this case, 10GB in size) and register it with VirtualBox:

    VBoxManage createhd --filename "WinXP.vdi" --size 10000 --remember
  4. Set this newly created VDI file as the first virtual hard disk of the new VM:

    VBoxManage modifyvm "Windows XP" --hda "WinXP.vdi"
  5. Register the ISO file that contains the operating system installation that you want to install later:

    VBoxManage openmedium dvd /full/path/to/iso.iso
  6. Attach this ISO to the virtual machine, so it can boot from it:

    VBoxManage modifyvm "Windows XP" --dvd /full/path/to/iso.iso

    (Alternatively, you can use VBoxManage controlvm dvdattach directly, without having to register the image first; see the section called “VBoxManage controlvm” for details.)

  7. Start the virtual machine using VBoxHeadless:

    VBoxHeadless --startvm "Windows XP"

    If everything worked, you should see a copyright notice. If, instead, you are returned to the command line, then something went wrong.

  8. On the client machine, fire up the RDP viewer and try to connect to the server. Assuming a Linux client, try the following:

    rdesktop -a 16 -N

    (With rdesktop, the -a 16 option requests a color depth of 16 bits per pixel, which we recommend. Also, after installation, you should set the color depth of your guest operating system to the same value. The -N option requests the NumLock state synchronization, which is required for a correct handling of NumPad keys.)

    You should now be seeing the installation routine of your guest operating system.