Re: loopback mount individual partitions from a whole hd image file

From: Steve Dodd (steved@loth.demon.co.uk)
Date: Sun Jun 25 2000 - 05:03:10 EST


On Sun, Jun 25, 2000 at 01:42:32AM +0100, Jon Evans wrote:

> Is there any way I can mount individual partitions from a losetup'd
> file? I can cfdisk /dev/loop and see the partitions there, with names
> like /dev/loop0p1 - but there doesn't seem to be a way to get at those
> individual partitions as seperate block devices so I can mount them.

I don't know how easy it would be to add partition support to loop, but I
guess there's the "usual" problem of major/minor number shortage.

> The file is version6_fullinstall.img, which can be obtained from
> http://jailbait.sourceforge.net/ - it's a mini Linux distribution designed
> to fit in a 16MB Sandisk, but I want to put it on a 120MB hard drive.
>
> Another way to do it would be to split the image file into seperate files
> for each partition - how would I locate the offsets into the file for each
> partition?

sfdisk can give you the offset in sectors, and the sector size:

# sfdisk -l -uS /dev/hda

Disk /dev/hda: 525 cylinders, 255 heads, 63 sectors/track
Units = sectors of 512 bytes, counting from 0

   Device Boot Start End #sectors Id System
/dev/hda1 63 2104514 2104452 7 HPFS/NTFS
/dev/hda2 * 2104515 6313544 4209030 83 Linux
[..]

losetup already has an option to specify the offset, but nothing to specify
the size, so I don't imagine that trying to set up multiple loops from a
single file would work very well. And loop is easily deadlockable in 2.3.x
(as of 2.4.0-test2, anyway).

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Jun 26 2000 - 21:00:06 EST