Extract partition data from xen image file: Difference between revisions
| Line 51: | Line 51: | ||
#vgchange -an VolGroup | #vgchange -an VolGroup | ||
0 logical volume(s) in volume group "VolGroup" now active | 0 logical volume(s) in volume group "VolGroup" now active | ||
#kpartx -d /dev/loop0 | |||
#losetup -d /dev/loop0 --delete from used | #losetup -d /dev/loop0 --delete from used | ||
Revision as of 14:41, 22 February 2014
THE ISSUE WAS FACED ON 192.168.1.15 where a virtual machine had boot error :
ERROR: boot loader didn't return any data!
The virtual machine was not getting up so data has to be extracted
GETTING DATA FROM XEN IMAGE FILE
using kpartx utility
- losetup -f -- find unused
/dev/loop0
- losetup /dev/loop0 /HDD_500/images/javapostgresql.img
- kpartx -av /dev/loop0
add map loop1p1 : 0 1024000 linear /dev/loop1 2048 add map loop1p2 : 0 60413952 linear /dev/loop1 1026048
- losetup -a ---lists all used
/dev/loop0: [0811]:32571394 (/HDD_500GB/images/javapostgresql.img) /dev/loop1: [0811]:32571394 (/HDD_500GB/images/javapostgresql.img)
- vgscan
Reading all physical volumes. This may take a while... Found volume group "VolGroup" using metadata type lvm2
- vgchange -ay VolGroup
2 logical volume(s) in volume group "VolGroup" now active
- lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert lv_root VolGroup -wi-a- 27.80G lv_swap VolGroup -wi-a- 1.00G
- mount /dev/VolGroup/lv_root /mnt/data/
NOW you can access your root partition in image on /mnt/data folder
After data is copied unmount the partition
- umount /mnt/data/
- vgchange -an VolGroup
0 logical volume(s) in volume group "VolGroup" now active
- kpartx -d /dev/loop0
- losetup -d /dev/loop0 --delete from used
NOTE: always remember to deactivate the logical volumes with "vgchange -an", remove the partitions with "kpartx -d", and (if appropriate) delete the loop device with "losetup -d" after you are finished. There are two reasons: first of all, the default volume group name for a install is always the same, so if you end up activating two disk images at the same time you'll end up with two separate LVM volume groups with the same name. LVM will cope as best it can, but you won't be able to distinguish between these two groups on the command line.
And secondly, if you don't deactivate it, then if the guest is started up again, you might end up with the LVM being active in both the guest and the dom0 at the same time, and this may lead to VG or filesystem corruption.