[linux-lvm] Loopback mount a disk image with lvm

David Robinson zxvdr.au at gmail.com
Mon Jun 9 00:52:54 UTC 2008


On Mon, Jun 9, 2008 at 8:23 AM, Girish V <girish.xen at gmail.com> wrote:
> Hello,
>
> I have a disk.img (a disk image file, raw format) with the following "fdisk -l"
>
>    Device Boot      Start         End      Blocks   Id  System
> disk.img1   *           1          13      104391   83  Linux
> disk.img2              14        2491    19904535   8e  Linux LVM
>
> Now I can loopback mount the first bartition using
> "mount -o loop,offset=32256 disk.img /mnt".
>
> I need to mount the second partition. If the secoond partition had
> been an ext3 partition, I would have loopback mounted it as
> "mount -o loop,offset=$((255*63*512*13) disk.img /mnt", but when I try
> that, I get
> mount: unknown filesystem type 'LVM2_member'
>
> Any help is greatly appreciated.

losetup /dev/loop0 disk.img
kpartx -a /dev/loop0

Then to mount the first partition:

mount /dev/mapper/loop0p1 /mnt

Or to activate the volume group then mount the logical volume:

vgscan
vgchange -ay vg
mount /dev/vg/lv /mnt

Hope that helps.

--Dave




More information about the linux-lvm mailing list