Linux.com

Home Learn Linux Linux Tutorials 5 VirtualBox Tips: How to Install Linux and More

5 VirtualBox Tips: How to Install Linux and More

VirtualBox is the excellent and user-friendly Type 2 Hypervisor that supports all the major operating systems. A Type 2 Hypervisor requires a host operating system to install on, and VirtualBox can be installed on Linux, Solaris, Mac OS X, and Windows. Then you can run any of these operating systems on VirtualBox as guests in virtual machines.

Virtualization is a big deal on servers for boosting hardware efficiency, and it is one of the foundation blocks of cloud technologies. In this fun era of powerful desktop PC hardware, cheap virtualization opens a vast world of possibilities. I use VirtualBox to keep multiple instances of development sandboxes, so I can freely experiment and blow things up without worrying about losing anything. (Note to the Internets: "losing". Not "loosing".) It's a fast and easy way to test distros and capture installation screenshots. Not that installing Linux is very exciting as it's been dead-easy for years. But it's nice to be able to do it.

The more powerful your system the better, because you are running multiple operating systems at the same time. You'll especially want a lot of RAM and disk storage. My upgraded hotrod Intel system has these specs: 

  • Intel i7-4770K CPU @ 3.50GHz with four physical and eight, count 'em, eight virtual cores
  • 16 big ole gigabytes of dual-channel DDR3 1600 memory
  • A small gaggle of 2TB SATA 6 hard disks

In other words, a perfect system for stuffing a bunch of virtual machines into with horsepower and storage to burn. One other thing you must have, and that is CPU support for virtualization. If you do not have this you can still use Virtualbox, but it will be a lot slower. Chances are you do, and you can easily check with this command:

$ egrep -o '(vmx|svm)' /proc/cpuinfo
vmx
vmx
vmx
vmx
vmx
vmx
vmx
vmx

That is eight results for eight cores. vmx is Intel, and svm is AMD.

Figure 1: Give your new VM enough memoryI'm going to skip over installation because it's easy-- just use your favorite Linux package manager.

Install Guest Linuxes

Installing a guest operating system is easy as can be. First download an installation ISO image in the usual way. Fire up VirtualBox, and click the pretty blue New button. You'll see a window like Figure 1. Just fill out the information and click Next. In the next screen you allocate memory. Virtualbox, for whatever reason, recommends 512 MB, which is not enough for most installations. If you're installing a headless server with no graphics it's enough, but if you want graphics then give it more, just as though you were doing a standalone installation. I'm giving CentOS 4GB. This memory will not be available to my host system (Kubuntu) when CentOS is running.

In the next two screens create a new virtual hard drive in VDI (VirtualBox disk image) format. On the next screen you have to choose a fixed or dynamically-allocated hard drive file. A fixed-size is suppose to deliver a little faster performance, at the cost of tying up unused storage space.

On the File Location and Size screen allocate enough space to hold your installation, plus a good buffer for growth. You'll be returned to the main VirtualBox control panel where you can click the Start button. Don't be scared by the clumsily-worded Select Start-up Disk screen, because this just means select your installation ISO image, then watch your new OS go into its normal installation screens. If you downloaded a live CD image make sure to select the hard drive installation boot option, rather than booting the live image.

fig-2-centos

And that's all you have to do for a basic new operating system installation. One thing that often trips up new VirtualBox users is mouse capture: to release it from the VM window, hold down the right Ctrl key. You can configure this in File > Preferences in your main VirtualBox control panel.

Clipboard and Dragon Droppings

Your muscle memory will take over and create vast vexations by trying to copy and paste between your host and guest systems, but this will not work until you enable it. In the main VirtualBox panel select your guest OS, and then click the Settings button. Go to the General > Advanced tab, and enable Shared Clipboard and Drag'n'Drop. That gives you both the lovely Unix select-to-copy/middle-click-paste, and Ctrl+c/Ctrl+v copy and paste. You'll also be able to drag-and-drop files back and forth.

Figure 3: Enable a common clipboard and drag-and-drop.

Snapshots

Snapshots are an amazing and powerful feature for saving the state of your virtual machines at whatever points in time that you want, and rolling back to any one that you want, and VirtualBox makes it so easy you'll dance for joy. On the top right of the VirtualBox control panel click the Snapshots button. Then select which guest OS you want to make a snapshot of, click the little camera icon, give it a name and description, and done. Your VMs can be running or not.

Figure 4: Creating a snapshot.

To restore a snapshot right-click on the snapshot you want to roll back to, then left-click the Restore button. Delete snapshots from the same right-click menu. You can also manage snapshots from the Machine menu inside a running VM.

Clones

Once you have created a snapshot you can clone it by clicking the little clone icon and following the prompts. You'll have a choice of a Full Clone or a Linked Clone. A Full Clone is a complete and independent copy that you can move around and perform terrible experiments on without affecting the original image. A Linked Clone shares files with the original, so you cannot move it independently.

Appliances

This is my favorite feature: set up a VM a certain way, export it as an appliance, and then it can easily be imported by other users into their own VirtualBox systems. For example, I can set up a prefab dev sandbox for a particular project, export it as an appliance, and distribute it to multiple users all ready to go. VirtualBox appliances are created in the standard Open Virtualization Format (OVF), so other virtualizers can import them as well, such as VMWare. Again, it's just click-pointy. The VM you want to export must not be running. Select it in your VirtualBox control panel and use File > Export Appliance. Answer a few simple questions and you're done.

VirtualBox is a remarkable piece of software, and I confidently predict you will find a hundred and one useful uses for it.

 

Comments

Subscribe to Comments Feed
  • Nazir Said:

    I use oracle virtual box on a daily basis. Nice summary.

  • Mark Said:

    I wish this had been written before I had to use it for a Solaris 11 training class. I did a lot of keying when I could have been cutting and pasting...

  • bert0001 Said:

    ... and a great command line interface too

  • Ed Said:

    The VirtualBox 'UserManual.pdf' is worth reading through, there's a lot of valuable info in it, and it's apparently kept pretty current with each release. It's included in every install (mine is in /user/VirtualBox ) and it's also at: https://www.virtualbox.org/wiki/Documentation

  • Eddie G. Said:

    Thank you SO much for this article!....I had been trying to figure out how I was going to run CEntOS / Fedora / Ubuntu / Windows XP / Windows 7 / Windows 8 / Debian OS'es all on this "hulk" of a machine, and now?....with this?...I should be humming along and have everything setup before the end of this week...Cheers!! Will also take the advice posted by "Ed" and read the User Manual from cover to cover!

  • Dan Saint-Andre Said:

    Thanks for the test for 'vmx' feature, but there is another test that I'm curious about. Can someone suggest a test that might indicate "This set of hardware has enough horses to support 1,2,...N guest environments"? Most of the discussions that I read, this one included, has very serious hardware. How can someone with modest hardware get a good idea about how well virtualization might work for them ... BEFORE they invest hours in install and configuration and discover there aren't enough cycles available.

  • Dr.J Said:

    Such a recommendation would indeed be very fine. But I guess it would be very difficult to make because it depends on so much. For example I have a puppy linux VM or a Test environment without any vdi-harddisk. You don't need much power to run them. On the other hand my two main VM's (one LInux Mint and a Windows 7 machine) both need together at least 8 GB RAM when they run together which is mostly the case. A SSD and power cpu is also very helpful.

  • Dr.J Said:

    No doubt about it. Virtualbox is great. Meanwhile I use nothing else, means all my systems including the main operating Linux Mint run in a virtual machine. It's much easier to handle all critical processes such as backups, dist-upgrades like new KDE-releases (first try with a clone !) or new hardware. I recommend it also for security reasons because it's easy to encrypt a second partition, put you all your VM's in it and find everything of your system encrypted, really everything.

  • stewart858 Said:

    I only get error, No DEFAULT or UI configuration directive found

  • prussell Said:

    personally I've found attempting a dual boot system.....(since XP is dead.....) trying to load Linux and Windows 7 has been a huge pain in the ass....Linux: k, ummmmmmm find a Distro....ok...load it to a dvd...k,............oh wait...i do that to an external drive.....soooooooo how do I boot to an external drive, scratch head....read....f12....aaaaaaaaaaaaaaand that didn't work....hmmmmmmmmm . k, Virtualbox!....ya that must be it..........install, configure..........open drive from Virtualbox.................nothing happening...........what did I do wrong.....???? .....let's see I work....have a family....go do other shit with my life....and don't really want to spend 9,000 hrs reading and figuring this out....hmmmmmmmmmm....Linux easy? .............I don't think so......maybe if you DON't have a life ....could be.....


Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board