[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-users] Recovering from VM file system corruption (in a LV inside a LV)

  • To: xen-users@xxxxxxxxxxxxxxxxxxx
  • From: Kyle Lexmond <kyl191@xxxxxxxxx>
  • Date: Sun, 14 Nov 2010 18:13:20 +0800
  • Delivery-date: Mon, 15 Nov 2010 05:55:53 -0800
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=S5h4DSKJUdeJ5BduFNyFCauelaK/eOCo3B/zc9npERcyKYn5YxHTH2Cjr52XeYrK4p 2hAby/vsNhJ0S8LVAjWHhOIfTtjofr0HVSUyeImahI5k8Gv9aD4gscDcN9eGWx9sfs8r bQMwAFrfvu4MYYxS478bTmmF9GyBa9ECQTyrY=
  • List-id: Xen user discussion <xen-users.lists.xensource.com>

Hi list,
Recently one of my VMs crashed, and couldn't reboot due to filesystem
corruption. It's a Fedora 13 host, and I installed a Fedora 13 VM
using virt-install, which by default creates an LVM for the root
partition. Now, the partition that was corrupted was the root
partition, so I couldn't boot into the VM and recover it, like I would
if /home was corrupted.

Because I searched to mostly no avail how to recover a partition in a
logical volume in a VM which itself is in a logical volume on the VM
host, which the LV partitioned into /boot and the remaining space used
for LVM, I'm posting the steps here, hopefully so someone in a similar
situation can be helped.

Step 1: Run kpartx -a /path/to/logical/volume
For me, this was kpartx -a /dev/domU/helium. This created two block
devices in /dev/mapper - domU-helium1 and domU-helium2. helium1 was my
/boot, helium2 was used for LVM.

Step 2: Run vgscan.
This will give you a list of the volume groups on your system,
hopefully including the volume group from your domU.

Step 3: Run vgchange -a y volume_group_from_VM
This will activate the logical volumes in the VG. Block devices should
appear in /dev/mapper. For me, what appeared was vg_helium-lv_root.
>From there, it's a simple fsck /dev/mapper/vg_helium-lv_root. Wait for
it to finish before you clean up after yourself.

Step 4: To clean up, you have to deactivate the LVs before destroying
the block devices that kpartx created. To do this, run vgchange -a n
volume_group_from_VM .

Step 5: Finally, run kpartx -d /path/to/logical/volume

Hopefully this helps someone - Googling "Recover file system xen
image" and variants thereof mainly turned up references to kpartx, not
the necessary LVM stuff. The most helpful link was
http://support.citrix.com/article/CTX117791, but it seems overly
complicated and has XenServer specific tools mentioned.

I'll see if I can update the xen wiki too...

Xen-users mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.