Use the VirtualBox command line management interface on Linux

Source: Internet
Author: User

Use the VirtualBox command line management interface on Linux

VirtualBox has a set of command line tools. You can use the command line interface (CLI) of VirtualBox to manage virtual machines on remotely unbounded servers. In this tutorial, you will learn how to use VBoxManage to create and start a virtual machine without a GUI. VBoxManage is the command line interface of VirtualBox. You can use it in the command line of your host operating system to perform all operations on VirtualBox.

VBoxManage has all the functions supported by the graphical user interface, and it supports far more than these functions. It provides all the functions of the virtual engine, even those functions that cannot be implemented by the GUI. If you want to try different user interfaces, not just the GUI, or change more advanced and Experimental configurations of the virtual machine, you need to use the command line.

When you want to create or run a virtual machine on VirtualBox, you will find that VBoxManage is very useful. You only need to use the terminal of the remote host. This is a common situation for servers that require remote management of virtual machines.

Preparations

Before using the VBoxManage command line tool, make sure that you have the permissions of Super Users on servers running Ubuntu 16.04 or that you can use the sudo command, you have installed Oracle Virtual Box on the server. Then you need to install the VirtualBox extension package, which is required to run the VRDE Remote Desktop Environment and access the virtual machine without interface.

Install VBoxManage

On the Virtual Box download page, you can get the latest version of the software extension package you need. The version of the extension package must be consistent with that of the VirtualBox version you have installed!

You can also use the following command to obtain the VBoxManage extension.

$ wget http://download.virtualbox.org/virtualbox/5.0.20/Oracle_VM_VirtualBox_Extension_Pack-5.0.20-106931.vbox-extpack

Run the following command to confirm that the VBoxManage has been successfully installed on your machine.

$ VBoxManage list extpacks

Use VBoxManage on Ubuntu 16.04

Next we will use VBoxManage to show you how easy it is to use the command line terminal tool to create and manage virtual machines.

Run the following command to create a virtual machine that will be used to install the Ubuntu system.

# VBoxManage createvm --name Ubuntu16.04 --register

After running this command, VBoxMnage creates a virtual machine called Ubuntu16.vbox. The virtual machine is located in the VirtualBox VMs/Ubuntu16/Ubuntu16.04.vbox in the home directory ". In the preceding command, "createvm" is used to create a VM, "-- name" defines the name of the VM, and "registervm" is used to register the VM.

Now, use the following command to create a hard disk image for the VM.

$ VBoxManage createhd --filename Ubuntu16.04 --size 5124

Here, "createhd" is used to create a hard disk image, and "-- filename" is used to specify the name of the virtual machine, that is, the name of the created hard disk image. "-- Size" indicates the space capacity of the hard disk image. The unit of space capacity is always MB. We specify 5 Gb, that is, 5124 MB.

Next we need to set the operating system type. If you want to install a Linux system, use the following command to specify the system type as Linux, Ubuntu, or Fedora.

$ VBoxManage modifyvm Ubuntu16.04 --ostype Ubuntu

Use the following command to set the memory size of the virtual system, that is, the memory allocated to the Virtual Machine System from the host.

$ VBoxManage modifyvm Ubuntu10.10 --memory 512

Use the following command to create a storage controller for the VM.

$ VBoxManage storagectl Ubuntu16.04 --name IDE --add ide --controller PIIX4 --bootable on

Here, "storagect1" creates a storage controller for the Virtual Machine. "-- name" specifies the name of the storage controller to be created, changed, or removed from the virtual machine. The "-- add" option specifies the type of the system bus that the storage controller needs to connect to. Optional options include ide, sata, scsi, and floppy. "-- Controller": select the type of the Main Board. The main board needs to be selected based on the required storage controller. Optional options include LsiLogic/LSILogicSAS/BusLogic/intelohci/PIIX3/PIIX4/ICH6/I82078. The last "-- bootable" indicates whether the controller can guide the system.

The preceding command creates a storage controller called IDE. Then the virtual media can connect to the Controller through the "storageattach" command.

Run the following command to create a storage controller named SATA, which will be connected to the subsequent hard disk image.

$ VBoxManage storagectl Ubuntu16.04 --name SATA --add sata --controller IntelAhci --bootable on

Attach the previously created hard disk image and CD/DVD drive to the IDE controller. Insert the Ubuntu installation disc to the CD/DVD drive. Then, use the "storageattach" command to connect the storage controller and virtual machine.

$ VBoxManage storageattach Ubuntu16.04 --storagectl SATA --port 0 --device 0 --type hdd --medium "your_iso_filepath"

This will connect the SATA storage controller and media (such as the virtual disk image created earlier) to the Ubuntu16.04 virtual machine.

Run the following command to add functions such as network connection and audio.

$ VBoxManage modifyvm Ubuntu10.10 --nic1 nat --nictype1 82540EM --cableconnected1 on$ VBoxManage modifyvm Ubuntu10.10 --vram 128 --accelerate3d on --audio alsa --audiocontroller ac97

Run the following command to start the Virtual Machine by specifying the name of the virtual machine you want to start.

$ VBoxManage startvm Ubuntu16.04

A new window is opened, in which the VM directs through the associated file.

You can use the following command to turn off the virtual machine.

$ VBoxManage controlvm Ubuntu16.04 poweroff

The "controlvm" command is used to control the status of the Virtual Machine. Optional options include pause/resume/reset/poweroff/savestate/acpipowerbutton/acpisleepbutton. Controlvm has many options. Use the following command to view all options it supports.

$VBoxManage controlvm

End

From this article, we learned about VBoxManage, a very practical tool in Oracle Virtual Box. The article includes the installation of VBoxManage and its usage on Ubuntu 16.04, this includes using commands in VBoxManage to create and manage virtual machines. I hope this article will help you, and don't forget to share your comments or suggestions.

From: https://linux.cn/article-7582-1.html

Address: http://www.linuxprobe.com/virtualbox-cmd-manage.html


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.