Sunday, September 16, 2018

Recover Crashed Ubuntu VM On Proxmox VE

One of our VM server accidentally crash and the partition table was deleted. It is using Ubuntu 14.04 on VMDK container. Here are what we did to recover the server.

Prerequisite: Ubuntu NON-EFI, ext4 partition

Convert vmdk to qico2
# qemu-img convert -f vmdk -O qcowq file.vmdk file.qcow2

Download ISO System Rescue CD from http://www.system-rescue-cd.org/ then treat as CD-ROM in the crashed VM, and then in the VM Console interface, boot from CD-ROM.

Run Test-disk

  1. Select the disk
  2. Select partition format: INTEL
  3. Analyze
  4. Deep search
  5. Select the righ partition
  6. Write
  7. Quit & reboot

Reload Using Ubuntu live CD
- fdisk recover extender partition (change type) from f to 5
- write, reboot

Rescue:
Install boot on /dev/sda, then reboot.

All done.

NOTES:
Mount to see files:
# qemu-nbd -c /dev/nbd0 file.qcow2
# partprobe /dev/nbd0
# mount /dev/nbd0 /mnt/nbd0