VirtualBox

Rescuing rm-ed file from EXT3

Background: I run multiple VirtualBox client within a single server. Each VirtualBox client coming with its *.vdi file for sure. Accidentally I run rm to them during migration and backup, and so some *.vdi are lose. I need to rescue them.

Most important action for rescue: unplug the server power and shut-it-down IMMEDIATELY! Try not to preform ANY write action to the target harddisk ANYMORE!

Next, I googling and figure out that foremost may give me a hand. So I will need a Ubuntu in Live-CD and boot up a system for rescue besides loading my target drive directly. Soon after that I figure out ext3grep and seems much better for my target.

foremost

I am now running the scan and hopefully it can get my data back. Here are some procedures about the work:

  1. Unplug the power of server IMMEDIATELY!
  2. Get an Ubuntu Live-CD. I am using 9.04 Desktop edition. We don't care about the version.
  3. Boot the system with Live-CD.
  4. After login, first update aptitude package list with:
    aptitude update
  5. Now install foremost and sshfs (for remote backup):
    apt-get install foremost sshfs
  6. Reference to Tutorial: All about VDIs and figure out its header format (I use hexdump to correct *.vdi for the correct header). Manually add the *.vdi extension to /etc/foremost.conf, e.g.:
    vdi y 137438953472    \x3c\x3c\x20\x3c\x75\x53\x20\x6e       \x00\x00\x00\x00\x00\x00\x00\x00
  7. Mount your remote drive and prepare for the restore.
  8. Run foremost as example:
    cd dir_where_you_mount_your_remote_drive_with_sshfs
    foremost -d -v -T -i /dev/sda3
  9. Go for a lunch or bath or coffee break or something else. Remember that foremost is now scanning the WHOLE drive and so it will take for a VERY long time!

ext3grep

Well... I am now trying to recover as newbie... Hopefully it can help:

ext3grep /dev/sda3 --restore-file home/groups/filename_to_be_restore

I am also seeking for other solutions, too. If you have any idea please let me know :S

UPDATE (20090731): Finally ext3grep is functioning and all files are successfully recovered. As they are *.vdi, after restore and bootup VirtualBox client, it is recommened to run fsck for every drives. To force fsck during system boot, run the following command and reboot the Linux:

touch /forcefsck


Intranet connection for VirtualBox 2.1.2

There are some different between VMware network connection with VirtualBox: for VMware, all clients will able to have interconnection in both NAT and internal mode, where clients will locate within save subnet; in case of VirtualBox, all NAT network will be handled individually, where only internal mode can communicate with each others (with same "network name", which will explain later). So how to build a effective internal network for your virtual clients? The main tips is: use 2 network adapters for your clients.


VirtualBox 2.1.0 on Debian Lenny mini-HOWTO

VirtualBox is an x86 virtualization software package, originally created by German software company innotek, now developed by Sun Microsystems as part of its Sun xVM virtualization platform. This mini-HOWTO will guide you though VirtualBox 2.1.0 installation on Debian Lenny/sid.

As Sun Microsystem already release Virtual 2.1.2 with number of bug fixes, please refer to my upgrade procedure for more information.


Upgrade VirtualBox from 2.1.0 to 2.1.2 on Debian Lenny

There is a new release of VirtualBox 2.1.2 for Debian Lenny on today (Changelog for 2.1.2), and so my server need upgrade. Here is some tips for a smooth server upgrade procedure:

  1. Shutdown down all of your virtual clients. It is because the virtual client profile and client daemon are both required to upgrade. We will get it done after server upgrade.
  2. Run the following command for packages upgrade:
    aptitude update && aptitude full-upgrade && aptitude autoclean && aptitude clean

    It will prompt that VirtualBox's kernel module required for upgrade after installation. Press "yes" to delete the existing kernel module now.
  3. After install you will need to recompile your VirtualBox's kernel module by:
    /etc/init.d/vboxdrv setup

It is recommend to reboot your host after kernel module upgrade. Once upgrade completed, open the VirtualBox GUI and it will prompt you a message that all virtual client profiles need upgrade, simply let it handle for you.

For each virtual client you will also need to upgrade their "Guest Additions". Just follow the normal installation procedure for upgrade, and reboot your client after that :D


Clone VirtualBox disk image on MS Windows mini-HOWTO

Since I am now testing VirtualBox performance, I need to clone existing guest image for multi-testing. This mini-HOWTO will guide you though the procedure for cloning a guest storage file for a new guest, under MS Windows host.

When following the official guideline and document, using VBoxManage clonehd command for disk clone, the result image is ALWAYS not functioning. Finally I figure out that a non-documented internal command is required: VBoxManage internalcommands sethduuid.

This bug is documented in VirtualBox bug ticket system #2813.

Within this artical, I am using the following system setup:

  • VirtualBox: v2.1.0
  • Host: MS Windows Vista Home Basic
  • Guest: Debian Lenny

Official procedure for cloning disk image (not function on MS Windows host)

Cloning an existing disk image for VirtualBox is much more than a simple copy command: it is because VirtualBox assigns a unique identity number (UUID) to each disk image, which also stored inside the image. VirtualBox will refuse to work with two image that use the same number. You need some extra handling.

According to official document, what you need is the console command VBoxManage clonehd, e.g. (host with MS Windows):

"C:\Program Files\Sun\xVM VirtualBox\VBoxManage.exe" clonehd hda.vdi hdb.vdi

or (host with Linux):

VBoxManage clonehd hda.vdi hdb.vdi

Therefore VirtualBox will copy your disk image, assign a new UUID for it, and import to its virtual media manager. You can now use it for your new guest system.

Alternative non-documented solution

As now you understand how the vboxmanage clonehd work around, what we needed is a new-and-unique UUID for our cloned disk image. There is a non-documented internal command which target for this procedure: VBoxManage.exe internalcommands sethduuid.

So what you needed for are:

  1. (Optional) Shutdown your target guest before disk clone.
  2. Manually copy the existing disk image, e.g.
    copy hda.vdi hdb.vdi
  3. Set a new UUID for the cloned disk, e.g.
    "C:\Program Files\Sun\xVM VirtualBox\VBoxManage.exe" internalcommands sethduuid hdb.vdi
  4. Manually add this newly cloned disk image though VirtualBox "Virtual Media Manager".
  5. Create a new guest profile as old system, and point the primary harddisk to your newly cloned disk image.


Syndicate content