Book Image

VirtualBox 3.1: Beginner's Guide

By : Alfonso Vidal Romero, Alfonso Vidal Romero Elizondo
Book Image

VirtualBox 3.1: Beginner's Guide

By: Alfonso Vidal Romero, Alfonso Vidal Romero Elizondo

Overview of this book

The furore around virtualization is taking the technology world by storm and is a must for efficient utilization of network server capacity, storage administration, energy, and capital. VirtualBox is free and this brings down your upfront costs for an agile data center. VirtualBox will transform your IT infrastructure into a lean Data Center on a Windows XP/7 or Ubuntu Linux platform. Although VirtualBox has grown by leaps and bounds, there is not enough documentation to guide you through its features and implementation.This hands-on guide gives you a thorough introduction to this award-winning virtualization product. It will help you to implement the right virtual environment for you. Additionally, this book will help you set up an environment that will work for your system. You will learn to architect and deploy your first virtual machine without being overwhelmed by technical details.This practical book unveils the robust capabilities and easy-to-use graphical interface of VirtualBox to help you to effectively administer and use virtual machines in a home/office environment. You begin by creating your first virtual machine on a Windows/Linux guest operating system and installing guest additions. The book then goes on to discuss the various formats that VirtualBox supports and how it interacts with other formats. The comprehensive instructions will help you to work with all the networking modes offered by VirtualBox. Virtual appliances will be explained in detail—how they help to reduce installation time for virtual machines and run them from VirtualBox.By the end of this book you will be able to run your own headless VirtualBox server, to create, manage, and run virtual machines in that server from a remote PC.
Table of Contents (16 chapters)
VirtualBox 3.1: Beginner's Guide
Credits
About the Author
About the Reviewer
Preface
Index

Time for action – using branching snapshots in your VMs


In this exercise, you'll learn how to use branching snapshots so you can create alternate realities in your virtual machines.

  1. Go to your UbuntuVB virtual machine settings page and select the Snapshots (1) tab. Then, select the Before deleting bin folder snapshot and click on the Delete snapshot button or hit Ctrl+Shift+D to delete the snapshot.

    Note

    When you use the Delete snapshot command, you're actually deleting the point in time when the snapshot was taken. So, if you accidentally forget to restore your virtual machine's state to the Before deleting bin folder snapshot before actually deleting it, the Delete snapshot command will erase that snapshot and you'll lose your bin folder forever! That's why you need to be very careful when deleting snapshots because you could lose important data or leave your virtual machine completely useless!

  2. A VirtualBox – Question dialog will pop up, asking if you really want to delete the snapshot. Click on Delete to continue.

  3. Now select the Current State item inside the Snapshots panel and click on the Take Snapshot button:

  4. The Take Snapshot of Virtual Machine dialog will pop up next. Type Fresh Install in the Snapshot Name field, Fresh installation of Ubuntu Karmic in the Snapshot Description field, and click on OK to continue.

  5. The Fresh Install snapshot will appear above the Current State item. Now start your UbuntuVB virtual machine and log in. Once the Ubuntu desktop shows up, open a web browser window, go to http://www.google.com/chrome, and follow the instructions to download and install the Google Chrome web browser.

  6. Wait for the installation process to complete and then select Applications | Internet | Google Chrome and go to http://www.virtualbox.org to verify the Google Chrome web browser is working in your virtual machine:

  7. Now select Machine | Take Snapshot from your virtual machine's menu. The Take Snapshot of Virtual Machine dialog will pop up next. Type After installing Google Chrome in the Snapshot Name field, My Ubuntu VM state after installing the Google Chrome web browser in the Snapshot Description field, and click OK to save the new snapshot.

  8. If you go to the Snapshots tab of your UbuntuVB virtual machine, you'll see that the new snapshot is right below the Fresh Install snapshot you took before:

  9. Go back to your UbuntuVB virtual machine's main screen and shut it down without closing the Google Chrome web browser.

  10. Once your UbuntuVB VM is shut down, select the Fresh Install snapshot in the Snapshots panel and click on the Restore Snapshot button or hit Ctrl+Shift+R to revert your virtual machine's state back to that snapshot.

  11. A VirtualBox – Question dialog will pop up to ask if you're sure you want to restore the Fresh Install snapshot. Click on Restore to continue.

  12. Now start your UbuntuVB virtual machine again. After logging in you can check the Applications | Internet menu to verify the Google Chrome web browser isn't installed in your virtual machine, and the (Fresh Install) message will appear in your virtual machine's title bar to indicate your VM is in the state it was before you installed Google Chrome.

  13. Now open a terminal window (Applications | Accessories | Terminal), type sudo apt-get install konqueror, press Enter, and follow the on-screen instructions to install the Konqueror web browser in your UbuntuVB virtual machine.

  14. Once the installation process finishes, exit the terminal window, select Applications | Internet | Konqueror to open the Konqueror web browser, and go to http://www.virtualbox.org to verify it's working:

  15. Select Machine | Take Snapshot from your virtual machine's main menu, or hit Host + S to take a snapshot of your current configuration. The Take Snapshot of Virtual Machine dialog will pop up next. Type After installing Konqueror in the Snapshot Name field, My Ubuntu VM state after installing the Konqueror web browser in the Snapshot Description field and click on OK to continue.

  16. Wait until the snapshot is fully taken and then shut down your virtual machine without closing the Konqueror web browser window. In the Snapshot panel you will now see three snapshots:

  17. The After Installing Konqueror snapshot will be shown in bold to indicate your virtual machine's current state derives from it. Now select the After installing Google Chrome snapshot and click on the Restore Snapshot button to revert your virtual machine to that place in time where you installed Google Chrome.

  18. The VirtualBox – Question dialog will pop up to ask if you're sure you want to restore that snapshot. Click on Restore to continue.

  19. Start your UbuntuVB virtual machine and log in to confirm the Konqueror web browser is gone and the Google Chrome web browser is shown on your virtual machine's desktop. Now you can go back and forth in time with your virtual machines!

What just happened?

Cool! You'll be able to do all those cool time-travelling tricks from the Back to the Future film series! Well, maybe not all of them, but I bet you didn't think it could be possible to try out different software configurations and then revert all changes as if nothing ever happened, right?

This was a lengthy exercise, but it's worth all the hassle. In steps 7 and 8 you created a snapshot after installing the Google Chrome web browser. If you look at the screenshot from step 8, you'll notice the After installing Google Chrome snapshot is a derivation from the Fresh Install snapshot, and if you look at the screenshot from step 16 you'll notice that the After installing Konqueror snapshot also derives from the Fresh Install snapshot.

Both snapshots are completely independent from each other. This effectively creates two time paths for your virtual machine, and if you take more snapshots on either path, you can go back and forth specific points of time at your leisure!

Note

You can think of a snapshot as a way to capture a specific point in time from your virtual machine.

In steps 17 and 18 you restored the After installing Google Chrome snapshot to go back to the point in time where you installed Google Chrome. From here you can install some other software package or make some changes to your virtual machine configuration, and then take another snapshot to preserve your new point in time, so later you can go back to the point where you installed Google Chrome, or to any other point in time preserved with a snapshot.

Note

With the branching feature you're able to create alternate realities for your virtual machines.

If you take a snapshot when your virtual machine is running, its memory state will also be preserved. That explains why on step 17, when you restored the After installing Google Chrome snapshot, the Google Chrome window was still open in your Ubuntu desktop.

And have you wondered how many snapshots can you take on a single virtual machine? Well, there isn't any limit imposed by VirtualBox, so practically you can take unlimited snapshots, but you need to take into account that each snapshot requires certain disk space in your host, so the only limitation is the space available on your host's hard disks.

Have a go hero – creating more alternate realities for your VMs

Practice with your other virtual machines, taking several snapshots and using the branching feature to create alternate realities. For example, you could install Microsoft Office in a Windows XP/Vista/7 virtual machine, and then create another alternate reality where you can install OpenOffice instead.

Pop quiz – creating alternate realities for your VMs

  1. You need to test two of the most popular IDEs for developing Java programs: NetBeans and Eclipse. The best way to do it would be to:

    1. Get two machines with the same RAM, processor and operating system, and then install NetBeans on one machine and Eclipse on the other.

    2. Use snapshots and VirtualBox to create a virtual machine with two alternate realities: one with NetBeans installed and the other with Eclipse installed.

    3. Flip a coin to decide which IDE you're going to use.

  2. After several days of testing your Eclipse and NetBeans installations, you decide NetBeans is the most appropriate IDE for you. What would you need to do to uninstall Eclipse from your virtual machine?

    1. Delete the snapshot where you installed Eclipse, and keep only the NetBeans-related snapshots.

    2. You'll need to erase everything, reinstall VirtualBox, and create a new virtual machine where you can install NetBeans again.

    3. You need to reformat your host's hard disk, and you'll need to delete all your valuable data!