skip navigation

www.Hilands.com


Content:: VirtualBox

VirtualBox
Last Modified: 2014-01-15
VirtualBox is a virtualization package for the x86 architecture. You can use it to install an Operating System inside another Operating System. We will run through the installation on Debian and show you how to use the Cloning features to duplicate Virtual Machines you already have running. You can use a Virtual Environment such as VirtualBox for many things primarily people use it to run applications they cannot on there current Operating System and test software applications.

Table of Contents
Installing
There are two easy ways to install virtual box on a Debian system. You can either use apt-get and install the "virtualbox-ose" package, or download the package from https://www.virtualbox.org/. With most packages I'd recommend using apt-get, however the current distribution through apt doesn't allow us to sync our iPhones. It seems the restore features don't work to well either way you go, my main purpose is to sync my music library to the iPhone. If you need to remove the package you installed via
# apt-get install virtualbox-ose You can remove the package with # apt-get --purge remove virtualbox-ose

After downloading the virtualbox package you can run the installer with # dpkg -i virtualbox-4.1_4.1.14-77440~Debian~squeeze_amd64.deb Upgrading the package is just as easy, simply run the install with the updated Debian package.

After running the primary installation you'll need to add the user(s) you want to use Virtual Box with to the vboxusers group. # usermod -a -G vboxusers user

For the iPhone features we will need to install the "Oracle VM VirtualBox Extensions Pack". After this is done you'll need to go to the USB settings and enable
Enable USB Controller
Enable USB 2.0 (EHCI) Controller
Cloning instances
To clone a Virtual Machine we will need to use the VBoxMange tool and point it to the vdi file. VDI files in the standard Debian package can be found in
~/.VirtualBox/
If you installed from the websites Debian package you can find the Virtual Machines in
~/VirtualBox VMs/


Inside the folder you will find sub folders for every Virtual system. Each folder contains a Logs sub folder along with a .vbox, .vbox-prev and .vdi file. I prefer to add the cloned VDI files to the base VirtualBox VM folder. My original image is called "WXP-PRO-OEM", lets navigate to where the VDI file is located. # cd ~/VirtualBox\ VMs/WXP-PRO-OEM/ We will now clone the WXP-PRO-OEM.vdi file to ~/VirtualBox VMs/WXP-cloned.vdi $ VBoxManage clonehd WXP-PRO-OEM.vdi ../WXP-cloned.vdi

Now that the core VDI file has been cloned we can create a new Virtual Machine using this file.
VirtualBox - New
From the VirtualBox Manager window click on the New button to create a new Virtual Machine.
VirtualBox - New VM Wizard
The next window is a welcome notice to the Virtual Machine Wizard, click the Next button.
VirtualBox - VM Name
Choose a name for your Virtual Machine and enter it into the Name text field. I prefer to choose a name similar to the VDI file. Click the Next button to continue.
VirtualBox - Memory
We will now choose the amount of memory we want the Virtual Machine to be able to allocate. With 8 GB of memory on my primary system I choose to allocate 2 GB of memory space for the VM. After entering the amount of memory to allocate in the text field, or using the slider bar, click the Next button to continue.
VirtualBox - Existing Hard Disk
To use the cloned VDI click the radio button for Use existing hard disk. We will have to tell VirualBox to find the file, to do this click the Folder Icon next to the select box.
VirtualBox - Choose file
Locate the VDI file we created with VBoxManage and click the Open button.
VirtualBox - Hard Disk
Verify the select box has the correct VDI file and click the Next button to continue.
VirtualBox - Summary
Verify the data on the summary screen and click the Create button.
VirtualBox - Manager
Back to the VirtualBox Manager window we can now start our cloned Virtual Machine!
Port Forwarding
The network adapters are set to NAT when creating a VM. The VirtualBox NAT will create a private 10's network VLAN to put the VM's on. We can use the natpf1 switch with the VBoxManage tool to redirect # VBoxManage modifyvm <vmname> --natpf1 "[<rule name>],<protocol (tcp|udp)>,[<hostip>],<hostport>,[<guestip>],<guest port>" For example we can use the Hosts port of 2222 to contact port 22 on the guest system with: # VBoxManage modifyvm TestVM --natpf1 "ssh,tcp,,2222,,22" We could also redirect http traffic with # VBoxManage modifyvm TestVM --natpf1 "ssh,tcp,,8080,,80"
References