Copying a VirtualBox virtual machine onto another host computer

I came across VirtualBox awhile back and it’s going to be the perfect program for us here since a good chunk of us use Ubuntu but at times need to test things in Windows or use specific programs that are only accessible in Windows.  It takes longer just to restart the computer into Windows than it does to test or use the program we need most of the time, so this will save us some time and be way more convenient.

Before I pushed this out on the next image I needed to find a way to copy the virtual machine I created so that my co-workers could use the same base image file and just configure it the way they want from there.  I found this blog that is my source for this information but it’s slightly different since he is using the Windows version of VirtualBox.

To copy the image to another computer:

  1. Close VirtualBox if it’s running.
  2. Go to your home folder and enable show hidden files through the View menu.
  3. Find the .VirtualBox folder, go to the HardDisks folder and copy the .vdi file you want to use.  In my case  I burned the file to a DVD because we have so many people who will be needing to save this in their home directory.
  4. Now go to the other host computer you want to use that .vdi file on and open VirtualBox if you’ve never opened it on the new host machine before.  This will create the .VirtualBox folder.  Then paste it in the same place (user’s home directory -> show hidden files -> .VirtualBox -> HardDisks).  You might need to create the HardDisks folder yourself.
  5. Edit the permissions of the file in order for it to work.  All I did was right-click on it after moving the file over and give read & write permissions to the owner, which should have your username there.  You can change the permissions to the group and others sections if needed later, but that wasn’t necessary for me.

Once you’ve copied the disk image you need to create a new machine and register that hard disk with VirtualBox on the target host machine:

  1. From the VirtualBox window click the New button.  This will open the New Virtual Machine Wizard.
  2. VM Name and OS Type – Give it a name and pick the type & version of the virtual machine OS.
  3. Memory – Just leave it as the default.  You can change it later if you notice any problems.
  4. Virtual Hard Disk – This is where you select the hard disk you copied in to the home directory earlier.  So click on existing and when the Virtual Media Manager window comes up choose to Add.  It should take you to the correct folder so just select the image file and click open, then select.
  5. You’re done, it’ll take you back to the main window with the new virtual machine you just created based off the existing image file.

If you notice things running slowly you can shut down the machine, go to settings, and change the base memory allocation.  It’ll be screaming at you in red or orange text if you’ve allocated too much.

, ,

  1. #1 by Bill on February 14, 2011 - 10:50 AM

    I had a situation where I have 6 Virtual Machines (Windows XP clients) running on Ubuntu and they were running perfectly. Something strange happened to my Ubuntu istallation so I copied the entire contents of the .VirtualBox directory (Hard Drives and machine Files). When I rebuilt the Unbuntu machine and reinstalled VirtualBox I copied back all of the files and while the VM’s open, they now randomly Blue Screen on me which is proving to be a huge problem. No equipment was changed on the Ubuntu machine before it was rebuilt. Any idea why this might be happening?

    Thanks
    Bill

  2. #2 by Mike another on September 27, 2010 - 9:13 AM

    Oops…
    and if you want access to your USB devices, of course you will want to add your name to the vboxusers group (check the box).

    Then you will have to reboot Ubuntu to have this recognized.

  3. #3 by Mike another on September 27, 2010 - 7:43 AM

    This works 100%. It is so gratifying to find instructions for well-written. And…accurate as well!!! BTW, I’m using version 3.2.8r64453.

    Because I transferred the clone from my desktop to my laptop, I did get an “activation request” from M$oft. This means likely I am limited to how many times I can clone it. Too bad, as I have firefox, my garmin software just as I like it, and it really saves time to just clone.

    One tip, one may have to invoke “Machine/Adjust window size” to have the VM fit the new monitor.

  4. #4 by U Avalos on April 27, 2010 - 9:59 AM

    This doesn’t work at all. The Windows VM compains that it underwent “significant hardware” changes. That’s when I copy the VDI file to another. Even if I match all the settings (memory, CPU, audio, etc), I still get the same error.

  5. #6 by Craig on October 17, 2009 - 3:22 AM

    That’s all fine if you’re just adding a new VM to another machine. My problem is that I use VM’s on my Ubuntu desktop then when I need to work away from the office I want to download them to my laptop, effectively updating what’s already there. That seems to be more complex. In fact I haven’t done it yet. Any clues?

    • #7 by jen3ral on October 17, 2009 - 3:07 PM

      You still do the same process I posted above to create the virtual machine on your laptop, you just tell it to use the already made .vdi file after you copy it from your desktop and paste it into the directory. Then once you use it on your laptop, to keep it consistent between computers, you need to paste it back over to your desktop. It just goes by file name, so I’m pretty sure copying/pasting back and forth won’t matter.

      • #8 by Craig on October 18, 2009 - 3:06 AM

        It doesn’t work because it doesn’t go on file name, it goes on a unique identifier that VB gives each virtual hard disk. I think I’ll have to go to the trouble of exporting each VM on the desktop to a .ovf file then, on the laptop, delete everything everytime and import the .ovf file. A bit of a bind to say the least!

        Craig

  6. #11 by Mike on August 2, 2009 - 8:46 PM

    I think there is a process to “clone” the virtual hard drive. IIRC you really should do this. It avoids them having the unique identifier but all else is identical.

    • #12 by jen3ral on August 2, 2009 - 11:47 PM

      Yes, that’s the best option. The version of VirtualBox I was using at this time had that command disabled for some reason. I’m not sure if they’ve fixed it in the newest version or not.

  1. Copy a virtual machine from one computer to another « Snott

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: