Chapter 15. Unix loopback mounts: using disk images as Unix directories


============================================================
Instructions for creating a loopback mount, so you can access
disk image files as normal directories under the host OS.
============================================================


NOTE: You will likely have to be root to execute the following commands.

NOTE: DO NOT try to access the disk image file with a loopback mount
      and plex86 at the same time!!!

Hard Disk Image Files:

  The very first track is used for paritition info.  So you
  have to let the loopback know to skip it.  Look at the
  'spt=' option for the 'diskc' clause in your conf file.  For example:

    bochs-opt diskc: file=../../483M.NT40, cyl=1024, heads=15, spt=63
                                                                   ^^

  ...uses 63 sectors per track.  So one track is (63 * 512bytes-per-sector),
  or 32256 bytes.  Pass this info to losetup, along with the loopback
  device and directory mount point.  You will have to create the directory
  mount point if it doesn't already exist, with 'mkdir'.


    root# mkdir /mnt/winnt   # If not created already
    root# losetup -o 32256 /dev/loop0 <path-here>/483M.NT40 
    root# mount /dev/loop0 /mnt/winnt


  Now you can use '/mnt/winnt' as a normal Unix directory.  When
  you are done, undo the process:

    root# umount /dev/loop0
    root# losetup -d /dev/loop0


Floppy Disk Image Files:

  This is a more simple case than for hard disk images.  You don't
  need to specify an offset to losetup, because there is no partition
  table.

    root# mkdir /mnt/msdos   # If not created already
    root# losetup /dev/loop0 <path-here>/1.44_image
    root# mount /dev/loop0 /mnt/msdos

  Now you can use '/mnt/msdos' as a normal Unix directory.  When
  you are done, undo the process:

    root# umount /dev/loop0
    root# losetup -d /dev/loop0