Update

Do this with kpartx now.

[clug] Accessing partitions on loop devices

Andrew Pollock andrew-clug at andrew.net.au
Thu Dec 16 04:45:26 GMT 2004


On Thu, Dec 16, 2004 at 12:20:08PM +1100, dave wrote:
> These devices (/dev/loop0p*) are only a naming convention used by fdisk,
> they dont exist (and cant be created as they are not actually exported
> as devices by the kernel/loop module).
> 
> You have 2 options:
> 1. Use the 'offset' option to losetup, to tell the loop device to begin
> at the start of the partition. For example:
> losetup -o 327680 /dev/loop0 image.dd
> (BTW, you can do it with mount, then you dont have to delete the
> loopback device yourself, it will happen for you when you unmount:
> mount -o loop,offset=327680 image.dd /mnt/)
> 
> The problem with this is that the offset argument would appear to be a
> signed integer, meaning that if any of you partitions begin after the
> 2GB mark, the offset will wrap and it will not work, which brings me to:
> 
> 2. NASA has developed a replacement loop module without this
> shortcoming. It even parses the partition table and exposes devices for
> the partitions such that /dev/loop0p1 would be real and you could
> actually mount it (you have to make the nodes, but the instructions tell
> you how to do that). I know it works with DOS partition table, assuming
> it uses the kernel to do the parsing, it will probably also work with
> other partition tables supported by the kernel (sun, apple, bsd etc). I
> dont have a link atm, you should be able to find it with google. I am
> not sure it has been ported to kernel 2.6 either.
> 
> BTW, the block numbers you get from "fdisk -l" begin after the boot
> sector and partition map. To get the correct values to give in the
> 'offset' parameter to loopback try 'fdisk -lu' or 'sfdisk -d'. For dos
> disks, the first partition typically starts at sector 63, which is
> 63*512 bytes, so you would use 32256 as the offset option.
> 
> Maby there are other ways these days, device mapper etc??
> 
> Hope this helps,

Thankyou for the comprehensive explanation. I didn't have size issues, but I
wasn't able to mount the second partition no matter what I did. That may
have been more a problem with the filesystem on it than anything else. The
-u option to fdisk was helpful though. I think I've successfully dd'ed the
entire CD now at least. (I was trying to copy a Solaris CD)

regards

Andrew


More information about the linux mailing list