How to: Mount raw VM disk images (KVM/Xen/VMW)

You can use linux loop device to mount the raw/disk images on the host. First, setup the loop device with the image file:
losetup /dev/loop0 raw-image-file.raw

Once done, use kpartx to recognise and activate partitions in the image:
kpartx -a /dev/loop0

Once done, you can see the partitions available to this image under /dev/mapper/loop0*

# ls /dev/mapper/loop0*
/dev/mapper/loop0p1 /dev/mapper/loop0p2 /dev/mapper/loop0p3 /dev/mapper/loop0p4 /dev/mapper/loop0p5 /dev/mapper/loop0p6

Now, you can mount each partition to a mount point, for example:

mount /dev/mapper/loop0p1 /mnt

Once all the processing is done, unmount the partitions, deactivate partitions with kpartx and remove the loop device:

umount /mnt
kpartx -d /dev/loop0
losetup -d /dev/loop0

  • vm image, disk image, raw image, kvm image, mount, centos
  • 0 Корисниците го најдоа ова како корисно
Дали Ви помогна овој одговор?

Понудени резултати

LVM Cheatsheet

To install LVM2 in CentOS/Redhat servers: yum install lvm2 1. Add a partition to physical...

How to: Extend LVM partition

To increase the partition lv0 under volume group vg0 by 50GB, use lvextend command: lvextend...

How to: LVM Snapshot

LVM snapshot can be useful for filesystem integrity check and backups. A snapshot of size 15GB...

How to: Device Mapper Number to LV Name

It is often confusing when device mapper number appears while troubleshooting in place of logical...

How to: Repair a lvm thin pool

Sometimes there can be error like the following:Thin's thin-pool needs inspection.It can appear...