How to attach and mount Xen DomU's disk partitions on Linux without Xen?

How to attach and mount Xen DomU's disk partitions on Linux without Xen?

asked Dec 14, 2015 by anonymous

1 Answer

You can use kpartx to create devices from the VM disk image (say, ./vmdisk0).

To activate all the partitions in a raw VM disk image:

# kpartx -av ./vmdisk0

This will output lines such as:

add map loop1p1 (253:8): 0 497664 linear /dev/loop1 2048
add map loop1p2 (253:9): 0 2 linear /dev/loop1 501758
add map loop1p5 (253:10): 0 63557632 linear /dev/loop1 501760
add map loop1p6 (253:11): 0 61769665 linear /dev/loop1 64059455

The loop1 is the name of a device file under /dev/mapper which you can use to access the partition. If the raw disk image's partitions are LVM volumes, you may find the LVM volumes being found by Linux like vg0 here:

# vgs
VG      #PV #LV #SN Attr   VSize   VFree 
HomeLVM   1   1   0 wz--n- 683.59g     0 
vg0       2   2   0 wz--n-  59.75g 29.49g

When you're done with the partitions (and with filesystems unmounted), you need to remove the devices

# vgchange -an vg0 # not need to do this if you have not LVM
# kpartx -dv ./vmdisk0
answered Dec 17, 2015 by Eric Z Ma (44,280 points)

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...