Author: Mario Pesce
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:
- My work e-mails were in Microsoft Outlook and I had to boot under Windows to access them.
- I used KMail (and later Mozilla Thunderbird) for my personal e-mails and I had to boot under Linux to access them.
- I could access Window folders from Linux and copy data from Windows, but I could not access any Linux directory from Windows.
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 acquisition of Sun.
Some good advantages that I found in Virtual Box are the following:
- VirtualBox 3 is a desktop virtual machine application using a “Type 2″ hypervisor that requires a compatible host operating system (Linux, Windows, Macintosh, or OpenSolaris) and computer hardware based on x86 or AMD64/Intel64 to function
- The installation of Virtual Box is pretty straightforward, but there are a few issues that I will describe later.
- You can easily install many different Operating systems and the performance is pretty good. You can read a list of the supported Operating Systems at virtualbox.org/
- Creating a VM is fast and easy, thanks to a VM creation wizard that takes you step-by-step through creating your guest VM.
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 theVirtualBox.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 environments.
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:
- The Virtual Box Windows installation is surely much better integrated with Linux than a native Windows installation and you will have at your disposal the power of Linux and Windows applications without any need to reboot.
- Windows under Virtual Box offers greater virus protection than a stand-alone Windows installation. You can easily save your Windows directory as a tar archive and many viruses will not have any effect
- There is no Windows boot sector and therefore boot sector or other boot time viruses are ineffective.
- Virtual Box installs Windows files in subdirectories of the host Linux filesystem and therefore FAT32 or VFAT related viruses are ineffective.
- Executable files and macro viruses can still attack, but will not affect the Linux system unless you transfer to the host filesystem an infected file. To reduce the risks, you might decide to declare a directory as a shared folders only when necessary
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 n-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:
- Start up Virtual box and then start up Windows xp
- Go to the top panel of the Virtual Box and click Devices–>Install Guest Editions
- Download and install the Guest Editions. This will cause a Windows reboot.
- Set up your shared folders in virtual box. For example declare share folder home/documents
- Start up Windows, go to Start–>Run, enter cmd and press
- once in the dos console, type
net use t: vboxsvrdocuments. 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: vboxsvrdocuments
- 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:
- I identified the Outlook mail boxes by using the Windows Find option with “*.pst” and copied them to the Windows environment.
- I identified the Outlook Express maild boxes by using the Windows Find option with “*.dbx” and copied them to the Windows environment.
- I identified my Eudora mail boxes (used for my personal mail) by using the Windows Find option with “*.mbx” and copied them to the Windows environment.
- I found the ‘Favorites’ folders used by Internet Explorer and I copied it and its sub-folders to the Windows environment.
- I copied the ‘My Documents’ folder and all other folders that I used in my Windows environment
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 ommand 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:
- Create a filesystem in the new partition by using a command such as mkfs /dev/???
- Mount the new filesystem in /mnt with a command such as mount /dev/??? /mnt/newhome
- Drop to single user mode (init 1)
- Change to the current home directory and enter a copy command such as cp -ax * /mnt/newhome. The ax option causes cp to copy in recursive mode by preserving all file attributes.
- Rename the old /home to /home.old by using the command mv /home /home.old and mount the new one with mount /dev/??? /home.
- When you are sure that everything works correctly, you can remove the /home.old directory.
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.
About the Author
Mario Pesce is a Computer consultant and Developer who has worked for many years in important international companies especially with IBM AS/400 and Linux systems. You can read more on these subjects ont his website Datamission.co.uk and on his blog Mario Pesce UK Blog
Find me on Google+