[ale] Loopback mounting of disk images with LVM

Asher Vilensky ashervilensky at gmail.com
Sun Sep 20 21:47:39 EDT 2009


I'm not sure what you're trying to do.  If you have a vmdk file, can't you
simply fire up (start) a VM and mount the lvm?  Why try to yank info from a
flat file?

-- Asher


On Fri, Sep 18, 2009 at 5:01 PM, <brian at polibyte.com> wrote:

> Hi,
>
> I have a file that's a disk image of a standard RHEL4 install. In this file
> are two partitions. The second partition contains a logical volume. I'd
> like to access the filesystem in that logical volume. I'm trying to create
> a loopback device that refers to the second partition so that I can use the
> standard lvm tools to set it up. I can't use the max_part option for the
> loopback module since my kernel is too old. Therefore, I think I have to
> manually calculate the offset of the second partition in the file and pass
> that to losetup. However, I get some warnings from fdisk when I'm trying to
> figure out the offset, and after I set up the loopback device the lvm tools
> don't detect anything. Anyone have any suggestions? More details are below.
>
> # First, set up the "flat" file to represent the disk.
>
> $ vmware-mount -f thedisk.vmdk /mnt/vm1/
>
> # Next, get details about the partitions.
>
> $ fdisk -l /mnt/vm1/flat
> last_lba(): I don't know how to handle files with mode 8180
> You must set cylinders.
> You can do this from the extra functions menu.
>
> Disk /mnt/vm1/flat: 0 MB, 0 bytes
> 255 heads, 63 sectors/track, 0 cylinders
> Units = cylinders of 16065 * 512 = 8225280 bytes
>
>        Device Boot      Start         End      Blocks   Id  System
> /mnt/vm1/flat1   *           1          13      104391   83  Linux
> /mnt/vm1/flat2              14        4177    33447330   8e  Linux LVM
> Partition 2 has different physical/logical endings:
>     phys=(1023, 254, 63) logical=(4176, 254, 63)
>
> # Multiply the start of the lvm partition by the units to get the offset.
> 8225280 * 14 is 115153920, so I try to mount the loopback device with
> that offset.
>
> $ losetup /dev/loop0 /mnt/vm1/flat -o 115153920
>
> # However, when I run pvscan or vgscan loop0 isn't recognized.
>
> #device/dev-io.c:486         Opened /dev/loop0 RO
> #device/dev-io.c:260       /dev/loop0: size is 66883954 sectors
> #device/dev-io.c:532         Closed /dev/loop0
> #device/dev-io.c:260       /dev/loop0: size is 66883954 sectors
> #device/dev-io.c:486         Opened /dev/loop0 RW O_DIRECT
> #device/dev-io.c:134         /dev/loop0: block size is 1024 bytes
> #device/dev-io.c:532         Closed /dev/loop0
> #filters/filter-composite.c:31         Using /dev/loop0
> #device/dev-io.c:486         Opened /dev/loop0 RW O_DIRECT
> #device/dev-io.c:134         /dev/loop0: block size is 1024 bytes
> #label/label.c:184       /dev/loop0: No label detected
> #device/dev-io.c:532         Closed /dev/loop0
>
> All the best,
> Brian Pitts
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.ale.org/pipermail/ale/attachments/20090920/77f55327/attachment.html 


More information about the Ale mailing list