VirtualBox

From MEPIS Documentation Wiki

Revision as of 20:56, 23 October 2012 by Jerry bond (Talk | contribs)
Jump to: navigation, search

Contents

Required knowledge

  • Opening a console and issuing simple commands
  • Copy and Paste

Introduction

VirtualBox is a software package that allows you to run another OS from within MEPIS, in a so called Virtual Machine (VM). Of course, there are other VM solutions, but VirtualBox has some outstanding characteristics:

  • Almost completely Open Source (except for some addons)
  • Easy installation
  • For Linux and Windows host systems
  • Linux, PC BSD and Windows guest systems
  • Very fast and lightweight

For examples of how you might use it, consider that you can install beta-test versions of MEPIS in a VM. This is especially useful, in that you can even SKIP the whole step of burning the ISO file onto a CD, because VirtualBox supports the ability to install directly from the ISO-file. [See the details below, in the 'Using an ISO' section.] And, of course, you can also try out some other Linux distro this same way.

In fact, you can convert any install-CD that was made from an ISO-file, back into an ISO-file, by doing a 'rip' of it. This includes Windows-install-CDs. Use a cmd of the form:

dd if=/dev/cdrom of=my_win_kit.iso

[Yes, it's legal to do that...the Microsoft protection gets enforced LATER, during the installation, when you are asked for a valid 'product-key'. OEMs backup their kits this way, to guard against scratches on their media copy.]

Preparations for installation

To prepare MEPIS for installation of VirtualBox, you need to install a couple of required packages. Act as follows:

Open a console --> type "su" and enter root password --> paste this command into the console:

m-a prepare

Done. We can now proceed to get VirtualBox and install it.

Installation

MEPIS 11

1. Add this line in to the repositories in /etc/apt/sources.list. See Editing sources.list.

deb http://download.virtualbox.org/virtualbox/debian squeeze contrib

2. Run apt-get update or reload the Repositories in Synaptic. If you get a " public key is not available" error, try the Easiest or manual method at the Public key not available error wiki page; or Run this command as root to add the Sun public key:

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

3. Use Synaptic to find and install the virtualbox package. You will find the application in Kmenu >>> System >>> Oracle VM VirtualBox


MEPIS 8 and MEPIS 8.5

Add this line in /etc/apt/sources.list (use Synaptic or edit it as root in a terminal with any text editor)

deb http://download.virtualbox.org/virtualbox/debian lenny contrib

Run this command as root to add the Sun public key:

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

Update sources:

apt-get update

If you get a " public key is not available" error, try the Easiest or manual method at the Public key not available error wiki page.

Install VirtualBox with this command (where "x" indicates latest version available):

apt-get install virtualbox-4.x

If it asks "Should the vboxdrv kernel module be compiled now?", you can say Yes.

MEPIS 7

As of mid-June, 2008, Sun Microsystems has disabled the repository supplied with MEPIS 7. You now must manually download the package from this page (choose the Etch version for MEPIS 7)

Important: before installation, you need to run "m-a prepare".

MEPIS 6.x

Go to the VirtualBox website and download from this link. Make sure you get the correct binary package. If you use MEPIS 6.x, you need to get Ubuntu 6.06 LTS ("Dapper Drake"). For MEPIS 7, you need to get Debian 4.0 ("Etch") version.

When the package is downloaded, open Konqueror and go to the folder where you saved the VirtualBox package. Press F4 to open a console in that folder. We are now going to install it via the command line.

  dpkg -i virtualbox*.deb

Please note that your actual package name may differ. To avoid problems with the name, start typing dpkg -i virtual and then enter a TAB. This will autocomplete the command.

The package will now be installed. At one time, it will ask you if you want to compile the kernel module. Just answer yes and the module will be created automatically.

Running VirtualBox

Once installation is finished, you need to reboot. If you don't reboot, you can only run it as root. After a reboot you should be able to run VirtualBox in your regular user account and your Virtual Machines will be created in ~/.VirtualBox (that is: /home/user/.VirtualBox).

To launch VirtualBox, goto Kmenu >>> System >>> Oracle VM VirtualBox (Virtual Machine). Or from the konsole, enter "VirtualBox" (without quotes, and note the mixed-case).

You might have to add your username to the user group "vboxusers". To do this, launch KUser by clicking KMenu --> System --> More Applications --> User Manager (KUser). If you prefer the command line or you're using antiX, as root, execute

   usermod -G vboxusers -a username

insert 'username' with your name. Log out and log back in for changes to take affect.

Settings

Create a New Virtual Machine (Linux)

To create a new VM, click the NEW icon on VirtualBox's toolbar. You will be guided in creating a VM with a wizard.
If you are installing MEPIS as a Virtual Machine: when it asks for "OS type" and "Version", MEPIS is not in the dropdown list. Since it is informational only, you can use OS type = "Linux" and Version = "Debian" or any other choice you are comfortable with. For Base Memory, select at least 512MB; For other choices/questions during the wizard process, you are usually safe to accept the default settings.

Now start your new VM (highlight it and click Start). You will now go through a "First Run Wizard": Select Installation Media: Your Media Source can be either a DVD/CD-Rom Drive or an ISO file: To use an ISO file, select the Folder Icon on the right side. That will open up the "Virtual Media Manager" Click "Add" icon to find and select your iso file. Upon finishing the Wizard, your new VM should boot up as if booting a live Cd.

To fully install MEPIS as a VM (as opposed to just running live) click "Install" icon on the MEPIS desktop and install as normal. Note: For step 1. Use disk sda and select "Auto-install using entire disk" and select "YES" for "OK to install GRUB bootloader at sda?" After installation process is complete, you can reboot your VM. Now to keep future boots from booting into a Live session: while not running your VM, select settings. On the "Storage" under IDE controller, select the iso file, then on CD/DVD device dropdown (the CD icon), select "Host Drive.." [or "empty" if you don't have CD/DVD drive]. Click OK to finish.

Once created you can tweak the VM settings (if it is not running) by clicking on the appropriate item on the right side of the VirtualBox screen. Settings such as System memory, video memory, Audio and others can be refined here.

For example, audio should be set to what your host is using such as alsa. Slow and unresponsive VM's can be improved by increasing system memory, but do not set it too large or it will be counterproductive. A setting of 356 MB seems to work fine for most Linux distros on a 1 MB machine. In other words, a good rule of thumb for starters would be to keep 2/3 of memory for the host machine and give 1/3 of memory to this virtual (aka guest) machine and then tweak/tune this later as needed.

Create a New Virtual Machine (Windows)

To install Win-XP Pro into a VM, you will probably need to follow a detailed example tutorial. One such tutorial can be found at: http://ubuntuforums.org/showthread.php?t=433359 Other examples can be found by doing a Google-search using keywords like: 'virtualbox tutorial Windows'.]

Cloning an Existing Virtual Machine and Enlarging an Existing Hard Disk

To clone an existing VM's Hard Disk (that is its *.vdi file, in this example called existing.vdi) follow these steps in a Konsole (adjust file locations/names as necessary):

  • Change directory to VirtualBox Hard Disk folder with this command:
cd /home/user/.VirtualBox/HardDisks
  • Create the clone with this command (follow the upper/lower cases exactly):
VBoxManage clonehd existing.vdi newclone.vdi
  • To use the cloned Hard Disk, Create a new VM and in the wizard when you select the Hard Disk, choose "Use existing hard disk" and select the newclone.vdi

An alternative cloning method is to first create a new VM with a new Hard Disk, named "newclone.vdi" in this example, and then clone the *.vdi into the newly-created Hard Disk:

VBoxManage clonehd existing.vdi newclone.vdi --existing
  • By making "newclone.vdi" larger than the original *.vdi file, the cloned Hard Disk will be an enlarged version of the original.

If an existing Hard Disk is Dynamic, it can be enlarged to xxxx MB in one step with this command:

VBoxManage modifyhd existing.vdi --resize xxxx
  • NOTE: To avoid a common fatal error using the above commands, enter the full path names of the *.vdi files, and avoid using abbreviated path names.

When a virtual Hard Disk is enlarged (using either the clonehd or the modifyhd method), the enlarged portion will be unallocated space. To make use of the unallocated space, use GParted to expand the partition(s) contained within the .vdi. To do this, locate a bootable CD (or its .iso image) with GParted installed on it, such as the Parted Magic CD. Attach the bootable CD or image to the VM's CD/DVD ROM controller, making sure the VM boots from the CD/DVD ROM first, and start the VM.

Using an ISO

A nice feature (and an essential one on machines without a CDROM drive) is to set the CDROM to virtual and specify an iso file of the Linux distro you want to install into a VM. It will then boot directly from the iso file into your VM and you can install permanently (for those LiveCD's having an install feature). [This is a great way to test MEPIS-beta/RC kits.] See Create a New Virtual Machine (Linux) section above for detailed steps.

Guest Additions

Important tip: Be sure to install VirtualBox GuestAdditions to your Guest OS, from the .iso file that is included with your VirtualBox installation. This will allow you to:

  • link one or more folders on the hard disk, which are accessible from the Host OS, with the virtual network installed in the Guest OS. This enables sharing files between Guest and Host.
  • adjust your display in various ways so that it suits your environment and habits

Steps:
1. Start the guest and inside the host: Open a konsole, and as root, enter the command:

m-a prepare

This installs the kernel headers and build essential packages required to build the Guest Addition modules.
2. From the top menu bar in VirtualBox select Devices >>> Install Guest Additions. You should see iso or CD image for the virtual additions in the device notifier and/or Dolphin file manager.
3. Click to mount it - and it should open in Dolphin.
4. Hit F4 to start a konsole session in that directory (/media/cdrom). Su to root. Now issue following command (depending on your guest architecture is 32 or 64 bit) and let it run:

sh VBoxLinuxAdditions-x86.run

OR

sh VBoxLinuxAdditions-amd64.run

5. The script should run, and Guest Additions install. Reboot the guest and you should have additions running.

VB Extensions package installation

Make sure you have the Extension Package that goes with your version of VirtualBox GUI

  • open VBox
  • click File > Preferences
  • click Extensions in left hand panel
  • lick Add Package button to the right of RH panel (the small top icon on the right-hand edge)
  • navigate to the Extension Package and select it
  • click Open and provide root password
  • On the proprietary version you will be asked to say you agree with their terms of use, it will not install unless you tell it Yes

CLI

  • open Konsole, become root, type [code]VirtualBox [path/name of extension package][/code], enter
  • On the proprietary version you will be asked to say you agree with their terms of use, it will not install otherwise.

Use USB devices in the virtual machine

  1. Make sure you use the full edition from Sun not the OSE (Open Source Edition) edition that Debian provides.
  2. Make sure you check "Enable USB Controller" in VM settings.
  3. If the USB devices still appear grayed out, add this line to /etc/fstab file (in the static part of it, the part before "Dynamic entries below" line):
none /proc/bus/usb usbfs devgid=46,devmode=664 0 0

Documentation

Don't forget to get the excellent User Documentation. There you will find info regarding host shares, how to install the VirtualBox addons (for better screen resolution and mouse integration) and loads more.

Troubleshooting

If you get a message saying "VirtualBox kernel driver not accessible, permission problem" when starting VirtualBox right after installation, your user account is probably not listed in the vboxusers group. The installation takes care of creating that group, but you will need to manually add all users to it that should be allowed to run VirtualBox.

As root, for each such user, run

usermod -G vboxusers -a username

If you replaced the kernel you need to run these commands:

m-a prepare
/etc/init.d/vboxdrv setup

Useful Links

Personal tools
In other languages