Virtual Box for Linux and Windows Integration

[ by Mario Pesce - Datamission.co.uk. ]

Introduction

A few years ago I wrote a report to summarize my experience about moving my PC from Windows to Linux (the original article on my experiences with the product can be found at the URL Win-to_Linux). As most people do,when I started using Linux, I created separate partitions for Linux and used Lilo or Grub to boot either into either Windows or Linux, according to the different job requirements.

I normally used my laptop PC during the day in a company that used Windows applications in a Windows based LAN and therefore I normally had to boot in Windows during the day to work with my colleagues whereas at home I would boot mainly into Linux. This approach has a few disadvantages as follows:

I reached the conclusion that there should have been a better way to use my PC and I looked for a solution that would allow to access both Linux and Windows applications without rebooting.

I investigated some of the available products. I found that the wine or CodeWeavers Crossover supported most common Windows applications, but some other ones would not work. VMWare looked interesting, but I preferred to use until recently Win4Lin (originally developed by Netraverse to support only Windows 95, 98 or ME and later upgraded by Virtual Bridges to support also Windows 2000 and Windows XP) but this product is no longer upgraded and supported,

I had to find a replacement and finally decided to install Virtual BOx, a virtualization platform originally developped by Sun Micro Systems and later supported by Oracle, after its aquisition of Sun.

Some good advantages that I found in Virtual Box are the following:

Installing Virtual Box

Virtual Box can be downloaded from VirtualBox.org, but I did not have to download it because the software is included with my Linux distribution (OpenSuSE 11.3).

You will find plenty of documentation at the VirtualBox.org Technical Documentation page.

The installation is pretty easy, but you must remember to manually add the users who will access Virtual Box to the special user group vboxusers. This can easily be done in OpenSuSe by using the security and users option of Yast.

Using Windows under Virtual Box

I installed under Virtual Box only Windows XP because my main purpose was to create an integrated Desktop environment where I could easily access both Linux and Windows applications

One important requirement for a good integration is to have the possibility to access from Windows also Linux directories because this allows to transfer data between the two environemnts.

Unfortunately this is not very simple to achieve. Virtual Box allows to declare Shared Folders which can be accessed from both Linux (host operating system) and Windows (guest operating systems). I declared my Linux home directory as a shared folder, but when I started Windows the shared folder was not visible in the explorer. This issue and its solution will be better explained in a separate point.

The main advantages of installing Windows under virtual box are the following:

Virtual box Limitations and Peculiarities

Virtual box does not support copy and paste between the Linux and Windows environments.

When you click the mouse in the Windows screen, the system captures the mouse in Windows and it will not move outside of the Windows screen. To use the mouse outside, you need to press a key to un-capture it.

Solution of the Shared Folder access problem

I introduced the problem before and I found it very annoying because it is a serious limitation to the integration between Linux and Windows. I was able to find a solution in the Ubuntu Forums. I summarize the steps needed to solve the problem below:

  1. Start up Virtual box and then start up Windows xp
  2. Go to the top panel of the Virtual Box and click Devices-->Install Guest Editions
  3. Download and install the Guest Editions. This will cause a Windows reboot.
  4. Set up your shared folders in virtual box. For example declare share folder home/documents
  5. Start up Windows, go to Start-->Run, enter cmd and press
  6. once in the dos console, type net use t: \\vboxsvr\documents. Notice that you should put in only the last folder name on the end of the command; for example if you selected a folder under home/mario1/documents the command would be net use t: \\vboxsvr\documents
  7. If you look in the Windows explorer, you will see the new t drive as a shared folder and you will be able to access its content.

Removing the original Window partition

One negative point of having both an original Windows partition and the guest Windows installation is the waste of space (for instance I had MS Office applications installed on both partitions). This setup could offer better security, in case of problems to either the Windows or Linux installation, but, at some point, I decided that I could use better the disk space and work without double booting with Linux and Windows under Windows.

To avoid loosing useful data, I performed following activities:

Making the above copies in the Virtual Box environment is relatively easy, because Linux can access the mnt directory. You can mount the original Windows partition in the Linux /mnt directory by using a command such as:

$sudo mount /dev/sdb3 /media/windows -t vfat -o umask=000

Once the partition is mounted, you can declare mnt as a shared folder and access it in the Virtual Box Windows session..

Once I was satisfied that all important data existed in the Windows environment, I decided to reformat the Windows partition and copy my Linux /home directory, that was included in the main root hierarchy, to a separate partition. This activity is described in detail below.

Using the freed partition for Linux

A good description of how to move /home to a different partition can be found in a good tutorial by Daniel Robbins at IBM DeveloperWorks. The main steps are as following:

Conclusions

I believe that the approach described above allows an optimal use of both Linux and Windows resources.

It is often difficult to use only Linux, because often people need to work in Windows based LANs, interact with other Windows users or just because one is too lazy to learn new applications instead of those normally used in a Windows environment.

A double boot system is inconvenient to use. An integrated solution like that described above allows a much more satisfactory usage of your computer resources and time.