PCs

How do I add a second drive to a Windows XP virtual machine running in VirtualBox?

Jack Wallen shows you how to expand the capabilities of a virtual machine by adding virtual drives using the VirtualBox application.

Virtualization is king and rightly so. The benefits to using this technology are many and mighty: cost effectiveness, reliability, recoverability, the list of pros goes on and on. And anyone digging deep into the world of virtualization knows that managing those virtual machines can sometimes be a daunting task.

Virtual machines are set up to expand to a set size, and once you reach that size you are out of luck -- unless you know how to add virtual drives to that machine. In VirtualBox this is quite possible, albeit a bit circuitous. The end results, however, will give you plenty of room to expand the capabilities of a virtual machine.

This blog post is also available as a TechRepublic Photo Gallery and TechRepublic download. Note: I will be illustrating this task using VirtualBox on a Linux (Ubuntu 10.10) host and a Windows XP guest. The task with other combinations will vary, but the fundamental idea remains the same.

Step 1: Shut down the virtual machine

Make sure you don't suspend the machine, because you won't be able to access the settings.

Step 2: Create a new virtual drive

A couple of steps are required to make this work. The first is to actually walk through the process of creating a new virtual machine. During this process you will define a new drive for that machine. Make sure you make the new drive the size you want for the additional drive. By default you will create a 10GB drive -- if that will serve as enough additional space for your second virtual drive, leave it as is. If you need more space, adjust it during the creation of the virtual machine.

Once the new virtual machine is created, you can then go back and delete the new virtual machine. This process will leave behind the newly created drive that you can then use for your original virtual machine.

The next phase of this step is that you need to open the settings of your virtual machine (the one you are adding the drive to) and then go to the Storage section (Figure A). Here you are going to add a new drive to this virtual machine. This new drive will be uninitialized and will have to be initialized later (from within the running Windows virtual machine -- more on that in a bit).

Figure A

As you can see, I have already added a new drive for this virtual machine and labeled it D.
To create a new drive, you need to select the main controller for the virtual machine and then click the Add Hard Disk button. When you do, a new disk will appear under the controller. If you select that new disk, you can then change the hard disk from the drop-down menu (Figure B) to the hard disk you just created earlier.

Figure B

When you click the Hard Drive drop-down menu, all the available drives will show up.

Once you have the hard drive chosen, you will need to select it as the Primary Slave (from the Slot dropdown) and then click OK.

Step 3: Initialize the hard drive

Now you need to go ahead and boot your virtual machine. Once that machine is booted and you have logged in, click Start | Run and then enter compmgmt.msc. When this tool starts, click on the Disk Management section under Storage (you may have to expand the tree to view) and then click the disk you want to initialize. When you click the disk to initialize it, the Initialize and Convert Disk Wizard will appear (Figure C). Check the disk to initialize and click Next.

Figure C

You might have more than one drive listed. Make certain you select the correct drive.
The next step is to select the disk you want to convert. Select that disk and click Next. Finally the wizard will give you a report on what it is about to do (Figure D).

Figure D

If all looks well, click Finish and your drive will be initialized.

Step 4: Create the partition

You now have an initialized, unformatted drive. This drive has to be partitioned in order for it to be of use. You should right-click the unallocated space (Figure E) and then select New Partition. This will walk you through the Partition Wizard.

Figure E

The unallocated space will be indicated by the diagonal stripes.
In the next screen (Figure F), you need to add the disk to the selected area.

Figure F

By default, your drive should already be selected. If not, select it and click the Add button.
When your drive has been selected, click the Next button to move on to the next phase of the partitioning. In this phase you will assign the drive a letter and then click Next. On the next window (Figure G), you select if you want to format the drive and, if so, what format you want the drive to be.

Figure G

You can give the drive a label if need be. You can also enable compression and do a quick format instead of a standard format.

After you have this configured, click Next and the formatting will complete. You are almost done with this task.

Step 5: Reboot

In order for this drive to be available to Windows, you have to reboot the virtual machine. Once you have done so, the drive will be available to the system.

Final thoughts

You now have a new drive available to your virtual machine. Although this process will add a new drive, it will not expand the size of the primary drive on the virtual machine. For that process you would have to use Clonezilla (or another disk-cloning tool). But for the process of just adding a new virtual drive, the above method will allow you to expand your virtual machine all you want.

Stay on top of the latest Microsoft Windows tips and tricks with TechRepublic's Windows Desktop newsletter, delivered every Monday and Thursday. Automatically sign up today!

About

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website getjackd.net.

9 comments
julitomartinez
julitomartinez

Jack, I happen to run the same setup as you, ubuntu 10.10 host, xp guest. Here is a question: what gives you better performance! Running the virtual controller as ide, scsi, sata, etc? There are several options in virtual box, and I did notice performance increase in running scsi (knowing I had to do some stuff with the drivers) but since vbox gives other options, I am curious. My laptop has sata II, and the disk is an ssd. I found a great website that shows you how to convert the actual virtual disk, but I am curious if you've run specs on the other controllers. Any thoughts?

Jeff7181
Jeff7181

Wow... what a convoluted process. Is this as good as it gets for free desktop virtualization on Linux? All this would take is about 5 mouse clicks in Virtual PC to accomplish the same thing.

Mark W. Kaelin
Mark W. Kaelin

Would Jack's technique also work with VMWare and Virutal PC and other virtualization systems? Do you have a better way?

Neon Samurai
Neon Samurai

Given that the actual hardware is SATA, I normally choose SATA drives except for the rare cases that prefer an virtualized IDE bus. (I think that's mostly Windows)

bdskp
bdskp

It's not convoluted. It's pretty straight forward. As usual actually performing the operations in the application itself is much more fluid than reading a how to guide on the net. Also..virtualbox is an oustanding application. I highly recommend you try it. If for no other reason than for the seamless mode feature. It's rare that I come across a feature that really makes life easier..this is one of them. YMMV. http://blogs.techrepublic.com.com/opensource/?p=757

Neon Samurai
Neon Samurai

My "free desktop virtualization" properly manages non-Microsoft OS. How's your VirtualPC do with that sort of thing? VirtualBox also runs on multiple host OS including Windows. Are you suggesting it's only "convoluted" when running on Linux based host systems? Compared to other virtualization solutions including Microsoft's own alternative. VirtualPC is more like "VirtualWindows" as it's only really meant to virtualize that particular OS.

ken.butler
ken.butler

If you look under File in Oracle VM VirtualBox you will find "Virtual Media Manager" and from there you can directly create new hard drives (.vdi) which can then be added to your existing VM. There is no need to go through the process of creating a new VM just to get a drive created.

hariks0
hariks0

Without adding a machine, one can directly create a VHD and link it later to any/multiple OS in VB, Actually it is done more than usual as a shared resource.

Neon Samurai
Neon Samurai

- Create HD blob file through VM software - shutdown relevant VM - link HD blob file to relevant VM - boot relevant VM and format the new HD with the VM's installed OS This seems to be the obvious standard process for any virtualization software. I'm not really sure how it justifies being called a "technique" rather than a "generic process". Don't get me wrong; for those not familiar with VM software, it's good to have Jack's howto available.

Editor's Picks