virtualbox script to control Virtual Machines

Additional to my daily job, I need to “play” from time to time in my home server, it’s a quad core machine with 8 gigs of RAM and two hard drives, nothing special about it, the important thing is that it does the job.

About 8 month ago I upgraded the OS and VMWare server started to “complain”, specially the graphical interface, it was discontinued and almost dead, so I decided to move to VirtualBox, I also updated the OS to Oracle Linux 6.

I’m surprised on how complete VirtualBox is and the multiple configuration options available, the graphical interface just doesn’t make justice to the product.

I started creating virtual machines to test my new toy and I realized that when the virtual machines are started from the graphical interface (I use gnome) they have a “collateral” impact on the host performance, having that GUI interface sitting there cost cpu and memory, after that I understood the importance on correctly setting the “VRDE” (Virtual Box Remote Desktop Extension), let me tell you something, it really rocks.
VRDE allows you to connect to your machines, linux, windows or whatever, using your normal Windows remote desktop connection, is a true console that works even if the virtual machine you are connecting to have no network.

I want to share with you a script that I developed using bash shell scripting to control machines on VirtualBox 4, I call it vbctl (VirtualBox control), and it really helps controlling the machines states (startup, pause,shutdown ,save state, etc).

Features
– It will scan the virtual machines in the system and list them (screenshot 1).
– It will allow you to perform operations on them (screenshot 2).
– Designed for headless machines, it will only start headless machines and it will show the RDC port (VRDE Port) in the listing (screenshot 1).
– VRDE activation, if you start a machine with VRDE disabled it will enable it and ask for a port number (between 5000 and 5050).

I want to state that this is not an intelligent script, it will do whatever you ask it to do (with some minor exceptions), for example, it will allow you to shut down a machine that’s already down.

Installation instructions:
– Create a directory (with the virtualbox administrator user).
– Save the script as vbctl.sh
– chmod 740 vbctl.sh
– edit your .bash_profile and create an alias (optional)
alias vbctl=’/<path>/vbctl.sh’

Click to enlarge

Screenshot 1 – Click to enlarge

click to enlarge

screenshot2 – Click to enlarge

One last thing, if you improve this script please share it back!

Enjoy!

Update:

Well, the OperSource spirit arrived sooner than I expected.

In less than two weeks I received the first important improvement!

  • V1.3  can now be downloaded from here

Mr. João Figueiredo improved the visual presentation and added colors! he also fixed minor problem when Virtual machine names have spaces.

Please visit his website for screenshots and details or download the script directly from his website.

Version 1.2 is still available for download.

About these ads
This entry was posted in Linux/Unix, Oracle Server, Virtualization and tagged , , , . Bookmark the permalink.

4 Responses to virtualbox script to control Virtual Machines

  1. Pingback: virtualbox script to control Virtual Machines | Oracle Examples | Linux Blog

  2. Joao says:

    Carlos, this script does exactly what I need: controls virtualbox machines from the command line. While testing it I found and corrected a minor issue with machines having white spaces in their names. I also changed the way it looks by adding color. The new version is available on my website at http://www.enide.net/webcms/index.php?page=vbctl if you want to try it. Thanks for sharing your work.

    • Hi Joao, it was so nice to see my script redesigned with colors, that was major makeup job you did!, thanks also for solving the problem when the names have spaces. I’m using the “overhauled” version now :-)
      Thanks for sharing

  3. João L. M. says:

    Very nice.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s