[HOWTO] Linux: Mount & create pcem images

Support and general discussion.
User avatar
TheMechanist
Posts: 36
Joined: Mon 03 Apr, 2017 6:59 pm

[HOWTO] Linux: Mount & create pcem images

Postby TheMechanist » Thu 13 Apr, 2017 5:44 pm

Since it's not possible to use shared folders with pcem, mounting an image to copy software is necessary.

With Linux it's straight forward, if you pay attention to a few things - I struggled especially with a bootable image (offset parameter), so I hope it helps:

I. If you have created an image with pcem, you'll find an image file.

1. In terminal type:

Code: Select all

fdisk -l <your.img>


It tells you "sector size" and "start". "Start" is where the filesystem starts which depends on your image, e.g. if it's the boot image and OS.

If your image contains multiple partitions, they are all shown with their starting sectors. Note, that extended partitions are just structures for logical partitions, that can't be mounted; only mount partitions, for which fdisk identifies a filesystem.

Code: Select all

fdisk -l hdd2.img
Disk hdd2.img: 42 MiB, 44040192 bytes, 86016 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device     Boot Start   End Sectors  Size Id Type
hdd2.img1          17 41054   41038   20M  4 FAT16 <32M
hdd2.img2       41055 87107   46053 22.5M  5 Extended
hdd2.img5       41072 87107   46036 22.5M  4 FAT16 <32M


For the first partition, the offset would be 512 * 17 = 8407, for the second - logical drive - 512*41072 = 21028864.

Note: For me it didn't make a difference, if fdisk -l is invoked without special drive specs (see II.2.). Try it, maybe it makes a difference in some cases like using real disc images.

2. To mount it just type:

Code: Select all

mount -o loop,offset=<start*sectorsize> <your.img> <desired mount point>


The offset is essential to mount the image correctly !

3. If it requires root rights to do, just mount as root or check your distributions help, how to mount with user privileges (e.g. add to fstab).

If mounted as root, adding

Code: Select all

-o umask=000, ...


will allow everbody to read and write the image.

Running pcem with a mounted disc doesn't seem to work, so unmount the disc when starting pcem / exit pcem before mounting.

II. You can create an image with linux too.

1. Create an image file

Code: Select all

dd if=/dev/zero of=<your.img> bs=1M count=<desired MB>


2. Get ancient drive specs

Run pcem and check in BIOS, which drives are supported by your "computer". Most BIOS have a lot of predefined disc specs they accept.

E.g. Classical hard disc (nr. 14 in Amibios):

Code: Select all

42 MB, 733 cyclinders, 7 heads, 17 sectors, 512 bytes/sector


3. Create partition with fdisk

Code: Select all

fdisk -C <cylinders> -H <heads> -S <sectors> <your.img>


For MSDOS:
a. Press "c" for DOS compatibility
b. Press "n" to create a partition
c. Press "t" to change partition type to 6 (FAT16)
d. Press "w" to write changes

You'll have to format filesystem with MSDOS Format, mkdosfs doesn't seem to work for image

4. Add the disc to pcem in settings & BIOS
Last edited by TheMechanist on Sat 15 Apr, 2017 6:52 pm, edited 1 time in total.
Zup
Posts: 40
Joined: Mon 30 Nov, 2015 10:47 am

Re: [HOWTO] Linux: Mount & create pcem images

Postby Zup » Fri 14 Apr, 2017 9:30 am

Note that the mount instruction will mount the first partition. If you have more than one partition, you'll need other instruction to access other partitions.
User avatar
TheMechanist
Posts: 36
Joined: Mon 03 Apr, 2017 6:59 pm

Re: [HOWTO] Linux: Mount & create pcem images

Postby TheMechanist » Sat 15 Apr, 2017 6:41 pm

Zup wrote:Note that the mount instruction will mount the first partition. If you have more than one partition, you'll need other instruction to access other partitions.


It mounts the partition, which offset you calculated. If you have multiple partitions, fdisk -l will show all partitions and their starting sectors. Thanks for your hint, added it to howto ..
User avatar
ender
Posts: 51
Joined: Tue 14 Oct, 2014 12:51 pm

Re: [HOWTO] Linux: Mount & create pcem images

Postby ender » Sun 16 Apr, 2017 9:04 pm

If you want an easy way to mount partitions from a disk image, use losetup like this:

Code: Select all

losetup -P /dev/loopX /path/to/disk.img
You'll get partitions as /dev/loopXp1, /dev/loopXp2 etc., which you can then mount directly (mount /dev/loopXp1 /mnt/whatever). When you're done, remove the loop with

Code: Select all

losetup -d /dev/loopX
JohnElliott
Posts: 46
Joined: Sun 31 Jan, 2016 7:29 pm

Re: [HOWTO] Linux: Mount & create pcem images

Postby JohnElliott » Mon 17 Apr, 2017 8:36 pm

If you want to access the contents of floppy images, the easiest way to do that is with mtools:

Code: Select all

mdir -i imagefile                       -- show contents
mcopy -i imagefile sourcefile ::        -- copy a file into the image
mcopy -i imagefile ::file .             -- copy a file out of the image
mdel -i imagefile ::file                -- delete a file from the image


(To create a new floppy image, I find it simplest to start with an existing one of the right size, copy it, and use mdel to delete the contents of the copy).
jschwart
Posts: 8
Joined: Sat 26 Nov, 2016 8:54 pm

Re: [HOWTO] Linux: Mount & create pcem images

Postby jschwart » Sat 13 May, 2017 9:17 pm

At some point I wrote a script to just copy files into an (almost) empty bootable image. I use it mainly to put existing dosemu installations into PCEM, but whenever I need to put a single file inside an existing PCEM installation, I just create a second image and use it as "drive d".

This script is here:
https://github.com/jschwartzenberg/dos- ... aster/pcem

It's really rough, but this works:
./copyfilesintoimage /tmp/somedirwith files /tmp/drived.img

The resulting drived.img can be easily loaded from PCEM.
teppic
Posts: 21
Joined: Tue 20 Jun, 2017 12:31 pm

Re: [HOWTO] Linux: Mount & create pcem images

Postby teppic » Wed 19 Jul, 2017 6:16 pm

As an addition to this, it's really easy to create 1.4/2.8mb floppy images and mount them.

First create the image:

Code: Select all

dd if=/dev/zero of=floppy.img bs=1440k count=1

(change to 2880k for 2.8mb)

Then create a DOS filesystem on the image:

Code: Select all

mkdosfs floppy.img

And then mount wherever you'd like:

Code: Select all

sudo mount -o loop floppy.img /mnt/floppy

You don't need fdisk or an offset since it's not partitioned. You can copy/unzip as you like, be sure to unmount it before you try to use it.

Return to “General”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest