In my previous post, I’d mentioned about Virtualization – what it is, how useful it is to test new softwares, distros etc. Now while working in your virtual machine, you’d obviously save some data – do some wordprocessing, or compatibility testing of your programs, just to name some, all this would mean that the data would be stored in the virtual machine.
Now you would like to have this data on your physical machine. Or alternatively you may want to transfer data from your physical machine to your VM. Of course, you could always go about using the concept of shared folders, but this would require installation of guest-additions. On a linux-based guest, this would require running scripts, and these scripts most likely require kernel-header or kernel source files. Going by my past experience, in most default installations, the header files would not be installed, or simply be missing in all of Live-CD based distributions, requiring downloading of the packages from the Internet. Is there a simpler way of going about this? Yes! Lets see how.
For this post, I’ve used Sun’s xVM VirtualBox 1.6, but the steps would be identical, albeit with different terminology, for other VM software like VMWare. The method requires that you share a Windows folder, most likely the folder to which you will transfer the data from the Virtual Machine. To share a folder, just right-click on it, click on Sharing & Security, put a Checkmark against “Share This Folder on the Network”, give a suitable name, and also put a Checkmark against “Allow Network users to change my files”. This is a critical part, else the shared folder would have read-only access.
Next, Launch VirtualBox, click on the VM, then Click on Settings. In the list of different options, click on Network. At the Host Interfaces tab, click on the “+” icon.
Give a suitable name, Click on OK. Next, Change the Attached to from NAT to Host Interface
You might be prompted by Windows regarding installation of new driver – about the driver not digitally signed, just click on Continue anyway and complete the driver installation. To verify that driver installation was successful, bring up the command prompt by Clicking on Start, Run, typing cmd. Open the prompt is up, type ipconfig to show a list of network interfaces. VirtualBox’s adapter will be shown as VirtualBox Host Interface 1(or whatever name you’d given earlier), with Media State as Media disconnected.
This is fine, don’t worry. Next start the VM. Once the VM is ready, the Host Interface would be assigned an IP-address, this IP address is required for the VM to communicate with the Physical Machine. Make a note of the IP address, by following the same steps as above.
Now in the VM, mount a network drive with the IP adress noted as above. KDE & GNOME 2.22 users don’t have to mount the network drives, just open the File Manager(Konqueror in KDE 3series, Dolphin in KDE4, and Nautilus for GNOME users) and just type smb:// in the address bar.
Now just copy the whatever files you want from the VM to this folder(or from the physical machine to the VM). The file will be available in the physical machine.
There you go! Your files are easily accessible! Simple as that!