My Ubuntu 12.04.1 running on virtualbox ran out of space while I was installing software on it and now it is not rebooting. I've got files I need to recover from it. I have the ubuntu64.vdi
file on my Windows 7 (host) laptop and I was wondering if there is any way of recovering the files from the vdi file.
In parallel, I generated a fresh 12.04.1 machine on virtualbox in the same laptop, and I'll use that one instead of the borked one.
I can add the borked vdi
to the list of disks in the working one. Then I used gnome nautilus to mount the borked disk.
I can find the files in there, but they are about 2 months old. I think this coincides with the last time that I did a virtualbox snapshot of the machine, but not the last time I got a working machine, which was yesterday. Is there any way of mounting the vdi
as of yesterday, just before it crashed?
EDITED:
Here is what Virtual Media Manager
tells me about my ubuntu64.vdi
file:
EDITED2:
I copied my ubuntu.vdi
to an external USB with plenty of disk space. I tried using Windows to clone it, but got an error:
I tried the same from the working VM via a shared folder of the USB drive, and it started the cloning. Took a good while, but finished successfully:
root@precise64:/media/sf_E_DRIVE/copy_of_ubuntu64_vm_folder_20140224/ubuntu64#
VBoxManage clonehd ubuntu64.vdi ubuntu64.raw --format RAW
0%...
10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone hard disk created in format 'RAW'. UUID: 90f99198-18e1-40ee-85fe-c083dcbb1ac3
EDITED3:
After creating the raw file, I run testdisk
with Deeper Search
, I get a list like this:
Ater Deeper Search
has finished, I get a list like this:
But I don't know which one is which snapshot... Any ideas?
Of the command line
In case we use Ubuntu as a host we can convert our .vdi disk to a raw disk with the following command:
We can then open testdisk with this file to recover files on the virtual drive's image (also see below):
Of a virtual machine
In case the broken VDI drive image is still registered with Virtual Box we may be able to add this image as a drive to our new virtual machine:
Start your virtual Ubuntu to which we had added the broken .vdi but do not mount the drive.
Create a directory on a mounted partition there to hold the harvested data (e.g.
~/rescued
),Install testdisk on the virtual machine.
Start testdisk from a terminal there:
Choose the appropriate drive to harvest data from (here shown for
/sdb
) and select[Proceed]
Choose the appropriate partition layout (usually
Intel
)Select
[Analyse]
-[Quick Search]
Select the partition which contains the data to harvest (here only a single NTFS partition was present):
Press P to list files on that partiton.
Browse to the directory containing the data. View the filenames to make sure you did choose the right ones.
Select directories or files to harvest using : . All selected files/directories will be marked green:
Press upper case C to copy all selected directories/files to the rescue directory which will be selected in the next step.
Choose a directory on your Ubuntu VM's mounted partition(s) to hold rescued data:
Press c to start copying the data from the broken .vdi to our rescue directory in your healthy VM.
Notes:
In case we can not see our files with the
[Quick Search]
option in 6. we may have to perform a[Deeper Search]
. This will also list previous deleted and overwritten partitions. So we need to make sure we select the appropriate partitions where our data reside.If we had taken snapshots of the .vdi we may find these in
~/.VirtualBox/Machines/<Name of Machine>/Snapshots/{###}.vmdk
but whenever we had used the snapshot feature of Virtual Box any changes from a snapshot will be written to a differential file.To merge the differential file with the hard drive we need to delete all snapshots (which is probably not what we want as then we could just restore to previous snapshot rather than call for data recovery), or we need to clone the machine's drive using:
Then we bind the clone to our rescue VM as depicted above.
Writing to the broken .vdi should only be done after the data was safe as this may further damage the file system.
In case our rescue Ubuntu is too small to hold the rescued data we may create another new virtual drive to bind to the VM. This drive then has to be mounted in the VM to be able to save data from testdisk there.
1) Try to recover the snapshot by the UUID, use following hack:
enter the command
C:> VBoxManage clonehd <UUID> CloneDisk.vdi
Hope it helps, i did found the solution here: (https://forums.virtualbox.org/viewtopic.php?t=791)
2) if the steps in 1) does not work, heres another steps you can try. How to clonehd the Current State of a disk:
Thi solution is from here: (http://www.i-m-code.com/blog/blog/2012/02/04/virtualbox-clone-snapshots/) Both speaks mostly about the same.
I had a Linux system get corrupted at
/
andfsck
could not fix it. I used the following simple approach:/home/user/
folder. Remember to copy the hidden files (settings files).Worked well for me. The disk corruption was only hindering boot, there was no data loss in my home folder.
Found my corrupt vdi file to be recoverable using 7-Zip , hope this simple method too helps someone.
Launch the old virtual machine after inserting an Ubuntu ISO. Ubuntu will analyze the machine. Choose "Try ubuntu" (obviously don't install anything and don't erase any data). Once it's booted up (and it will because it's using the ubuntu iso not your old broken install), in the browser (Nautilus) choose "Other locations" to navigate to your old data and move them to somewhere safe.
I did not try to fix the machine, but I was only interested in recovering data and move them to the new virtual machine. It's probably possible to do what the top answer is suggesting directly from the live-booted old machine that way.