You are here
Home > How To > Moving VirtualBox VM’s To An External Drive

Moving VirtualBox VM’s To An External Drive

Moving Virtualbox VM

Moving Virtual Box VM’s – The other day I created a VM in VirtualBox, and it created the VM in the default directory on my local drive. My local drive is not full, but having a virtual machine hogging an initial 23 Gb of disk space, didn’t excite me too much. This is especially true if it is set to dynamically grow in size. As I found out, moving VirtualBox VM’s is really quick and easy. Here’s how.

Moving VirtualBox VM’s

The current version of my Virtualbox installation is 4.2.14r86644. The first step is to ensure that the virtual machine is powered off.

Moving VirtualBox VM

Navigate to the settings for the specific VM you want to relocate. Click on the Storage item and select your vdi file (your hard disk). Click on ‘Remove Attachment’.

Remove attachments

When you have done that, click on OK and then open up the Virtual Media Manager from the VirtualBox file menu.

Moving VirtualBox VM

Select your vdi file again from the Hard drives tab and click on the Remove button.

Moving VirtualBox VM

VirtualBox will now prompt you to confirm your selection to remove the hard disk (unless you selected not to show this message at an earlier time). Click on the ‘Remove’ button.

Moving VirtualBox VM

Because we want to relocate the VM, you need to keep the hard disk. If you delete it here… well, just don’t.

Keep hard disk

Once you have done that, go the the disk location for your VM (mine was at “C:Users[username]VirtualBox”, but your path will be different) and copy it to your external drive. Go make a cup of coffee.

Copy to external drive

When the disk has been copied, you need to select the settings for your VM again and click on the Storage menu. This time, click on the ‘Add Hard Disk’ button.

Add hard disk

VirtualBox then asks you if you want to create a new disk or add an existing one. We want to use the disk we copied on to our external drive. Click on ‘Choose existing disk’ and browse to the location on your external drive.

Choose existing disk

VirtualBox will then add the disk on your external drive to your storage tree. Click OK and start your VM.

Disk added

Lastly, don’t forget to remove the old VM from the location it originally was created in. Having my VM on an external Hard Drive allows me to free up space on my development machine. Another good idea is to Export Appliance once you have your VM set up just right. That way you can import it if you need to create a new VM or distribute it to others in your organization.

 Al Forno

Dirk Strauss
Dirk is a Software Developer and Microsoft MVP from South Africa. He loves all things Technology and is slightly addicted to Twitter and Jimi Hendrix. Apart from writing code, he also enjoys writing human readable articles. "I love sharing knowledge and connecting with people from around the world. It's the diversity that makes life so beautiful." Dirk feels very strongly that pizza is simply not complete without Tabasco, that you can never have too much garlic, and that cooking the perfect steak is an art he has yet to master.

Similar Articles

  • Noel

    Thank you Dirk,
    I’m trying to find out how to move the VM storage to my ext drive, and this is help me a lot.

  • Wanderson Diego

    Thank u Dirk! It was really helpful for me!

  • Rohit Chauhan

    Thanks a lot ….:) But I have a doubt. Is the working (execution) speed of the guest OS affect, after moving it to external hard drive ?

    • Dirk Strauss

      Hi Rohit. I used my VM’s purely for development and testing. I found that the isolated environment worked really well and I experienced no impact on speed. I guess this would also depend on the speed of your external HDD. I know that there is a school of thought that suggests keeping all your source code on external HDD’s (along with other files) and having only the OS and app running off of a SSD. While this isn’t a VM solution, it does illustrate the usefulness of separation using external HDD’s. I used multiple VM’s for development. Snapshots also helped me manage releases and allowed me to ‘branch’ development as needed. While I know that every persons reason for using a VM is different, doing development on a VM located on an external HDD worked really well for me.

  • Krishna

    Thank you.

  • Shafiq Sukiman

    Thank you Dirk! A really helpful step by step tutorial for a tech noob like me 🙂

    • You’re welcome Shafiq. Everyone is a noob at something.

  • Terry

    Hi Dirk,

    Currently my PC has 2 partitions, C: and D: (on the same disk). VirtualBox is installed on the C: drive, but the virtual disks are on the D: drive…(C for Operating System).

    To cut a long story short, my PC needs a complete rebuild, which will re-create the C: and D: drive partitions similar to before (with more space on C: this time). However, I want to permanently have the VMs, virtual disks, everything, on an external disk drive E: say. I probably will install the VirtualBox software on the D: this time rather than C to conserve space. But I want the hard drives, etc. on the E: drive.

    So what is the best approach? My thinking is follow the steps you mentioned above, which is transferring the disk files to the external drive, then do an Export Appliance. After this, once the PC has been re-built, I re-install the VirtualBox software as before (same version, etc.), then do I do an Import Appliance? Would that work?

    Any advice would be appreciated.

    Thanks,

    Terry

    • Hi Terry. Thank you for your comment. What I would do is to transfer my VM files to the external drive. Then I would see if I can start those VM’s from VirtualBox (and perhaps from a different machine) to ensure that everything is still working as it should.

      Only once everything is working, would I do a format/reload. That way you know that if anything goes wrong, your VM’s still work. I would like to stay in touch with you and get feedback regarding this process. If you don’t mind, please send me a message via this blog’s contact form or go to http://www.dirkstrauss.com/contact-me/ and include your mail.

      I will send you a mail then and get that feedback from you. Good luck!

      • Terry

        Hi Dirk,

        Many thanks for the very prompt reply! I will try that out and let you know.

        Out of interest, what is the Export/Import Appliance used for?

        Kind Regards,

        Terry

        • Hi Terry

          From what I understand, the Export Appliance will zip (for lack of a better word) or bundle one or more VM’s into a single file. The idea is then to allow users to easily share the file containing that VM or VM’s with somebody else. The other person who is using a different machine can then easily use Import Appliance to create and get those VM’s running on their side.

          That’s the way I understand it. I hope this helps 🙂

          • Terry

            Hi Dirk,

            Thanks again! That makes more sense.

            Regards,

            Terry

  • Łukasz Siwiński

    Works fine for me with Virtual Box 5.0.10 on Windows 7 Professional. Thanks a lot!

  • Craig

    Thank you for this clear guide! It gave me the confidence to move my VM.

    But in my supreme laziness, I wondered what would happen if I changed my Default Machine Folder (File -> Preferences -> General) to the external drive, then cloned the VM. It seems to have worked. The new machine is now on my external, and I can delete the original because I made a full clone.

    My VM in question was very simple, so this might not work for everyone. This was on version 5.0.18.

  • Don

    Thank you so much for this excellent, easy to follow instruction guide. My IT dept moved my VM’s to a new hard drive for me, but they failed to change settings in virtual box to new location. This was very easy to follow!

  • Leif

    Great guide, even two years later. Only minor differences from the current version. Thank you for taking the time to be precise and thorough.

  • Mystery Man

    proudly south african! Thanks for sharing your knowledge.

  • Banderaz

    One thing you should add to this tutorial is to first make a snapshot of your virtual machine before doing this! I had an issue with the permission and the network when it booted/started it up. Luckily, I had a snapshot. Then it worked.

  • You rock, worked perfect!

  • Antonio Di Bacco

    I had some “Virtual Box Snapshots” and I had the Remove button in Virtual Media Manager greyed out. I had to remove snapshots to proceed.

  • Panzer

    Dirk you’re Da Best ……..

  • Pingback: Moving and extending VirtualBox virtual machines - Ptarmigan Labs()

  • Mike

    Just a note to others that may run into the same problem. For me, the .vdi file added to the storage tree just fine, but when I hit the OK button, I got the following error:

    Failed to attach the hard disk (G:KubuntuKubuntu.vdi) to the slot SATA Port 0 of the machine Kubuntu.

    Cannot attach medium ‘G:KubuntuKubuntu.vdi’ {bcfbe458-f550-40c6-916e-47b038df402e}: medium is already associated with the current state of machine uuid {634c3e24-12f7-461d-a922-211180553866}!.

    Result Code: VBOX_E_OBJECT_IN_USE (0x80BB000C)
    Component: MediumWrap
    Interface: IMedium {4afe423b-43e0-e9d0-82e8-ceb307940dda}
    Callee: IMachine {b2547866-a0a1-4391-8b86-6952d82efaa0}

    I tried to find this mysterious UUID (634c3e24-12f7-461d-a922-211180553866), by first looking under File->Virtual Media Manager. I didn’t find it under there, so I listed the virtual machines in a Windows command window, using command: vboxmanage list hdds.

    It was nowhere to be found, so I decided to reboot/rerun the VirtualBox program to see if this would clear it. It did!

    What I think happened was that I added the Kubuntu virtual machine, didn’t like the settings, deleted it, and set up a new one with the same name. The first one’s UUID must have been stuck in a cache somewhere until I reran the program.

    Hope this helps some future, confused soul with the same problem.

  • RextheRunt

    Thanks so much – excellent instructions!

Top