Archive for category Virtualbox

How to load VirtualBox driver

VirtualBox
If for any reason (for instance Genymotion complaining about not finding VirtualBox) and you need to reload the VirtualBox driver keep in mind that the script that do this has been moved in newest Debian/Ubuntu versions, so if you used to run this:

/etc/init.d/vboxdrv.sh setup

Now you must reload the module this way:

/usr/lib/virtualbox/vboxdrv.sh setup


,

No Comments

Repositories for VirtualBox 4.2.x

VirtualBox 4.2.x

 After the release of VirtualBox 4.2.x versions, I decided to update the repositories on one of the computers at work, which runs Ubuntu 12.04. To do so just put the following into the file /etc/apt/sources.list:

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

After this change you must refresh the package list and update VirtualBox:

aptitude update
aptitude install virtualbox-4.2

Repositories on Debian

For Debian testing (wheezy) and stable  (Squeeze) you must put the following lines:

deb http://download.virtualbox.org/virtualbox/debian wheezy contrib
deb http://download.virtualbox.org/virtualbox/debian squeeze contrib non-free

Setting apt-cacher

If you followed the apt-cacher and VirtualBox recipe from this blog, I inform you only the /etc/apt/sources.list file must be edited as explained above, I mean, the apt-cacher server remains unchanged.

Reference: Download VirtualBox for Linux Hosts

,

4 Comments

Installing VirtualBox Guest Additions on CentOS

VirtualBox CentOS

If for any reason you need to install CentOS on a virtual machine using VirtualBox and you want to take advantage of the extras features provided by the Guest Additions (network and graphic drivers, for enabling full screen and mouse integration options) you can follow these steps::

  • In the virtual machine with CentOS install the needed files for compiling the Guest Additions:
yum install kernel-headers kernel-devel
yum groupinstall "Development Tools"

This will take long because it downloads a lot of packages.

  • Select Guest Additions on VirtualBox menu.

VirtualBox Guest Additions CentOS

On the virtual machine a link will be created to mount the CDROM. Right click on it and choose Mount. Once mounted go to:

cd /media/VBOXADDITIONS_4.1.20_80170/

There run the binary file for Linux installation:

./VBoxLinuxAdditions.run

Once it had finished the Guest Additions will be installed on Fedora!

Installing on Red Hat

The above steps are valid for Red Hat, you only need to set a repository from where packages and group of packages will be downloaded.

,

2 Comments

How to shrink a disc on VirtualBox

First off I have to admit that this article has a tricky title, it should say someting like “Copying  the content of a big disk into a small one on VirtualBox using rsync”, but because my problem arose from that need I decided to leave it as it is.

The problem

I needed a 600 GB disk virtual machine image cloned with Clonezilla, as shown in the above picture, but the destination was only a 200GB of hard disk. Clonezilla can’t modify the disk’s hardware information, and I could’t find a way to shrink a disk on VirtualBox, even though about 15 GB out og 600 GB were used.  With Clonezilla you can create images from partitions, but when I tried to recover the image, it recognized that the source system had a 600 GB disk and the destination just 200 GB. On the other hand,  the operating system (CentOS 6.0) had LVM, so restoring from partitions didn’t solve the problem.

The solution

Because the generated image was done from a 600 GB hard disk, I came up with the idea of making a smaller disk of 200 GB and install the operating system there, then copy the needed files from the original disk into the smal disk. So on the virtual machine I created a dynamic 200 GB hard disk :

Shrink disk on VirtualBox - Adding small disk

Then I remove the 600 GB disk (on the example, CentOS Server.dvi), leaving the 200 GB disk (SmallDisk.dvi). Later I installed CentOS as I normally would. It’s a good idea to check the installation, I mean, check that the virtual machine boots with the 200 GB hard disk normally.

Once the operating systmen on the 200 GB hard disk has been checked, turn off the virtual machine and add the 600 GB hard disk, but as primary disk (select SATA Port 0 instead of SATA Port 1). The small disk must be set as secondary by choosing SATA Port 1, as shown on the above picture. Then turn on the virtual machine, and as root mount the 200 GB disk:

mount /dev/mapper/VolGroup-lv_root /mnt/lvm2/root/

And now you can copy the content of the big disk into the small one:

rsync -arpz --progress --numeric-ids --exclude=/dev --exclude=/proc --exclude=/tmp --exclude=/boot --exclude=/home --exclude=/etc/fstab  --exclude=/mnt --exclude=/sys / /mnt/lvm2/root/

Note that  /dev, /proc, /sys, /tmp, /boot, /home, /mnt directories and the /etc/fstab file were excluded, because you won’t want to copy that information on the small disk (for instance, you won’t want to copy the  boot loader from the big hard disk into the small one).

Once  the files have been copied, you can turn off the virtual machine, detach the big hard dsik, leaving the small one on SATA Port 0.

As a final note, all were made with CentOS but it will works on Debian and spin-off as well.

No Comments

VirtualBox Guest Addtions on OpenSuse 10.1

OpenSuse logo

A coworker came to me with a virtual machine running OpenSuse 10.1, where she wanted to use one of the VirtuaBox’s Guest Additions features: shared folders. The first thing I detected was it didn’t have the Guest Additions installed, so I proceeded to install them but the VirtualBox’s installing script didn’t compile because all the stuff needed to compile a Linux module was missing. On this article I describe all I had to do to compile the Guest Additions on OpenSUse 10.1.

OpenSuse 10.1 repositories

First I supposed I had to install the kernel sources and the needed compilers, but checking the repositories I realized that it only had as source the installation CD that was used to create the virtual machine.  OpenSuse 10.1 is an old distribution and its repositories are no longer supported officially, so I had to find somebody who had the mirrors published, so I came across to this mirror list. I used the first option and from Software Sources I put the url shown on the picture:

OpenSuse 10.1 - repo

Requisites to compile the Guest Additions

Once the repository was added I proceeded to install the requisites to compile the Guest Additions, begging with the C/C++ tools and compilers. To do so, I went to the OpenSuse’s Control Center, and from Software Management I choose C/C++ compilers and tools option from the selections, as shown in the following image:

C and C++ Compilers and tools

In order to compile the Guest Additions it still left another requisite: the kernel sources. Here I found another problem, because the virtual machine had kernel 2.6.16.46-0.12-default but the repository didn’t have the sources for that version but the 2.6.16.13-4-default version instead. The solution was to remove the kernel image 2.6.16.46-0.12 and use the one provided in the repository 2.6.16.13-4, to do so yo can use the Software Management or from a terminal type this:

 zypper remove kernel-default
 zypper install kernel-default

Then you can install the kernel sources:

 zypper install kernel-source kernel-sysm

Once installed all requisites, just run the Guest Additions script from the directory it was mounted:

./VBoxLinuxAdditions.run

To changes take effect you must reboot the guest.

Shared folders

You can active the shared folders from VirtualBox’s by going to Device > Shared Folders, and select the one you want to map in the host’s file system. If you check Auto-mount next boot, and for the shown example, a shared folders will appear in /media/Sf_videos

Shared folders

References

,

No Comments

LVM on Fedora / Red Hat


Link to the video http://blip.tv/lgallardo/lvm-on-fedora-red-hat-5908557

On this video you can see the installing process using a LVM on Fedora (it’s also valid on Red Hat). As a side note, the directory that must be outside the LVM is /boot, altoogh I said it was the file system’s root directory /, which also includes /boot.

If you don’t understand some of the LVM terms, you can check out the previous article about basic LVM concepts and some commands to manage a LVM by hand.

,

No Comments

Installing VirtualBox Guest Additions on Fedora

If for any reason you need to install Fedora on a virtual machine using VirtualBox and you want to take advantage of the extras features provided by the Guest Additions (network and graphic drivers, for enabling full screen and mouse integration options) you can follow these steps::

  • In the virtual machine with Fedora install the needed files for compiling the Guest Additions:
yum install kernel-headers kernel-devel
yum groupinstall "Development Tools"

This will take long because it downloads a lot of packages.

  • Select Guest Additions on VirtualBox menu.

On the virtual machine a link will be created to mount the CDROM. Right click on it and choose Mount. Once mounted go to:

cd /media/VBOXADDITIONS_4.1.2_73507

There run the binary file for Linux installation:

./VBoxLinuxAdditions.run

Once it had finished the Guest Additions will be installed on Fedora!

Installing on Red Hat

The above steps are valid for Red Hat, you only need to set a repository from where packages and group of packages will be downloaded.

6 Comments

Installing Oracle VM VirtualBox Extension Pack

VirtualBox Extensions

Now in VirtualBox 4.x the USB support and other stuff are installed using and extra package called Oracle VM VirtualBox Extension Pack. This move by Oracle lets distribute VirtualBox as software libre, so if commercial software is needed it can be installed as an extension, without GPL license infringements.

Installing

Let’s see how to install Oracle VM VirtualBox Extension Pack:

  1. DownloadOracle VM VirtualBox 4.3.28 Extension Pack
  2. Open VirtualBox, then go to  File > Preferences > Extensions  and choose the downloaded file  (see above image).
  3. Add the user to VirtualBox group. On Linux you must add the user who will use VirtualBox to the vboxusers group:
    adduser lgallard vboxusers

    Note: In this example lgallard is the user wichi will use VirtualBox, and for adding users to groups in Linux you must be the system’s administrator (root).

  4. Close the graphical session and log into again to apply changes..

Once it’s done you can use any USB device or the serial port with your virtual machine!!

Old versions

If you need the Extension Packs for older VirtualBox versions, here I leave some:

,

106 Comments

Enabling USB support for VirtualBox on Linux

VirtualBox Usb List

Even in recent VirtualBox versions the USB support is not enabled by default. Some time ago you needed to edit the /etc/fstab, but all that is in the past. Now just add the user which will be using the USB ports to the vboxuser group:

adduser lgallard vboxusers

To apply changes you must log out and log in to run VirtualBox again.

,

6 Comments

Repository for VirtualBox 4.x.x

VirtualBox 4.04 update

I had set VirtualBox to download it from Oracle’s repository as a Debian package when upgrading the system. But I opened VirtualBox and got the above message, thing I found odd since it should have automatically updated. Therefore I did a research and found that VirtualBox’s repository changed, before you put into the /etc/apt/sources.list this:

deb http://download.virtualbox.org/virtualbox/debian squeeze non-free

Now you must put this:

deb http://download.virtualbox.org/virtualbox/debian squeeze contrib non-free

After this change you must refresh the package list and update VirtualBox:

aptitude update
aptitude install virtualbox-4.1

Setting apt-cacher

If you followed the apt-cacher and VirtualBox recipe from this blog, I inform you only the /etc/apt/sources.list file must be edited as explained above, I mean, the apt-cacher server remains unchanged.

Reference: Download VirtualBox for Linux Hosts

,

No Comments