Creating a New Virtual Machine Using VBoxManage

You can create a VM on the command line using VBoxManage. See also .

The following example uses various VBoxManage commands to specify the VM and configure an unattended guest installation for an Oracle Linux VM on a Linux host.

It then shows the use of the VBoxManage unattended install command to install and configure the guest OS.

  1. Set a variable for the name of the OS.

    # VM="ol8-autoinstall"
    

  2. List the available guest OS types and note the exact name of the one you need. This is required in VBoxManage commands.

    # VBoxManage list ostypes

  3. Create the virtual machine.

    # VBoxManage createvm --name $VM --ostype "Oracle_64" --register

    The VM has a unique UUID.

    An XML settings file is generated.

  4. Create a 32768 MB virtual hard disk for the VM.

    # VBoxManage createhd --filename /VirtualBox/$VM/$VM.vdi --size 32768

  5. Create storage devices for the VM.

    • Create a SATA storage controller and attach the virtual hard disk.

      # VBoxManage storagectl $VM --name "SATA Controller" --add sata --controller IntelAHCI
      # VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --device 0 \
      --type hdd --medium /VirtualBox/$VM/$VM.vdi

    • Create an IDE storage controller for a virtual DVD drive and attach an Oracle Linux installation ISO.

      # VBoxManage storagectl $VM --name "IDE Controller" --add ide
      # VBoxManage storageattach $VM --storagectl "IDE Controller" --port 0 --device 0 \
      --type dvddrive --medium /u01/Software/OL/OracleLinux-R7-U6-Server-x86_64-dvd.iso

  6. (Optional) Configure some settings for the VM.

    • Enable I/O APIC for the motherboard of the VM.

      # VBoxManage modifyvm $VM --ioapic on

    • Configure the boot device order for the VM.

      # VBoxManage modifyvm $VM --boot1 dvd --boot2 disk --boot3 none --boot4 none

    • Allocate 8192 MB of RAM and 128 MB of video RAM to the VM.

      # VBoxManage modifyvm $VM --memory 8192 --vram 128

  7. Specify the Unattended Installation parameters, and then install the OS.

    • Specify an Oracle Linux ISO as the installation ISO.

      # VBoxManage unattended install $VM \
      --iso=/u01/Software/OL/OracleLinux-R7-U6-Server-x86_64-dvd.iso \

    • Specifiy a user name, full name, and password for a default user on the guest OS.

      --user=login --full-user-name=name --user-password password \

      Note that the specified password is also used for the root user account on the guest.

    • Specify that you want to install the VirtualBox Guest Additions on the VM.

      --install-additions \

    • Sets the time zone for the guest OS to Central European Time (CET).

      --time-zone=CET

  8. Start the virtual machine.

    # VBoxManage startvm $VM --type headless

    The VM starts in headless mode, which means that it does not have a GUI.