Re: fdisk /dev/loop0 ?

Brion Vibber (brion@gizmo.usc.edu)
Thu, 17 Jun 1999 18:55:44 -0700 (PDT)


On Thu, 17 Jun 1999, Tigran Aivazian wrote:

> Can anyone tell me if it is possible to manipulate a disk image with
> multiple partitions? I wanted to make a file that looks like
> "hda: hda1 hda2" for booting Linux (or some other OS) under bochs and I

My recollection from the time I tried bochs was that I created a big block
of zeros to be the drive and partitioned it from (blech) DOS fdisk running
inside bochs, booted from a virtual floppy. The same could be done with
Linux fdisk running inside bochs, or I'm sure you could hack up fdisk to
work on a file as though it were a partition.

The partitions inside the file can be accessed by appropriately setting
the offset address for your loop device (see man 8 losetup). I'm sure
there's a magic method of calculating the offset but I don't know it, I
just searched the file for the magic bytes at the start of the FAT
partition (look at a real-disk partiton of the desired type to compare).

There's no need for changing the loop device to do this, it can all be
done in user space AFAIK. I'm not sure if you can have multiple loop's
opened on different parts of one file though (host-OS access to
multiple looped partitions simultaneously) though, never tried that.

-- brion vibber (brion@pobox.com | brion@gizmo.usc.edu)

-
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/