Using Windows XP in VirtualBox on Linux
As a person who uses Linux regularly, often I am asked about my opinions about other operating systems, especially those coming from large companies located in Redmond, Washington. Here's the deal. Operating systems are tools. We use them to do jobs. It is always a good idea to think critically about what tools you are using, and verify if other tools can do the same job in a more efficient or flexible manner.
Having said that, using Linux as a Host OS for VirtualBox, I will show you how to create a Windows virtual machine that can interact with shared network folders in a Windows network as if it were an actual machine instead of a virtual one. In this article, I will also show you how to mount local Linux directories as network drives within your Windows Guest OS.
I'll start by assuming that you already have VirtualBox installed (available here).
This tip assumes that you have legitimate installation media for Windows XP. Start by selecting "New" to create a new virtual machine.
Indicate the Virtual Appliance name, and select the type of Operating System. In this case, it will be Windows XP.
Select the amount of RAM that you want the virtual machine to use. I chose 1024 megabytes, as my system machine has 4GB of RAM.
Choose an exisiting virtual hard disk, or create a new one. I will assume that you wish to create a new virtual disk image (VDI).
Choose either a dynamically expanding or fixed size virtual disk. I'm a fan of dynamically expanding storage, as it takes up less room on your hard drive if the virtual hard disk is not full.
Choose the size of your hard disk. In VirtualBox, expanding the size of virtual disk is a relatively time-consuming endeavor, so give yourself some breathing room here.
Verify your hard disk choices and choose "Finish".
Verify the rest of your choices, and click "Finish" again,
Your Guest OS should now be in your VirtualBox menu. Before installing, we need to change some of settings, so highlight your virtual machine and click on "Settings".
If you wish to install XP from an actual disk, the you need to enable the drive through the host OS. Under "Storage", select the CD icon under IDE controller, and select "Host Drive" under "CD/DVD Device".
Insert the OS disk, start the virtual machine, and install Windows XP as if it were a normal machine.
After installing the OS, I would recommend installing Guest Additions to your Windows XP machine. There is an entire chapter of the VirtualBox Manual dedicated to Guest Additions, and I encourage you to read it, but here is the manual's description of what Guest Additions can do.
The Guest Additions offer the following features:
- Mouse pointer integration - To overcome the limitations for mouse support that were described in the section called "Capturing and releasing keyboard and mouse", this provides you with seamless mouse support. You will only have one mouse pointer and pressing the Host key is no longer required to "free" the mouse from being captured by the guest OS. To make this work, a special mouse driver is installed in the guest that communicates with the "real" mouse driver on your host and moves the guest mouse pointer accordingly.
Better video support - While the virtual graphics card which VirtualBox emulates for any guest operating system provides all the basic features, the custom video drivers that are installed with the Guest Additions provide you with extra high and non-standard video modes as well as accelerated video performance.
In addition, with Windows and recent Linux, Solaris and OpenSolaris guests, if the Guest Additions are installed, you can resize the virtual machine's window, and the video resolution in the guest will be automatically adjusted (as if you had manually entered an arbitrary resolution in the guest's display settings).
For Linux and Solaris guests, the Xorg server version 1.3 or later is required for automatic resizing (the feature has been disabled on Fedora 9 guests due to a bug in the X server they supply). The server version can be checked with Xorg -version.
Finally, if the Guest Additions are installed, 3D graphics for guest applications can be accelerated; see the section called "Hardware 3D acceleration (OpenGL and Direct3D 8/9)".
- Time synchronization - With the Guest Additions installed, VirtualBox can ensure that the guest's system time is better synchronized. This fixes the problem that an operating system normally expects to have 100% of a computer's time for itself without interference, which is no longer the case when your VM runs together with your host operating system and possibly other applications on your host. As a result, your guest operating system's timing will soon be off significantly. The Guest Additions will re-synchronize the time regularly. See the section called "Tuning the guest time synchronization parameters" for how to configure the parameters of the time synchronization mechanism.
- Shared folders - These provide an easy way to exchange files between the host and the guest. Much like ordinary Windows network shares, you can tell VirtualBox to treat a certain host directory as a shared folder, and VirtualBox will make it available to the guest operating system as a network share. For details, please refer to the section called "Folder sharing".
- Seamless windows - With this feature, the individual windows that are displayed on the desktop of the virtual machine can be mapped on the host's desktop, as if the underlying application was actually running on the host. See the section called "Seamless windows" for details.
- Shared clipboard - With the Guest Additions installed, the clipboard of the guest operating system can optionally be shared with your host operating system; see the section called "General settings".
- Automated Windows logons - (Credentials passing; Windows guests only) For details, please see the section called "Automated Windows guest logons".
OK, Now you should be convinced that installing Guest Additions is a good idea. Luckily, installing Guest Additions is easy! While your virtual machine is running, click the "Devices" menu and select "Install Guest Additions."
A setup wizard should begin shortly. Choose to continue.
Twice during the install, Windows will freak out and warn you that the drivers that are being installed haven't passed "Windows Logo testing". It's OK. Choose to "Continue Anyway".
Windows will ask you to reboot your (virtual) machine. Do it.
Congratulations. VirtualBox Guest Additions have now been installed.
Now that Guest Additions have been installed, let's take advantage of the feature that allows you to mount a Linux directory as a network share. Select your Virtual Machine from the menu, and select "Settings"
Under "Shared Folders", click the
Add Shared Folder icon on the right side of the window.
Under "Folder Path", select "Other".
Browse to the directory that you wish to share, and select "Open".
Verify your selection, choose the name of the shared folder, choose whether or not to have "read-only" access, and click "OK".
Start your virtual machine, click the start menu, right click "My Computer" and select "Map Network Drive".
Choose the drive letter of your network drive, and click "Browse" to find your directory.
Your share should be listed under:
Entire Network ----VirtualBox Shared Folders --------\\Vboxsvr ------------\\VBOXSVR\YOUR_SHARE_NAME_HERE
Select "OK", then select "Finish"
Marvel at your new "Network Drive" shared folder. This is one way to get around resizing your virtual machine if you are running out of virtual hard drive space.
If you wish that your Guest OS can access and share files on your Windows file sharing network, you will need to change the way that your virtual machine interacts with the Internet. Under "Settings"/"Network", change "NAT" to "Bridged Adapter".
Please understand, the choice to use Bridged Networking does have security repercussions. The VirtualBox Manual explains the benefits and limitations of the different networking modes that are available, but this statement from the VirtualBox manual sums it up rather well:
In bridged networking mode, all traffic goes through a physical interface of the host system. It is therefore possible to attach a packet sniffer (such as Wireshark) to the host interface and log all traffic that goes over it. If, for any reason, you prefer two or more VMs on the same machine to communicate privately, hiding their data from both the host system and the user, bridged networking therefore is not an option.
I will assume that you are willing to accept the security risks that go with using this networking mode, as well as the additional risks of allowing file sharing within Windows.
Choose the directory that you wish to share, right-click it, and select "Sharing and Security"
You may have to complete the Network setup wizard to enable File and Printer Sharing.
Check "Share this folder on the network", the click "OK". It may ask you to reboot your (virtual) machine again.
When you restart the computer, you will notice that your directory is listed as a shared directory, and it will be accessible as a Samba share on your Linux host machine, as well as all other machines on your network. Enjoy!
Linux rocks! Personal blog: zootlinux.blogspot.com
Webinar: 8 Signs You’re Beyond Cron
11am CDT, April 29th
Join Linux Journal and Pat Cameron, Director of Automation Technology at HelpSystems, as they discuss the eight primary advantages of moving beyond cron job scheduling. In this webinar, you’ll learn about integrating cron with an enterprise scheduler.Join us!
- New Products
- Users, Permissions and Multitenant Sites
- Not So Dynamic Updates
- March 2015 Issue of Linux Journal: High-Performance Computing
- Flexible Access Control with Squid Proxy
- Security in Three Ds: Detect, Decide and Deny
- Tighten Up SSH
- DevOps: Everything You Need to Know
- Solving ODEs on Linux
- Non-Linux FOSS: MenuMeters