Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a virtualbox VM that is broken. It won't boot normally. I don't want to bother trying to fix it but I do want to get some files off it that I need.

If I hold down the shift key I can get to a prompt allowing me to boot into recovery mode and from there I can select the option netroot and I'm in. I can get to the files on that machine which I need and the internet works (I can run wget --spider http://example.com succesfully.) So it seems like I should have everything I need to get the files off. But how? I thought about trying to setup an FTP server but I'm wondering if there isn't an easier way.

I am running Ubuntu 12.04 on the host and 10.04LT on the client (VM).

share|improve this question

2 Answers 2

up vote 2 down vote accepted

An easy way would be to enable SSH on your host, then mount a folder via SSH on your VM.

openssh-serverInstall openssh-server

On the host:

sudo apt-get install openssh-server
mkdir ~/vm_backup

On the VM:

sshfsInstall sshfs

apt-get install sshfs
mkdir /mnt/host
sshfs [username]@[host]:/home/[username]/vm_backup /mnt/host

NOTE:

  • Replace [username] with the username on the host.
  • Replace [host] with either the IP address or hostname of the host

Then you can just copy everything you need to /mnt/host

When you are done, if you do not want SSH anymore, simply uninstall it.

sudo apt-get remove openssh-server
share|improve this answer
    
awesome. thanks. just what I needed! –  snowguy Jul 24 '12 at 17:18
1  
No problem. I'm glad I could be of help. :-) –  reverendj1 Jul 24 '12 at 17:18

I do this regularly and you don't even have to start the virtual machine itself. The idea is to mount the disk image on your host machine.

To do this, you'll need virtualbox-fuseInstall virtualbox-fuse on the host:

$ sudo apt-get install virtualbox-fuse

You can then mount the image using vdfuse. Per example, mounting a VDI image (VMDK and al are also supported), as root:

$ mkdir /mnt/vdi
$ vdfuse -f /path/to/disk/image.vdi /mnt/vdi

In /mnt/vdi, you'll have a disk image for each partition and one for the entire disk:

$ ls /mnt/vdi
EntireDisk  Partition1  Partition2

Mount the partition you want:

$ mkdir /mnt/guest
$ mount /mnt/vdi/Partition2 /mnt/guest

And that's it. You can now copy your files from /mnt/guest to your host machine without any network overhead whatsoever.

It's also useful for a ton of other things other than backing up broken VMs. ;-)

share|improve this answer
    
Wow. This is great. I already got the files off the other way, but I agree this is really good to know. –  snowguy Jul 24 '12 at 20:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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