I want to transfer Ubuntu from a VirtualBox Guest 'appliance' to a real (metal and chips) computer?

Can this be done, and what steps are involved?


I'd try it with dd (don't forget to replace the device names like sda with your device name):

  1. Replace all uuids in your /etc/fstab with things like /dev/sda1 (sda = destination hd number!)
  2. update-grub2 && grub-install /dev/sda
  3. Save your virtual hdd inside VBox into a File: dd if=/dev/sda /home/user/sda.img
  4. Copy the Image to a disk (external hdd, network share, dvd, ...)
  5. Restore the Image to the destination drive: dd if=/media/drive/sda.img of=/dev/sda

The biggest problem might be the bootloader (but there are tutorials for this even in this forum). I once reinstalled a bootloader by doing a fresh install of Ubuntu (preferably the same as the one you dd'ed) and then dd the old partition over the fresh install (in this case, you would only dd /dev/sda1, not /dev/sda, which also includes the bootloader and all partitions)

| improve this answer | |
  • I can handle dd. I've used it before and know the if isn't the start of a conditional statement :) ... For some reason uuids and grub baffle me.. They are probably quite simple, but then again I might be too.. I'll probably use the MBR from a fresh (dummy) install.. The biggest hurdle for me is to actually dd the partitons from the VM.. How can I dd from a VM partition to the Host? – Peter.O Oct 20 '10 at 20:57
  • ... a bit more (I tried to edit this into my previous comment, but the edit was disallowed!?.. another minor mystery): . . . VirtualBox's shared folders seem to rely on the Addons which aren't present in a Live-CD run, because it requires a reboot. – Peter.O Oct 20 '10 at 21:07
  • you could dd to a network folder, I did this last week and it was like 30MB/s. If you set a shared folder in your live-cd environment/windows/linux and activate bridged network for the VM this should work. – sBlatt Oct 20 '10 at 21:16
  • btw: it's possible to copy an entire Linux-Partition with cp (+ some arguments to keep the permissoins! Very important! I think it was -p or --preserve=all). I did this once to copy back an image after resizing a partition (so I mounted the dd-Image file and did cp) – sBlatt Oct 20 '10 at 21:20
  • Sorry to be so dumb about this, but I must be missing some incredibly simple point... Everything I read seems to imply that NAT allows the Guest to access the Host by default (a connection in the other direction needs Bridging).. Okay I've had my three guesses (more like thirty!). I've successfully accessed VBox's Shared Folders only when Guest Addons are installed. I can't install these Addons in a LiveCD run, so I'm stuck again. How do I access the NAT connected Host's file sysem from the Guest (no Addons)? I suppose I need to do something on the host, but I don't knwow what it is? – Peter.O Oct 20 '10 at 23:31

Haven't tried this myself, but description seems to be realistic enough to try.

| improve this answer | |
  • The article you mention is on a similar path to where I want to go. If I ignore his Fedora LVM issues, it almost resolves one of my problems: How to get the VM partion into the Host environmnet. He mentions a VirualBox tool VBoxManage which emables the mounting of a raw VM disk image on the Host. However there is a problem with this article insomuch as it relates to a Windows Host. The command-name is okay, but none of the args are recognized... but I assume the same is available for Linux... Does someone know the syntax? – Peter.O Oct 20 '10 at 22:08
  • Try running "VBoxManage internalcommands" - it prints out some usage information. Might appear to be sufficient. – Serge Broslavsky Oct 21 '10 at 4:35

1> do a tar of your virtualBox OS

2> start with a live distro

3> untar your virtualBox OS in the target partition/s (/dev/sda1 for example)

4> make the partition bootable (fdisk can help you): # fdisk /dev/sda Command (m for help): a (a = toggle a bootable flag) Partition number (1-4): 1 (1 = /dev/sda1) Command (m for help): q (q = exit)

5> install grub into mbr (https://wiki.ubuntu.com/Grub2) # mount /dev/sda1 /mnt/ # mount --bind /dev /mnt/dev # mount --bind /proc /mnt/proc # mount --bind /sys /mnt/sys # cd /mnt && chroot . #(chroot) update-grub #(chroot) grub-install /dev/sda (NOT /dev/sda1!) #(chroot) grub-install --recheck /dev/sdX

6> Enjoy...

| improve this answer | |
  • 1
    To tar my VirtualBox OS sounds so easy... but not for me... For example; Where do I tar it to? I assume that the appropriate way to tar a file system is to not have it in use... so I booted the VM via a LiveCD... This gave me access to the VM's drive via the LiveCD's /media.... but how do I get the data out of the VM.. VirtualBox's Shared Folders requires the GuestAddons, which requires a reboot, which restart the Live CD to its no-Addons state... Or have I missed something about VirtualBox's Shared Folders/ – Peter.O Oct 20 '10 at 21:23
  • You can tar (rsync also) the system directly even if it's running (this is Linux...): – daniele Oct 21 '10 at 8:19
  • You can tar the system directly even if it's running. This is Linux ;-). First install this packages: sshfs (fuse.sourceforge.net/sshfs.htm) and mount a real directory inside virtualbox. For example you can use,inside virtualbox as I said, a pendrive (mounted, let me say, in /media/pendrive) in this way: # sshfs root@ /mnt After tar directly from your RUNNING virtualbox to the pendrive (Linux can): # cd / # tar -cvpzf /mnt/backup.tgz --exclude=/proc/ --exclude=/lost+found/ --exclude=/mnt/ --exclude=/sys/ / – daniele Oct 21 '10 at 8:48

What exactly from the install do you want to migrate? If all you care about are user data and preferences, you could probably just copy everything from your home directory on the VM to a file system outside the VM (a keydrive, for example), copy those files over to a fresh Ubuntu install and then reinstall any programs you had installed on the VM. Depends on how much you've customized the VM install, versus how much trouble the other solutions here would be.

| improve this answer | |
  • I am using Ubuntu (first time Linux user) on real hardware. I've been learning a lot, but my system has gathered a lot of clutter. I've tweaked one setting and forgotten where I set it, etc. My idea is to use the (minimal) experience I now have, and build a parallel VM system, without the mistakes, and then just shuffle it across to the primary hardware. I can take my time about it and still experiment on the current one. Its also a good "learning" project... but I'm feeling like I've bitten off a bit more than I can chew :) ... getting there slowly... – Peter.O Oct 20 '10 at 20:23

I like to use rsync for backing up my system. This is good for a home directroy or ect directory but might not be what you're looking for in terms of a complete system migration. To use rsync, you'll need to install ubuntu on both systems. Update both of them so that the packages are the same and are at the same level (this isn't mandatory but does make things easier). Then, to copy your home dir from server1 to server2 you can run the following on server1:

$rsync -avz /home/username/ username@server2:/home/username/

The thing that I like about this is that rsync will calculate the differences between directories and transfer the changes rather than everything. This way you can keep your backup current by running on server2 (to backup on server1):

$rsync -avz /home/username/ username@server1:/home/username/


| improve this answer | |
  • Thanks, I've been using rsync to backup my non-OS partitions (ie.. data, like music, etc). I too like the way rsync works; very efficient. My main "problem" is that I don't know if a simple file copy from the VM to equivalent partitions will work. Eg. How will Ubuntu handle the different HARDWARE. Does it automatically detect it and adjust on bootup? Windows certainly wouldn't! and I'm not yet sure how to handle mount points: I don't want to rsync my TeraByte drive across to the OS partition; and GRUB spins me out. These are the little fun things I don't quite know enough about yet.. – Peter.O Oct 20 '10 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.