Virtualbox's secret: Command Line

Source: Internet
Author: User
Generally, virtualbox users may not know the powerful power lurking in the command line interface (CLI.

The most obvious question is, "Why do you need to work with command lines when you have a great Gui ?", The answer is its power. Since 1995, a whole generation of computer users have considered computers as a large collection of windows and graphics, but they are still inseparable. You may ask why it is 1995? Because the introduction of Windows 95 brings people into a new era of graphics. Fvwm95 was released shortly after January 26, August. This is the Linux answer to the Windows 95 browser interface. For me, it seems that the old days of using the command line have gone forever. No one will want to use dos again, and of course they will not be excited about Linux. The command line still exists in the Linux environment and is very good. Command lines are also available in windows. At the same time, Macs is now UNIX-based, and from time to time it will raise non-Gui dust.

You may be surprised to find that the mysterious world is actually a command line lurking in the beautiful GUI, colorful graphics, conspicuous settings pages and numerous drop-down lists of virtuabox. This dark play will show the real power of those who dare to enter this old grave. After you have explored the virtualbox CLI, you may think that the GUI is just a poor window decoration (both Chinese and Japanese), designed for those who ignore the trueProgramThe following are created by those who pass through the undesirable black rectangle.

Command Line Power

The rectangular box I mentioned refers to the terminal window port. The command line provides powerful automated operations. Scripts in Perl, shell, or other languages are the automation methods in * nix systems that I am familiar. The System Scheduling daemon (cron) can help you start these scripts when appropriate. The power displayed through automation requires system administrators to be able to write scripts in their skill reserves. Each type of system administrator operation that will be presented to you requires that you understand shell scripts and at least one of the following interpreted languages.

For virtualization, the command line allows you to quickly create virtual disks, add new NICs, start virtual machines, and create new ones without using the GUI. Script automation also allows you to schedule the startup and shutdown of a virtual machine without any intervention. Further, if you are a very smart script programmer, you can create a powerful script, A series of prompts are displayed for you to create, start, install, or upgrade virtual machines. This requires only a small amount of intervention. If you are a virtual machine that does not want to do anything and has a series of rules for use, you can install a script set for each type of Virtual Machine (as imagined as a template ), then, it takes only one second to create your VM.

Let's take a look at the simplicity and elegance of the command line function in virtualbox.

Installation and basics

Download the binary version in the virtualbox Linux Download Area Based on your system. You can also useSource code. My options (rhel5/centos 5 rpm) install everything in the following places.

* Binary file-/usr/lib/virtualbox. It is also a link to/usr/bin.
* Library file-/usr/lib/virtualbox
* SourceCode-/Usr/share/virtualbox
* Client additional product (ISO)-/usr/share/virtualbox

If your release version is not up-to-date (3.1.2 In this article), you can use a similar downloadable package or source code. Once virtualbox is installed, it is already called a formal user.

Virtual Machine creation and Configuration

The most difficult part of using the command line is to know where to start it. The GUI uses an available new button to simplify the configuration. Exposing this secret using command lines is a little complicated. To create and install a new virtual machine, first open the terminal window or SSH to the Linux host where virtualbox is installed, and then enter the following command.

$/Usr/bin/vboxmanage createvm -- name debian5-register

This creates a virtual machine named debian5 and registers it in virtualbox. The created VM is an XML file located in your main directory :~ /. Virtualbox/machines/debian5/debian5.xml.

Create a virtual disk for your VM:

$/Usr/bin/vboxmanage createhd -- filename debian5.vdi -- size 4000 -- variant fixed

The virtual disk you created is named debian5.vdi, with a fixed size of 4 GB (4,000 MB) (non-dynamic growth ).

Create a virtual disk here :~ /. Virtualbox/harddisks/Debian. VDI

Create a memory controller to connect to a virtual disk and a virtual CD/DVD drive.

$/Usr/bin/vboxmanage storagectl debian5 -- name "Ide controller" -- add ide -- controller piix4

This command creates an IDE controller named "Ide controller". The controller type is piix4.

Now, connect your virtual disk to the virtual machine:

$/Usr/bin/vboxmanage storageattach debian5 -- storagectl "Ide controller" -- Port 0 -- device 0 -- type HDD -- medium debian5.vdi

Connect an ISO image to install the required operating system:

$/Usr/bin/vboxmanage storageattach debian5 -- storagectl "Ide controller" -- Port 0 -- device 1 -- type dvddrive -- medium/ISO/debian-40r3-i386-netinst.iso

Install the network:

$/Usr/bin/vboxmanage modifyvm debian5 -- nic1 bridged -- cableconnected1 on -- bridgeadapter1 eth0

This will create a wired bridging network card that is automatically connected at startup. the Linux system regards it as eth0.

Start a VM:

$/Usr/bin/vboxmanage startvm debian5

If everything is as planned, you will see the following message and your VM window will start to be installed.

Waiting for the remote session to open...

Remote session has been successfully opened.

As you can see, using command line to create and install virtual machines frees you from the crazy mouse clicks and opens a new Virtual Machine Automation world for you. In fact, we have just begun to get into touch with the fur, but this brief introduction is very promising to stimulate your curiosity and give you a chance to learn and explore the powerful power of command line.

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.