Rescuing a qemu android-x86 image

I use a number of qemu based android-x86 for various purposes, such as storing proprietary certificate handling software in them.

One of the virtual machines suddenly refused to boot. It kept hanging during the display of the android logo in the early boot sequence.

Booting the virtual machine in debug mode revealed that there was an issue with the ext3 root filesystem.

Very odd. This is how I solved it

 1
 2yum install guestfish
 3guestfish -a  ~/android-x86/certstore.img
 4
 5Welcome to guestfish, the guest filesystem shell for
 6editing virtual machine filesystems and disk images.
 7
 8Type: 'help' for help on commands
 9      'man' to read the manual
10      'quit' to quit the shell
11
12><fs> help
13Add disk images to examine using the -a or -d options, or the 'add' command.
14Or create a new disk image using -N, or the 'alloc' or 'sparse' commands.
15Once you have done this, use the 'run' command.
16
17For more information about a command, use 'help cmd'.
18
19To read the manual, type 'man'.
20
21><fs> run
22><fs> list-filesystems
23/dev/sda1: ext3
24><fs> fsck ext3 /dev/sda1

At this point theres a progress bar, and a segfault. If I try guestfish and run again, there is no error report or progress bar.

Then I can boot the vm as usual.

1qemu-kvm -m 512 -hda ~/android-x86/certstore.img -vga std -usbdevice tablet

The error in the boot happened again at a later time, and I could again recover the image the exact same way.