Subject: loopmount again

From: Bernhard Mogens Ege <[email-masked]>
Date: Tue, 7 Oct 1997 07:34:44 GMT

Hi,

I noticed the arrival of losetup and downloaded it right away (I just
had to try). I installed it, and tried that little example mentioned in
the man page (creating a 100K ext2 image and mounting it). It worked
perfectly. :-)

Then I tried copying a 1.44Mb dos-floppy image to the HD and tried
loopmounting that. Again it worked perfectly.

The I tried mounting my ADFS disk, and then loopmounted the root-rpc
disk I had located in $.ARMLinux. This too worked perfectly.

Now I had to try the real test. I loop-mounted my dos-image file located
in $.PC486.drive_c. It failed. Doh!

The mount phase failed. The losetup /dev/loop0 /mnt/adfs/PC486.drive_c
did not complain. Mount complains about not being a msdos filesystem or
a bad superblock (I think it was superblock).

I tried creating other dos-image files, formatting them in various ways,
but they all failed.

Then I was looking into a way to create a dos-image file on my ext2 disk
but I could not. mkdosfs complains about not being able to determine the
geometry of the image file. I understand that, but how do I tell mkdosfs
that?

I guess that the image-file create by !PCConfig isn't exactly as mount
-t msdos/vfat wants it. Can I correct that?

Bernhard

-- 
------------------------------------------------------------------------------
 Bernhard Mogens Ege, M.Sc.E.E.  |           | E-mail:      [email-masked]
 Laboratory of Image Analysis    |      /(   | Direct call:   +45 96 35 87 85
 Institute of Electronic Systems |   ._//(   | Switchboard:   +45 96 35 80 80
 Aalborg University              |  /  |  \  | Fax:           +45 98 15 40 08
 Frederik Bajersvej 7, D1-205    |  A  A  U  | Homepage:
 DK-9220 Aalborg East            |           | http://www.vision.auc.dk/~bme
------------------------------------------------------------------------------
  Home: H.C.Andersens Vej 26 st.mf., DK-9000 Aalborg, Phone: +45 20 42 99 26
------------------------------------------------------------------------------

---

From: David Alan Gilbert <[email-masked]>
Date: Tue, 07 Oct 1997 10:07:43 +0000

Hi,
  The problem with loop mounting DOS image files is that they tend to be
a partition table followed by the actual filing system.

  You need to find the offset to the start of the partition and pass this to
losetup.

Dave

-- 
----------------------------------------------------------------------
- David Alan Gilbert - WARNING! This is a beta release .signature    -
- Work:    dg @ cogency.co.uk        -    0161-428-9444              -
- Home:    gro.gilbert @ treblig.org -                               -
----------------------------------------------------------------------

---

From: Russell King - ARM Linux Admin <[email-masked]>
Date: Tue, 7 Oct 1997 20:09:35 +0100 (BST)

> in $.PC486.drive_c. It failed. Doh!

The reason is that the dos image used by the PC is an image of a complete
PC hard disk with BIOS partition table at the start.  loop doesn't know about
partition tables, and so when you try to mount it, it's not a valid dos fs.

The valid dos fs is (around) one track into the image file, whatever a track
is when talking about image files...

Maybe the fatfs should be modified to take an offset parameter?  [don't look
at me to do that, but please do send patches...]
   _____
  |_____| ------------------------------------------------- ---+---+-
  |   |        Russell King        [email-masked]        --- ---
  | | | |    http://www.arm.uk.linux.org/~rmk/home.html      /  /  |
  | +-+-+                                                     --- -+-
  /   |               THE developer of ARM Linux              |+| /|\
 /  | | |                                                     ---  |
    +-+-+ -------------------------------------------------  /\\\  |

---

From: Bernhard Mogens Ege <[email-masked]>
Date: Wed, 8 Oct 1997 07:00:25 GMT

>>>>> "Russell" == Russell King <- ARM Linux Admin <[email-masked]>> writes:

>> Now I had to try the real test. I loop-mounted my dos-image file
>> located in $.PC486.drive_c. It failed. Doh!

> The reason is that the dos image used by the PC is an image of a
> complete PC hard disk with BIOS partition table at the start.  loop
> doesn't know about partition tables, and so when you try to mount it,
> it's not a valid dos fs.

I see.

> The valid dos fs is (around) one track into the image file, whatever a
> track is when talking about image files...

I made several attempts with different offsets, all with 512 bytes
apart. The 17th attempt succeeded, i.e., the offset should be
17*512=8704. Hope this helps someone.

> Maybe the fatfs should be modified to take an offset parameter?
> [don't look at me to do that, but please do send patches...]

I am looking for a way to say mount /mnt/dosc (like mount /mnt/adfs) to
make linux mount that partition (extract the mising parts from
/etc/fstab). It would need to issue the losetup command to do
that. Would that be possible?

Bernhard

---

From: Paul Koning <[email-masked]>
Date: Wed, 8 Oct 1997 08:58:32 -0400

>>>>> "Bernhard" == Bernhard Mogens Ege <[email-masked]> writes:

 >> complete PC hard disk with BIOS partition table at the start.
 >> loop doesn't know about partition tables, and so when you try to
 >> mount it, it's not a valid dos fs.

 Bernhard> I see.

 >> The valid dos fs is (around) one track into the image file,
 >> whatever a track is when talking about image files...

 Bernhard> I made several attempts with different offsets, all with
 Bernhard> 512 bytes apart. The 17th attempt succeeded, i.e., the
 Bernhard> offset should be 17*512=8704. Hope this helps someone.

 >> [don't look at me to do that, but please do send patches...]

Well, losetup takes an offset parameter.  The hassle is figuring out
what the offset is.  It turns out you can do it with fdisk:

# dos disk image is in foo.dsk...
fdisk foo.dsk
x			(to "expert" mode)
p			(print partition table in semi-raw form)
q			(quit)

Look at the "start" column, that's the starting sector number of the
partition.  Multiply by 512, supply that as the -o argument of
losetup.  Done...

	paul

---

From: Philip Blundell <[email-masked]>
Date: Fri, 10 Oct 1997 19:32:19 -0000

>that. Would that be possible?

Newer mounts can do this automatically.

p.