≡ Menu

How to Install Oracle VM VirtualBox and Create a Virtual Machine

Oracle VM VirtualBox is an open source virtualization software that you can install on various x86 systems. You can install Oracle VM Virtualbox on top of Windows, Linux, Mac, or Solaris. Once you install the virtualbox, you can create virtual machines that can be used to run guest operating systems like Windows, Linux, Solaris, etc.

On a high-level Oracle VM VirtualBox is similar to VMware. Oracle got this VirtualBox technology from Sun.

This article cover the basic installation of virtualbox and how to install a guest OS on it.

If you are interested in VMware, use this guide: How to Create VMware Virtual Machine and Install Guest OS using vSphere Client.

The following are the basic terms you should be aware of before we go further:

  • Host – The physical machine where you are going to install VirtualBox
  • Guest – The machines created using VirtualBox. ( Virtual Machine )
  • Guest Additions – A set of software components, which comes with VirtualBox to improve the Guest performance and also to provide some additional features.

1. Installing VirtualBox

This article explains how to install VirtualBox on a Debian based system.

First, add any one of the following mirrors based on your distribution in /etc/apt/sources.lst

deb http://download.virtualbox.org/virtualbox/debian oneiric contrib
deb http://download.virtualbox.org/virtualbox/debian natty contrib
deb http://download.virtualbox.org/virtualbox/debian maverick contrib non-free
deb http://download.virtualbox.org/virtualbox/debian lucid contrib non-free
deb http://download.virtualbox.org/virtualbox/debian karmic contrib non-free
deb http://download.virtualbox.org/virtualbox/debian hardy contrib non-free
deb http://download.virtualbox.org/virtualbox/debian squeeze contrib non-free
deb http://download.virtualbox.org/virtualbox/debian lenny contrib non-free

Next, download the public key and register with apt-key for signature verification

wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -

Finally, installing VirtualBox as shown below.

sudo apt-get update
sudo apt-get install dkms
sudo apt-get install virtualbox-4.1

After successful installation a command named “virtualbox” will be created. Also you can access VirtualBox from “Application -> System Tools” menu.

2. Creating a Virtual Machine ( For Guest OS)

Open Application -> System Tools -> VirtualBox ( Command name is “virtualbox” )

Click Machine -> New. This will launch a “Create New Virtual Machine” wizard. Click Next.

Enter the name of the Guest machine as you desire and choose the Operating system and Version that you are planning to install as follows, and click “Next”.

Enter the RAM size that you want to provide to your Guest machine as follows.

Now it will ask you to choose your “Virtual Hard Disk” for installing the guest OS as follows.

Since this is the first time we are installing, click “Create New Hard disk”.

Create “New Virtual Disk” wizard will open. Click Next

Now we need to choose, whether the disk has to be “Dynamically expanding disk” or “Fixed-size storage”.

Remember, for a guest machine, it sees a file residing in the host machine as the “Hard Disk”. Whenever a guest machine does any write to disk, it will be written into the file which resides on the host machine

If we select “Fixed storage” and if we choose the size as 10GB then, in host machine ( by default under .VirtualBox/Guest-Machine/Guest-Machine.vdi ) a file will be created with 10GB of size

If we select “Dynamic storage” then, .VirtualBox/Guest-Machine/Guest-Machine.vdi will initially be a small size file, but it will grow whenever the guest machine writes data to the disk.

Choose “Dynamic storage” and click Next.

Enter the maximum size that you want to allocate for the guest machine.

Click Finish. Now a file named “Guest-Machine.vdi” will be created under “.VirtualBox/Guest-Machine/”

Click “Finish” to complete the creation of Virtual Machine.

Now a new “Virtual Machine” is created and it will be in “power off” state.

3. Installing OS in a Virtual machine

We can install any OS ( personally tested windows and linux ) on a virtual machine. We can install the OS in virtual machine by 2 methods

  • Through OS-DVD
  • Through ISO image of the OS

Here we will cover the installation using an ISO image, although using DVD is very similar to this.

Make sure that the iso file of your distribution is present in the host machine.

Launch “virtualbox”. Select the newly created virtual machine. Click “Settings”.

Now a new window will open which will list out the settings group on left panel and actual setting on the right side as follows.

Select “System”. On the right panel ensure that the boot order is correct ( Similar to setting the boot order in BIOS ).

Use the “Move Up” or “Move Down” button button to change the boot order, and make sure CD/DVD is selected as the “First boot device” and click “Ok”.

The next step is to map the “ISO file” of your distribution to the virtual CD/DVD device.

Under “Settings” go to “Storage”, the following screen will appear.

Click the “CD icon” and choose the “iso file of the OS”, here I used “Debian-Lenny”.

The following screen will appear once you have choosen the ISO file. Click “Ok”.

Now select the virtual machine, and click “Start”. It will start to boot from the CD/DVD which is mapped to the ISO file.

The OS installation is similar to installing an OS in a physical machine.

Once OS is installed successfully, change the “Boot Order” to boot from HDD, and click “Start”.

Now you can start using the virtual machine as like other machines.

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

{ 36 comments… add one }

  • Jeff February 3, 2012, 6:19 am

    Not a bad tutorial. Can I suggest a second, follow-up topic? The two biggest issues I have with Virtual Box are 1) getting a virtual machine to run automatic and headless at host startup, and 2) installing guest tools on linux VMs. Both of these topics can be tricky based on guest VM OS.

  • Ward February 3, 2012, 10:45 am

    thanks for the tutorial. I have been using Virtual Box for years to take new distrobutions that I am interested in for a spin.

    Jeff…..Oracle has the ability to run automaticly and headless…..howtoforge.com has a great article on this that will walk you through doing just this sort of thing. If you want the virutal machine to continue running after you kill your ssh session use a nohup when you run the VBoxHeadless command. Hope this helps

  • Will February 3, 2012, 11:01 am

    I would like to see examples of running VirtualBox on Windows7 and running Linux as guest OS. Thx.

  • Valo February 3, 2012, 11:08 am

    Yeah, once in university i try to install the Guest Additions in a CentOS 5.3 and it was’n tanything like smooth ride. It was very hard and like Jeff i think that is a pretty cool idea for you to do a second part of this tutorial.

    I’m from Mexico and really, really dude your posts are the best. I love your blog

  • Bill Semmendinger February 3, 2012, 11:58 am

    A good tutorial, I thought it was clean and easy to understand. I have thought about delving into using a virtual box for a while but just never took the time to look into it. I’m glad you put this out.

  • Avinash February 3, 2012, 12:34 pm

    Great…Thank you…

  • Lakshmanan February 3, 2012, 11:42 pm


    1) To start the VM automatically at host start-up, in /etc/rc.local enter the below command.

    VBoxHeadless –startvm “Machine-Name”.

    It works for both windows and debian as guest OS.

    2) With regard to installing the Guest Additions, I’ve not had issues with windows Guest OS and Debian/Ubuntu Guest OS. I can help, if you provide me the exact problem you faced.

  • addison February 4, 2012, 12:40 pm

    I’ve had a less than stellar experience with VirtualBox. The host was Windows Vista 64-bit and the client machine Solaris 11 64-bit. Four installation attempts and at no point was the OS ever accessible. If it didn’t lock during the initial installation, it would would boot and hold at a splash screen indefinitely.

    Installed VMware Workstation 8 and Solaris 11 installed the first time and works wonderfully.

  • Fractal February 14, 2012, 3:00 pm

    Hard stuff…

  • Bob C March 1, 2012, 1:10 am

    @addison I seem to recall a blurb that currently you can only install 32-bit versions of Linux OS in a WIndows 7 VirtualBox. This may also be true for Vista.

    @Will I found installing VirtualBox on Windows 7 to be straightforward. Download the exe file (currently 4.1.8) and run it. I agree a tutorial would be nice.

    I would also like to see a tutorial on “Exporting and Importing”. I have a few log-ons on my Win. 7 and it looks like I installed VirtualBox twice (for 2 Win. 7 users). One uses a separate partition for the virtual machines (which is what I want) and the other installed the virtual machines in its partition (rather than in the separate partition). Trying to read through the humongous PDF is trying to say the least.

    Another discussion would be nice is reading the VDI file under Windows (or setting up a “shared directory” for data exchange).

  • Jalal Hajigholamali March 29, 2012, 10:10 am


    Very nice article..

  • Alex Kratinoha April 1, 2012, 3:19 am

    nice tutorial, but for me little bit useless – I am hobbyist using virtualbox over 3 years.

    What about try tutorial for VMware?

  • Lakshmanan Ganapathy April 1, 2012, 10:49 pm


    VMWare tutorials are already available. Please check out the archives page

  • The Red Gator in Virginia April 30, 2012, 3:29 pm

    I have been running 64-bit RHEL6.1 under VirtualBox 4.1.* on a Windows 7 64-bit Dell M4500. Just installed 4.1.14, and am now running an MRG 2.0 kernel which had not worked previously.

    Always, ALWAYS getting better…

    You certainly can’t run a 64-bit OS as a guest on a 32-bit host, but 64-bit Linux on 64-bit Windows 7… yes we CAN! (Sorry, lost it for a moment…)

  • manea June 1, 2012, 2:59 am

    Thx guys to all of you for such rich discussion.

    My situation is different here. I am running dual OS i.e. Mac OS + WinXp (bootcamp) & I just need Oracle VMbox to boot from the existing WinOS (Which installed in separate physical partition). Can I do such scenario or I have to do new Guest OS installation?

    Thank you..

  • Clare August 8, 2012, 3:42 am

    Your post was the best one I found that explained why I kept getting the error – thank you I have been trying to get it to work since 6pm and it is now 7:40pm….

  • Eyal October 3, 2012, 12:18 pm

    I just ran into a weird problem. I am running Ubuntu 12.4 64 bit, I set Orcale’s VB 64 bit. But when I was instaling Windows 7 64 bit in the virtual box I got a message that Windows 64 bit is in compatible with the CPU! My CPU is 64 bit and all the sofwatre in between is 64 as welll…What should I do?


  • Daria October 6, 2012, 2:06 am

    where did you find the iso file of the OS? I want to run Win7 on a virtual machine but i can’t find this file to use in CD/DVD device.

  • Sivani singh October 12, 2012, 2:57 am

    Need the steps involved to create the host over vmware with guest os windows7 and the host should be available to the base machine hosting vmware.using oracle vmware4.0

  • Lakshmanan Ganapathy October 12, 2012, 10:03 am


    Read the “Supported guest operating systems” in http://www.virtualbox.org/manual/ch03.html.

    Hope it will help!.

  • Daria October 12, 2012, 10:23 am

    thanks very much for help! :)

  • David November 22, 2012, 11:06 pm

    Before installing Virtualbox 4.2.4, system RAM was 4.0GB(3.86GB usable). After successfuly installing VBox, the system RAM is 4.0GB(3.36GB usable). Didnt create any VMs either, only just installed VBox. I uninstalled VBox, still the system RAM is at 3.36GB usable.

    Why did I lose approx. 500MB of RAM on installation?
    Does anyone else also faced this issue?
    One of my friend also faced this exact issue.

    It’ll be very helpful if someone can answer to my queries.

  • priyanka January 22, 2013, 11:55 am

    thank u
    it helped me wen i needed it most
    thank u so much

  • Eb February 1, 2013, 1:24 pm

    I have the raspberry pi b running wheezy Debian when I say to it sudo apt-get install dkms it says package not found I’ve tried login in as root but nothing help me

    Many thanks

  • priyesh February 3, 2013, 9:39 pm

    Its really nice and helpfull.

  • Alexander Appleton February 11, 2013, 10:28 pm

    Thanks, this is a very helpful tutorial! Worked great with elementary OS.

  • tarun July 28, 2013, 2:37 am

    from where will i get iso files of operating system to install.. help me

  • Bob July 30, 2013, 3:50 pm


    It depends on which OS you want to install. Windows? Apple? Linux?

    Windows – you need to have the OS CDs/DVDs (unless they happen to have a “Preview” available (usually for a new release and then limited time – like a trial). Assuming you have the CDs/DVDs, just pop them into the DVD unit like you would install Windows in a real machine. Start your VM (assuming you have created one at this point) and then follow the procedure to install the OS. There is a project called “ReactOS”, which is creating a clone of Windows XP and is free. You can download the “.iso” file and either burn it to a CD/DVD or install from where you downloaded the ISO.

    Apple – I will leave that to someone else as I have never used a Mac.

    Linux – there are many Linux distributions. See: http://distrowatch.com/ which lists all (or most) of them. Some of the more popular are Linux Mint, Ubuntu, Ubuntu variations (Mint being one), Debian (“base” for Ubuntu and variants), SLAX, OPpen SUSE, Fedora, etc. Again, you can install them into the VM the same as described for Windows. If you scroll down a little ways at distrrowatch.com, you will see a list of the top 100 “distros”. Clicking on one, will take you to a description and download link to for that particular distro. Of course, you can always Google for a specific one too. Nearly all are free downloads.

    One thing to note is when you “Start” the VM to install, you will see on the Menu Bar of the VM “Machine, View, Devices, Help”. If you click on “Devices”, you will get a drop-down list with CD/DVD Devices at the top. Selecting that option will show at least 2 entries – 1. Choose a virtual CD/DVD file ,,, , 2. Host Drive ‘x:’ (where x: is your real CD/DVD drive. By choosing the first option, you can navigate to the directory where you downloaded the ISO file and select it. It will then be booted as if it were on a CD/DVD. Depending upon the state of the VM you created, you may have to restart if you can’t reboot immediately after selecting an ISO file rather than an actual CD/DVD.

    One last point. VirtualBox not only supports Mac OS X, but also 64-bit Guest OSes. Section 3.1.2 of the current VirtualBox release (4.2.16) discusses the caveats.

  • abhi@32 September 14, 2013, 11:19 am

    Thank a lot!!

  • eran October 28, 2013, 3:13 am

    there is a mistake in the repository location:
    /etc/apt/sources.lst -> /etc/apt/sources.list

  • Chris November 20, 2013, 5:35 am

    Clear and well presented article.

    One suggestion bold and perhaps increase font size for this senetence “Once OS is installed successfully, change the “Boot Order” to boot from HDD, and click “Start”.”

    That one sentence makes all the difference.

    Thank you.

  • adesh June 5, 2014, 12:24 am

    Hello everyone,

    I want to install RT linux on a virtual machine (either Virtual Box/Vmware ) on windows 7 .
    can you please suggest :
    -> which VM to use or best for use for installing RT linux ?
    -> which kernel version are supporting RT linux ?
    -> the steps to do it.

    Thanks in advance.

  • Tarun July 1, 2014, 5:51 am

    Is it posible to drag file or folder from source Window machine to VM window client? machine.

  • Bob C July 5, 2014, 10:40 pm

    @Tarun You can set up a “shared” folder to pass files back and forth. You need to make it shared on Windows and when you set up your guest machine. For example, I have a couple of Linux guests (Windows 7 is the host) and when you click on the VirtualBix settings, at the bottom,l you will see an entry for “Shared Folders”. You can point the entry for this setting to the “shared” Windows folder (in my case) and I have it set to “automount = yes” and “access = full”. On Windows, you need to click on the properties for the “shared” folder and make it shared (I made it fully shareable for everyone).

  • ansari m October 30, 2014, 5:56 am

    very nice article sir … thank you very much

  • kumar December 9, 2014, 12:02 am


    I have WIndows7 32 bit as a host OS in C drive. and i have installed the Virtualbox in D drive and installed CentOS 6 in virtual box as a guest OS.

    After installing the Guest Additions in CentOS and set the Drg n Drop-Bidirectional. it permits to create shared folder in CentOS but i am not able to drag n drop to any file from host to guest and vice versa.

    also when i plug the pendrive it copy the partially data in guest OS then it show unpluggeed automatically in guest OS. It copy only .rpm file in guest OS (CentOS)

    please suggest how to copy the file from Host OS to guest OS and vice versa. and how to use share folder.


Leave a Comment