At Logilab, we work a lot with virtual machines for testing and developping code on customers architecture. We access virtual machines through the network and copy data with scp command. However in case you get a network failure, there is still a way to access your data by mounting a rescue disk on the virtual machine. The following commands will use qemu but the idea could certainly be adapted for others emulators.
Creating and mounting the rescue disk
For later mounting the rescue disk on your system, it is necessary to use the raw image format (by default on qemu):
$ qemu-img create data-rescue.img 10M
Then run your virtual machine with the 'data-rescue.img' attached (you need to add a disk storage on virtmanager). Once in your virtual system, you will have to partition and format your new hard disk. As a an example with Linux (win32 users will prefer right clicks):
$ fdisk /dev/sdb $ mke2fs -j /dev/sdb1
Then the new disk can be mounted and used:
$ mount /dev/sdb1 /media/usb $ cp /home/dede/important-customer-code.tar.bz2 /media/usb $ umount /media/usb
You can then stop your virtual machine.
Getting back data from the rescue disk
You will then have to carry your 'data-rescue.img' on a system where you can mount a file with the 'loop' option. But first we need to find where our partition start:
$ fdisk -ul data.img You must set cylinders. You can do this from the extra functions menu. Disk data.img: 0 MB, 0 bytes 255 heads, 63 sectors/track, 0 cylinders, total 0 sectors Units = sectors of 1 * 512 = 512 bytes Disk identifier: 0x499b18da Device Boot Start End Blocks Id System data.img1 63 16064 8001 83 Linux
Now we can mount the partition and get back our code:
$ mkdir /media/rescue $ mount -o loop,offset=$((63 * 512)) data-rescue.img /media/rescue/ $ ls /media/rescue/ important-customer-code.tar.bz2