3.2. Unattended Guest Installation

Oracle VM VirtualBox can install a guest OS automatically. You only need to provide the installation medium and a few other parameters, such as the name of the default user.

Performing an unattended guest installation involves the following steps:

  • Create a new VM. Use one of the following methods:

    For the new VM, choose the guest OS type and accept the default settings for that OS. The following sections in this chapter describe how to change the settings for a VM.

  • Prepare the VM for unattended guest installation. Use the VBoxManage unattended command, see Section 7.44, “VBoxManage unattended”.

    During this step, Oracle VM VirtualBox scans the installation medium and changes certain parameters to ensure a seamless installation as a guest running on Oracle VM VirtualBox.

  • Start the VM. Use the VirtualBox Manager or the VBoxManage startvm command.

    When you start the VM, the unattended installation is performed automatically.

    The installation operation changes the boot device order to boot the virtual hard disk first and then the virtual DVD drive. If the virtual hard disk is empty prior to the automatic installation, the VM boots from the virtual DVD drive and begins the installation.

    If the virtual hard disk contains a bootable OS, the installation operation exits. In this case, change the boot device order manually by pressing F12 during the BIOS splash screen.

Section 3.2.1, “An Example of Unattended Guest Installation” describes how to perform an unattended guest installation for an Oracle Linux guest.

3.2.1. An Example of Unattended Guest Installation

The following example shows how to perform an unattended guest installation for an Oracle Linux VM. The example uses various VBoxManage commands to prepare the guest VM. The VBoxManage unattended install command is then used to install and configure the guest OS.

  1. Create the virtual machine.

    # VM="ol7-autoinstall"
    # VBoxManage list ostypes
    # VBoxManage createvm --name $VM --ostype "Oracle_64" --register

    Note the following:

    • The $VM variable represents the name of the VM.

    • The VBoxManage list ostypes command lists the guest OSes supported by Oracle VM VirtualBox, including the name used for each OS in the VBoxManage commands.

    • A 64-bit Oracle Linux 7 VM is created and registered with Oracle VM VirtualBox.

    • The VM has a unique UUID.

    • An XML settings file is generated.

  2. Create a virtual hard disk and storage devices for the VM.

    # VBoxManage createhd --filename /VirtualBox/$VM/$VM.vdi --size 32768
    # 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
    # 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

    The previous commands do the following:

    • Create a 32768 MB virtual hard disk.

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

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

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

    # VBoxManage modifyvm $VM --ioapic on
    # VBoxManage modifyvm $VM --boot1 dvd --boot2 disk --boot3 none --boot4 none
    # VBoxManage modifyvm $VM --memory 8192 --vram 128

    The previous commands do the following:

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

    • Configure the boot device order for the VM.

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

  4. Perform an unattended install of the OS.

    # VBoxManage unattended install $VM \
    --iso=/u01/Software/OL/OracleLinux-R7-U6-Server-x86_64-dvd.iso \
    --user=login --full-user-name=name --password password \
    --install-additions --time-zone=CET

    The previous command does the following:

    • Specifies an Oracle Linux ISO as the installation ISO.

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

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

    • Installs the Guest Additions on the VM.

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

  5. Start the virtual machine.

    This step completes the unattended installation process.

    # VBoxManage startvm $VM --type headless

    The VM starts in headless mode, which means that the VirtualBox Manager window does not open.

  6. (Optional) Update the guest OS to use the latest Oracle Linux packages.

    On the guest VM, run the following command:

    # yum update