VOGONS


First post, by mike_canada

User metadata
Rank Member
Rank
Member

I want to make a universally compatible bootable hard drive image that I can turn into an ISO and eventually burn onto a CD for booting into any old computer that supports CD booting.

But my problem lies with the tools I have. I use Linux.

If I use tools that come with DOSEMU (like mkfatimage16) to make an image file, then DOSEMU and mtools will happily work with the file provided that I include this in the mtools config file:

drive (any letter): file="(image)" partition=1 offset=128

When I use cfdisk or fdisk on the image, it recognizes it as a single partition.

Now the problem is if I try to mount it in Linux as a loop device, I get this problem:

NTFS signature is missing.
Failed to mount '/dev/loop1': Invalid argument
The device '/dev/loop1' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?

And dmesg shows these new errors:

[17242.765605] REISERFS warning (device loop1): sh-2021 reiserfs_fill_super: can not find reiserfs on loop1
[17242.765691] EXT3-fs (loop1): error: can't find ext3 filesystem on dev loop1.
[17242.765729] EXT2-fs (loop1): error: can't find an ext2 filesystem on dev loop1.
[17242.765765] EXT4-fs (loop1): VFS: Can't find ext4 filesystem
[17242.765821] FAT-fs (loop1): invalid media value (0x00)
[17242.765824] FAT-fs (loop1): Can't find a valid FAT filesystem
[17242.765859] FAT-fs (loop1): invalid media value (0x00)
[17242.765862] FAT-fs (loop1): Can't find a valid FAT filesystem
[17242.766190] isofs_fill_super: bread failed, dev=loop1, iso_blknum=45, block=90

and running ccd2iso (imagefile) (isofile) gives this error:

Unrecognized sector mode (c4) at sector 0!

What am I doing wrong?

And the only two things that can access such created images so far are mtools utilities and dosemu.

Reply 1 of 24, by darry

User metadata
Rank l33t++
Rank
l33t++
mike_canada wrote on 2021-07-23, 01:00:
I want to make a universally compatible bootable hard drive image that I can turn into an ISO and eventually burn onto a CD for […]
Show full quote

I want to make a universally compatible bootable hard drive image that I can turn into an ISO and eventually burn onto a CD for booting into any old computer that supports CD booting.

But my problem lies with the tools I have. I use Linux.

If I use tools that come with DOSEMU (like mkfatimage16) to make an image file, then DOSEMU and mtools will happily work with the file provided that I include this in the mtools config file:

drive (any letter): file="(image)" partition=1 offset=128

When I use cfdisk or fdisk on the image, it recognizes it as a single partition.

Now the problem is if I try to mount it in Linux as a loop device, I get this problem:

NTFS signature is missing.
Failed to mount '/dev/loop1': Invalid argument
The device '/dev/loop1' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?

And dmesg shows these new errors:

[17242.765605] REISERFS warning (device loop1): sh-2021 reiserfs_fill_super: can not find reiserfs on loop1
[17242.765691] EXT3-fs (loop1): error: can't find ext3 filesystem on dev loop1.
[17242.765729] EXT2-fs (loop1): error: can't find an ext2 filesystem on dev loop1.
[17242.765765] EXT4-fs (loop1): VFS: Can't find ext4 filesystem
[17242.765821] FAT-fs (loop1): invalid media value (0x00)
[17242.765824] FAT-fs (loop1): Can't find a valid FAT filesystem
[17242.765859] FAT-fs (loop1): invalid media value (0x00)
[17242.765862] FAT-fs (loop1): Can't find a valid FAT filesystem
[17242.766190] isofs_fill_super: bread failed, dev=loop1, iso_blknum=45, block=90

and running ccd2iso (imagefile) (isofile) gives this error:

Unrecognized sector mode (c4) at sector 0!

What am I doing wrong?

And the only two things that can access such created images so far are mtools utilities and dosemu.

Please share the exact commands that you are running, from image creation up to and including the loop device mounting attempt .

Reply 2 of 24, by Cyberdyne

User metadata
Rank Oldbie
Rank
Oldbie

Better use Floppy emulation, majority of older BIOSes do not support HDD emulation, or the feature is broken. Just saying.

I am aroused about any X86 motherboard that has full functional ISA slot. I think i have problem. Not really into that original (Turbo) XT,286,386 and CGA/EGA stuff. So just a DOS nut.

Reply 3 of 24, by darry

User metadata
Rank l33t++
Rank
l33t++

This seems to work for me, as far as partition creation and access is concerned . I have not actually tried it in DOSEmu .
EDIT : I got the image to mount under DOSEmu2 , mostly by trial and error, as IMHO, DOSEmu2's drive mapping/grouping logic is obtusely opaque, almost totally incomprehensible and poorly documented . Either that, or I'm dense or maybe very very very tired .

root@openmediavault:~$ mkfatimage16 -k 131072 -p -f /home/bob/testhdd2

root@openmediavault:~$ cat /etc/mtools.conf | egrep testhdd2
drive o: file="/home/bob/testhdd2" partition=1 offset=128 fat_bits=16

root@openmediavault:~# mcopy audiodump.wav o:

root@openmediavault:~# mdir o:
Volume in drive O has no label
Volume Serial Number is 16F6-DA0A
Directory for O:/

AUDIOD~1 WAV 25428012 2021-07-23 6:19 audiodump.wav
1 file 25 428 012 bytes
108 474 368 bytes free

root@openmediavault:~# losetup /dev/loop0 /home/bob/testhdd2 -o 128
losetup: /home/bob/testhdd2: Warning: file does not fit into a 512-byte sector; the end of the file will be ignored.

root@openmediavault:~# fdisk -l /dev/loop0
Disk /dev/loop0: 128.3 MiB, 134507520 bytes, 262710 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
/dev/loop0p1 * 0 262079 262080 128M 6 FAT16

root@openmediavault:~# fsck.fat -v /dev/loop0
fsck.fat 4.1 (2017-01-24)
Checking we can access the last sector of the filesystem
Boot sector contents:
System ID "MTOO4023"
Media byte 0xf0 (5.25" or 3.5" HD floppy)
512 bytes per logical sector
2048 bytes per cluster
1 reserved sector
First FAT starts at byte 512 (sector 1)
2 FATs, 16 bit entries
131072 bytes per FAT (= 256 sectors)
Root directory starts at byte 262656 (sector 513)
512 root directory entries
Data area starts at byte 279040 (sector 545)
65383 data clusters (133904384 bytes)
63 sectors/track, 16 heads
0 hidden sectors
262080 sectors total
Checking for unused clusters.
/dev/loop0: 1 files, 12417/65383 clusters

root@openmediavault:~# mount /dev/loop0 /mnt/testhdd2
root@openmediavault:~# ls -l /mnt/testhdd2
total 24834
-rwxr-xr-x 1 root root 25428012 Jul 23 02:23 audiodump.wav

Reply 4 of 24, by mike_canada

User metadata
Rank Member
Rank
Member
darry wrote on 2021-07-23, 10:28:

root@openmediavault:~# losetup /dev/loop0 /home/bob/testhdd2 -o 128
losetup: /home/bob/testhdd2: Warning: file does not fit into a 512-byte sector; the end of the file will be ignored.

I almost did the same thing myself except now I need to play with losetup some more.

Except that losetup doesn't want to work unless a loop device already exists, and the only way I can make a loop device exist is to use mount, but I cannot mount an image made with mkfatimage16 directly

This is the output when I tried to mount my image file /disk/image (created with mkfatimage16) to the empty /mnt folder.

bash-4.2# mount /disk/image -v /mnt mount: enabling autoclear loopdev flag mount: going to use the loop device /dev/loop0 mount: […]
Show full quote

bash-4.2# mount /disk/image -v /mnt
mount: enabling autoclear loopdev flag
mount: going to use the loop device /dev/loop0
mount: you didn't specify a filesystem type for /dev/loop0
I will try all types mentioned in /etc/filesystems or /proc/filesystems
Trying reiserfs
Trying ext3
Trying ext2
Trying ext4
Trying vfat
Trying msdos
Trying iso9660
Trying ntfs
NTFS signature is missing.
Failed to mount '/dev/loop0': Invalid argument
The device '/dev/loop0' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?

I'm going to see if there's any other way to create a loopX device so I can configure it

Reply 5 of 24, by darry

User metadata
Rank l33t++
Rank
l33t++
mike_canada wrote on 2021-07-23, 18:51:
I almost did the same thing myself except now I need to play with losetup some more. […]
Show full quote
darry wrote on 2021-07-23, 10:28:

root@openmediavault:~# losetup /dev/loop0 /home/bob/testhdd2 -o 128
losetup: /home/bob/testhdd2: Warning: file does not fit into a 512-byte sector; the end of the file will be ignored.

I almost did the same thing myself except now I need to play with losetup some more.

Except that losetup doesn't want to work unless a loop device already exists, and the only way I can make a loop device exist is to use mount, but I cannot mount an image made with mkfatimage16 directly

This is the output when I tried to mount my image file /disk/image (created with mkfatimage16) to the empty /mnt folder.

bash-4.2# mount /disk/image -v /mnt mount: enabling autoclear loopdev flag mount: going to use the loop device /dev/loop0 mount: […]
Show full quote

bash-4.2# mount /disk/image -v /mnt
mount: enabling autoclear loopdev flag
mount: going to use the loop device /dev/loop0
mount: you didn't specify a filesystem type for /dev/loop0
I will try all types mentioned in /etc/filesystems or /proc/filesystems
Trying reiserfs
Trying ext3
Trying ext2
Trying ext4
Trying vfat
Trying msdos
Trying iso9660
Trying ntfs
NTFS signature is missing.
Failed to mount '/dev/loop0': Invalid argument
The device '/dev/loop0' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?

I'm going to see if there's any other way to create a loopX device so I can configure it

Maybe I'm misunderstanding, but losetup sets up and creates the loop device on my end .

root@openmediavault:~# ls -l /dev/loop*
crw-rw---- 1 root disk 10, 237 Jul 23 15:01 /dev/loop-control

root@openmediavault:~# losetup /dev/loop0 /home/bob/testhdd2 -o 128
losetup: /home/bob/testhdd2: Warning: file does not fit into a 512-byte sector; the end of the file will be ignored.
root@openmediavault:~# ls -l /dev/loop*
brw-rw---- 1 root disk 7, 0 Jul 23 15:04 /dev/loop0
brw-rw---- 1 root disk 7, 1 Jul 23 15:04 /dev/loop1
brw-rw---- 1 root disk 7, 2 Jul 23 15:04 /dev/loop2
brw-rw---- 1 root disk 7, 3 Jul 23 15:04 /dev/loop3
brw-rw---- 1 root disk 7, 4 Jul 23 15:04 /dev/loop4
brw-rw---- 1 root disk 7, 5 Jul 23 15:04 /dev/loop5
brw-rw---- 1 root disk 7, 6 Jul 23 15:04 /dev/loop6
brw-rw---- 1 root disk 7, 7 Jul 23 15:04 /dev/loop7
crw-rw---- 1 root disk 10, 237 Jul 23 15:04 /dev/loop-control

root@openmediavault:~# losetup /dev/loop9 /home/bob/testhdd2 -o 128
losetup: /home/bob/testhdd2: Warning: file does not fit into a 512-byte sector; the end of the file will be ignored.
root@openmediavault:~# ls -l /dev/loop*
brw-rw---- 1 root disk 7, 0 Jul 23 15:04 /dev/loop0
brw-rw---- 1 root disk 7, 1 Jul 23 15:04 /dev/loop1
brw-rw---- 1 root disk 7, 2 Jul 23 15:04 /dev/loop2
brw-rw---- 1 root disk 7, 3 Jul 23 15:04 /dev/loop3
brw-rw---- 1 root disk 7, 4 Jul 23 15:04 /dev/loop4
brw-rw---- 1 root disk 7, 5 Jul 23 15:04 /dev/loop5
brw-rw---- 1 root disk 7, 6 Jul 23 15:04 /dev/loop6
brw-rw---- 1 root disk 7, 7 Jul 23 15:04 /dev/loop7
brw-rw---- 1 root disk 7, 9 Jul 23 15:05 /dev/loop9
crw-rw---- 1 root disk 10, 237 Jul 23 15:04 /dev/loop-control

Reply 6 of 24, by mike_canada

User metadata
Rank Member
Rank
Member
Maybe I'm misunderstanding, but losetup sets up and creates the loop device on my end . […]
Show full quote

Maybe I'm misunderstanding, but losetup sets up and creates the loop device on my end .

root@openmediavault:~# ls -l /dev/loop*
crw-rw---- 1 root disk 10, 237 Jul 23 15:01 /dev/loop-control

root@openmediavault:~# losetup /dev/loop0 /home/bob/testhdd2 -o 128
losetup: /home/bob/testhdd2: Warning: file does not fit into a 512-byte sector; the end of the file will be ignored.
root@openmediavault:~# ls -l /dev/loop*
brw-rw---- 1 root disk 7, 0 Jul 23 15:04 /dev/loop0
brw-rw---- 1 root disk 7, 1 Jul 23 15:04 /dev/loop1
brw-rw---- 1 root disk 7, 2 Jul 23 15:04 /dev/loop2
brw-rw---- 1 root disk 7, 3 Jul 23 15:04 /dev/loop3
brw-rw---- 1 root disk 7, 4 Jul 23 15:04 /dev/loop4
brw-rw---- 1 root disk 7, 5 Jul 23 15:04 /dev/loop5
brw-rw---- 1 root disk 7, 6 Jul 23 15:04 /dev/loop6
brw-rw---- 1 root disk 7, 7 Jul 23 15:04 /dev/loop7
crw-rw---- 1 root disk 10, 237 Jul 23 15:04 /dev/loop-control

root@openmediavault:~# losetup /dev/loop9 /home/bob/testhdd2 -o 128
losetup: /home/bob/testhdd2: Warning: file does not fit into a 512-byte sector; the end of the file will be ignored.
root@openmediavault:~# ls -l /dev/loop*
brw-rw---- 1 root disk 7, 0 Jul 23 15:04 /dev/loop0
brw-rw---- 1 root disk 7, 1 Jul 23 15:04 /dev/loop1
brw-rw---- 1 root disk 7, 2 Jul 23 15:04 /dev/loop2
brw-rw---- 1 root disk 7, 3 Jul 23 15:04 /dev/loop3
brw-rw---- 1 root disk 7, 4 Jul 23 15:04 /dev/loop4
brw-rw---- 1 root disk 7, 5 Jul 23 15:04 /dev/loop5
brw-rw---- 1 root disk 7, 6 Jul 23 15:04 /dev/loop6
brw-rw---- 1 root disk 7, 7 Jul 23 15:04 /dev/loop7
brw-rw---- 1 root disk 7, 9 Jul 23 15:05 /dev/loop9
crw-rw---- 1 root disk 10, 237 Jul 23 15:04 /dev/loop-control

What version of the kernel are you using?

I'm using 3.2.29 and the only way I can see those directory entries other than:

crw-rw---- 1 root disk 10, 237 Jul 23 15:04 /dev/loop-control

is to execute:

modprobe -r loop
modprobe loop max_part=##

where the value is at least 16.

So I executed:

modprobe -r loop
modprobe loop max_part=4
losetup /dev/loop /disk/image -o 128
ls /dev/lo*

and I get:

/dev/loop-control /dev/loop1 /dev/loop3 /dev/loop5 /dev/loop7
/dev/loop0 /dev/loop2 /dev/loop4 /dev/loop6

Then when I try to mount it I get an error.

mount /disk/image /mnt NTFS signature is missing. Failed to mount '/dev/loop1': Invalid argument The device '/dev/loop1' doesn't […]
Show full quote

mount /disk/image /mnt
NTFS signature is missing.
Failed to mount '/dev/loop1': Invalid argument
The device '/dev/loop1' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?

Since losetup has registered the image, I figured I could mount it other ways, yet I still have no luck.

bash-4.2# losetup -a /dev/loop0: [2052]:2 (/disk/image), offset 128 bash-4.2# mount /disk/image /dev/loop0 NTFS signature is mis […]
Show full quote

bash-4.2# losetup -a
/dev/loop0: [2052]:2 (/disk/image), offset 128
bash-4.2# mount /disk/image /dev/loop0
NTFS signature is missing.
Failed to mount '/dev/loop1': Invalid argument
The device '/dev/loop1' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?
bash-4.2# mount /dev/loop0 /mnt
NTFS signature is missing.
Failed to mount '/dev/loop0': Invalid argument
The device '/dev/loop0' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?
bash-4.2#

Yet when I run the image inside DOSEMU and do dir C: it shows an empty folder and the correct size as expected (instead of a media error) so somehow there is a valid dos partition when mkfatimage16 generates the image file.

I tried more things:

bash-4.2# mount /dev/loop0 -o loop=/dev/loop0,offset=128 /mnt mount: stolen loop=/dev/loop0 bash-4.2# mount /disk/image -o loop= […]
Show full quote

bash-4.2# mount /dev/loop0 -o loop=/dev/loop0,offset=128 /mnt
mount: stolen loop=/dev/loop0
bash-4.2# mount /disk/image -o loop=/dev/loop0,offset=128 /mnt
NTFS signature is missing.
Failed to mount '/dev/loop0': Invalid argument
The device '/dev/loop0' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?
bash-4.2#

Reply 7 of 24, by mike_canada

User metadata
Rank Member
Rank
Member

I came across a post just now from stackoverflow.com that states:

Let's say $IMAGE is set to the path to your image file. You could write a small script by using

fdisk -u sectors -l $IMAGE

to get a list of partitions inside the image. And then use a sequence of

mount -o ro,loop,offset=$OFFSET -t auto $IMAGE /media/$DEST

Which suggests to me that linux could only mount image files if they have defined partition entries yet DOSEMU would run the image without such an entry? Anyways, so I ran fdisk on my created image with mkfatimage16 and I see this:

bash-4.2# fdisk -l /disk/image […]
Show full quote

bash-4.2# fdisk -l /disk/image

Disk /disk/image: 33 MB, 33562624 bytes
255 heads, 63 sectors/track, 4 cylinders, total 65552 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

No partition.

So I decide to create a partition in that image file and ran fdisk like I did, and it happily shows the partition:

fdisk -l /disk/image […]
Show full quote

fdisk -l /disk/image

Disk /disk/image: 33 MB, 33562624 bytes
21 heads, 32 sectors/track, 97 cylinders, total 65552 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
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/disk/image1 * 63 65551 32744+ 6 FAT16

So I went with math I found on stackoverflow.com and made the offset 63 times 512 and I tried mounting the image with no luck:

bash-4.2# mount /disk/image -o loop=/dev/loop1,offset=$((512*63)) /mnt NTFS signature is missing. Failed to mount '/dev/loop1': […]
Show full quote

bash-4.2# mount /disk/image -o loop=/dev/loop1,offset=$((512*63)) /mnt
NTFS signature is missing.
Failed to mount '/dev/loop1': Invalid argument
The device '/dev/loop1' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?

Reply 8 of 24, by darry

User metadata
Rank l33t++
Rank
l33t++
mike_canada wrote on 2021-07-23, 22:24:
What version of the kernel are you using? […]
Show full quote
Maybe I'm misunderstanding, but losetup sets up and creates the loop device on my end . […]
Show full quote

Maybe I'm misunderstanding, but losetup sets up and creates the loop device on my end .

root@openmediavault:~# ls -l /dev/loop*
crw-rw---- 1 root disk 10, 237 Jul 23 15:01 /dev/loop-control

root@openmediavault:~# losetup /dev/loop0 /home/bob/testhdd2 -o 128
losetup: /home/bob/testhdd2: Warning: file does not fit into a 512-byte sector; the end of the file will be ignored.
root@openmediavault:~# ls -l /dev/loop*
brw-rw---- 1 root disk 7, 0 Jul 23 15:04 /dev/loop0
brw-rw---- 1 root disk 7, 1 Jul 23 15:04 /dev/loop1
brw-rw---- 1 root disk 7, 2 Jul 23 15:04 /dev/loop2
brw-rw---- 1 root disk 7, 3 Jul 23 15:04 /dev/loop3
brw-rw---- 1 root disk 7, 4 Jul 23 15:04 /dev/loop4
brw-rw---- 1 root disk 7, 5 Jul 23 15:04 /dev/loop5
brw-rw---- 1 root disk 7, 6 Jul 23 15:04 /dev/loop6
brw-rw---- 1 root disk 7, 7 Jul 23 15:04 /dev/loop7
crw-rw---- 1 root disk 10, 237 Jul 23 15:04 /dev/loop-control

root@openmediavault:~# losetup /dev/loop9 /home/bob/testhdd2 -o 128
losetup: /home/bob/testhdd2: Warning: file does not fit into a 512-byte sector; the end of the file will be ignored.
root@openmediavault:~# ls -l /dev/loop*
brw-rw---- 1 root disk 7, 0 Jul 23 15:04 /dev/loop0
brw-rw---- 1 root disk 7, 1 Jul 23 15:04 /dev/loop1
brw-rw---- 1 root disk 7, 2 Jul 23 15:04 /dev/loop2
brw-rw---- 1 root disk 7, 3 Jul 23 15:04 /dev/loop3
brw-rw---- 1 root disk 7, 4 Jul 23 15:04 /dev/loop4
brw-rw---- 1 root disk 7, 5 Jul 23 15:04 /dev/loop5
brw-rw---- 1 root disk 7, 6 Jul 23 15:04 /dev/loop6
brw-rw---- 1 root disk 7, 7 Jul 23 15:04 /dev/loop7
brw-rw---- 1 root disk 7, 9 Jul 23 15:05 /dev/loop9
crw-rw---- 1 root disk 10, 237 Jul 23 15:04 /dev/loop-control

What version of the kernel are you using?

I'm using 3.2.29 and the only way I can see those directory entries other than:

crw-rw---- 1 root disk 10, 237 Jul 23 15:04 /dev/loop-control

is to execute:

modprobe -r loop
modprobe loop max_part=##

where the value is at least 16.

So I executed:

modprobe -r loop
modprobe loop max_part=4
losetup /dev/loop /disk/image -o 128
ls /dev/lo*

and I get:

/dev/loop-control /dev/loop1 /dev/loop3 /dev/loop5 /dev/loop7
/dev/loop0 /dev/loop2 /dev/loop4 /dev/loop6

Then when I try to mount it I get an error.

mount /disk/image /mnt NTFS signature is missing. Failed to mount '/dev/loop1': Invalid argument The device '/dev/loop1' doesn't […]
Show full quote

mount /disk/image /mnt
NTFS signature is missing.
Failed to mount '/dev/loop1': Invalid argument
The device '/dev/loop1' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?

Since losetup has registered the image, I figured I could mount it other ways, yet I still have no luck.

bash-4.2# losetup -a /dev/loop0: [2052]:2 (/disk/image), offset 128 bash-4.2# mount /disk/image /dev/loop0 NTFS signature is mis […]
Show full quote

bash-4.2# losetup -a
/dev/loop0: [2052]:2 (/disk/image), offset 128
bash-4.2# mount /disk/image /dev/loop0
NTFS signature is missing.
Failed to mount '/dev/loop1': Invalid argument
The device '/dev/loop1' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?
bash-4.2# mount /dev/loop0 /mnt
NTFS signature is missing.
Failed to mount '/dev/loop0': Invalid argument
The device '/dev/loop0' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?
bash-4.2#

Yet when I run the image inside DOSEMU and do dir C: it shows an empty folder and the correct size as expected (instead of a media error) so somehow there is a valid dos partition when mkfatimage16 generates the image file.

I tried more things:

bash-4.2# mount /dev/loop0 -o loop=/dev/loop0,offset=128 /mnt mount: stolen loop=/dev/loop0 bash-4.2# mount /disk/image -o loop= […]
Show full quote

bash-4.2# mount /dev/loop0 -o loop=/dev/loop0,offset=128 /mnt
mount: stolen loop=/dev/loop0
bash-4.2# mount /disk/image -o loop=/dev/loop0,offset=128 /mnt
NTFS signature is missing.
Failed to mount '/dev/loop0': Invalid argument
The device '/dev/loop0' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?
bash-4.2#

I am running

root@openmediavault:~# cat /etc/debian_version
10.10
root@openmediavault:~# uname -a
Linux openmediavault 5.10.0-0.bpo.7-amd64 #1 SMP Debian 5.10.40-1~bpo10+1 (2021-06-04) x86_64 GNU/Linux

If I do not specify a specific loopX device, losetup fails :

 root@openmediavault:~#  losetup /dev/loop /home/bob/testhdd2 -o 128
losetup: /dev/loop: failed to set up loop device: No such file or directory
root@openmediavault:~# losetup -l
root@openmediavault:~#

If I specify a specific loopX device, such as loop0, losetup succeeds even if I previously unload the loop module (though if I manually unload the loop module, I sometimes need to run losetup a second time for the loop module to reload succesfully and for losetup to succeed) :

root@openmediavault:~# modprobe -r loop
root@openmediavault:~# lsmod | egrep loop
root@openmediavault:~# losetup /dev/loop0 /home/bob/testhdd2 -o 128
losetup: /home/bob/testhdd2: failed to set up loop device: Resource temporarily unavailable
root@openmediavault:~# losetup -l
root@openmediavault:~# losetup /dev/loop0 /home/bob/testhdd2 -o 128
losetup: /home/bob/testhdd2: Warning: file does not fit into a 512-byte sector; the end of the file will be ignored.
root@openmediavault:~# losetup -l
NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE DIO LOG-SEC
/dev/loop0 0 128 0 0 /home/bob/testhdd2 0 512
root@openmediavault:~# lsmod | egrep loop
loop 40960 1
root@openmediavault:~# mount /dev/loop0 /mnt/testhdd2
root@openmediavault:~# ls -l /mnt/testhdd2
total 25252
-rwxr-xr-x 1 root root 25428012 Jul 23 02:23 audiodump.wav
-rwxr-xr-x 1 root root 212992 Jul 23 03:28 comcom32.exe
-rwxr-xr-x 1 root root 212992 Jul 23 03:28 command.com
drwxr-xr-x 2 root root 2048 Jul 23 03:28 tmp

I can also do it in a single command , such as "mount -o loop,offset=128 /home/bob/testhdd2 /mnt/testhdd2" , which will
a) modprobe loop module (if not already loaded)
b) automatically setup a loop device
c) mount the the filesystem through the loop device

See example below :

root@openmediavault:~# umount /mnt/testhdd2
root@openmediavault:~# losetup -D
root@openmediavault:~# modprobe -r loop
root@openmediavault:~# ls -l /dev/loop*
crw-rw---- 1 root disk 10, 237 Jul 23 19:02 /dev/loop-control
root@openmediavault:~# mount -o loop,offset=128 /home/bob/testhdd2 /mnt/testhdd2
root@openmediavault:~# ls -l /mnt/testhdd2
total 25252
-rwxr-xr-x 1 root root 25428012 Jul 23 02:23 audiodump.wav
-rwxr-xr-x 1 root root 212992 Jul 23 03:28 comcom32.exe
-rwxr-xr-x 1 root root 212992 Jul 23 03:28 command.com
drwxr-xr-x 2 root root 2048 Jul 23 03:28 tmp
root@openmediavault:~# df -h /mnt/testhdd2
Filesystem Size Used Avail Use% Mounted on
/dev/loop0 128M 25M 104M 20% /mnt/testhdd2

Three questions :

1) What does lsmod | egrep -i fat return on your end ?
On mine :

root@openmediavault:~# lsmod | egrep -i fat
vfat 20480 2
fat 86016 1 vfat

2) What does running "umount /mnt ; modprobe loop ; losetup -D ; mount -t vfat -o loop,offset=128 /disk/image /mnt" return on your end ?

3) What distro are your running ?

I am particularly curious as to why it tries to mount the partition as NTFS on your end and wonder what will happen if vfat is specified as a filesystem type on the mount command, assuming vfat kernel module is loaded .

EDIT : Assuming you can zip it to a small enough size, can you share the hd image file ( /disk/image) you initially created ?

Reply 9 of 24, by darry

User metadata
Rank l33t++
Rank
l33t++

I retraced my steps exactly, to be sure I am sharing exactly what I did and what works for me . I tried many things along the way and may have previously pasted some inaccurate info, so I wanted to restart from scratch to be sure .
For this work on my end partition=0 needs to be set in etc/mtools.conf for the disk image in question.
I am including a gzipped copy of the image file I freshly re-created from scratch and onto which I have copied 2 small random files .

Filename
testhdd2.gz
File size
348.81 KiB
Downloads
44 downloads
File license
Public domain

Exact steps to create, copy files to and mount my test image and then unmount it, undefine the loop device and loop/remount it in a single command .

root@openmediavault:~# losetup -l
root@openmediavault:~# cat /etc/mtools.conf | egrep testhdd2
drive o: file="/home/bob/testhdd2" partition=0 offset=128 fat_bits=16
root@openmediavault:~# mkfatimage16 -k 131072 -p -f /home/bob/testhdd2
root@openmediavault:~# mdir o:
init O: non DOS media
Cannot initialize 'O:'
root@openmediavault:~# mformat o:
root@openmediavault:~# mdir o:
Volume in drive O has no label
Volume Serial Number is 6D10-77C2
Directory for O:/

No files
133 904 384 bytes free

root@openmediavault:~# mcopy /usr/local/share/comcom32/* o:
root@openmediavault:~# mdir o:
Volume in drive O has no label
Volume Serial Number is 6D10-77C2
Directory for O:/

comcom32 exe 212992 2021-07-23 20:01
command com 212992 2021-07-23 20:01
2 files 425 984 bytes
133 478 400 bytes free

root@openmediavault:~# losetup /dev/loop0 /home/bob/testhdd2 -o 128
losetup: /home/bob/testhdd2: Warning: file does not fit into a 512-byte sector; the end of the file will be ignored.
root@openmediavault:~# fdisk -l /dev/loop0
Disk /dev/loop0: 128.3 MiB, 134507520 bytes, 262710 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
/dev/loop0p1 * 0 262079 262080 128M 6 FAT16
root@openmediavault:~# fsck.vfat -v /dev/loop0
fsck.fat 4.1 (2017-01-24)
Checking we can access the last sector of the filesystem
Boot sector contents:
System ID "MTOO4023"
Media byte 0xf0 (5.25" or 3.5" HD floppy)
512 bytes per logical sector
2048 bytes per cluster
1 reserved sector
First FAT starts at byte 512 (sector 1)
2 FATs, 16 bit entries
131072 bytes per FAT (= 256 sectors)
Root directory starts at byte 262656 (sector 513)
512 root directory entries
Data area starts at byte 279040 (sector 545)
65383 data clusters (133904384 bytes)
63 sectors/track, 16 heads
0 hidden sectors
262080 sectors total
Checking for unused clusters.
/dev/loop0: 2 files, 208/65383 clusters
root@openmediavault:~# mount /dev/loop0 /mnt/testhdd2
root@openmediavault:~# ls -l /mnt/testhdd2
total 416
-rwxr-xr-x 1 root root 212992 Jul 23 16:01 comcom32.exe
-rwxr-xr-x 1 root root 212992 Jul 23 16:01 command.com
root@openmediavault:~# umount /mnt/testhdd2
root@openmediavault:~# losetup -D
root@openmediavault:~# losetup -l
root@openmediavault:~# mount -o loop,offset=128 /home/bob/testhdd2 /mnt/testhdd2
root@openmediavault:~# df -h /mnt/testhdd2
Filesystem Size Used Avail Use% Mounted on
/dev/loop0 128M 416K 128M 1% /mnt/testhdd2
root@openmediavault:~# ls -l /mnt/testhdd2
total 416
-rwxr-xr-x 1 root root 212992 Jul 23 16:01 comcom32.exe
-rwxr-xr-x 1 root root 212992 Jul 23 16:01 command.com
root@openmediavault:~# losetup -l
NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE DIO LOG-SEC
/dev/loop0 0 128 1 0 /home/bob/testhdd2 0 512

Reply 10 of 24, by mike_canada

User metadata
Rank Member
Rank
Member

Darry, you must have a different kernel.

I remove my existing disk image and then recreate it.
This is how I make the disk image (my first steps):

mkfatimage16 -P -k 32767 -f /disk/image

I then edit etc/mtools.conf so these entries exist:

drive c: file="/disk/image" partition=1 offset=128 fat_bits=16
drive d: file="/disk/image" partition=0 offset=128 fat_bits=16

I then tried directory listings on both drives, and it works for C but not D...

bash-4.2# mdir c: Volume in drive C has no label Volume Serial Number is 1234-5678 Directory for C:/ […]
Show full quote

bash-4.2# mdir c:
Volume in drive C has no label
Volume Serial Number is 1234-5678
Directory for C:/

No files
33 470 464 bytes free

bash-4.2# mdir d:
init D: non DOS media
Cannot initialize 'D:'

Exact steps to create, copy files to and mount my test image and then unmount it, undefine the loop device and loop/remount it in a single command .

As for....

root@openmediavault:~# losetup -l

there is no "l" option in my losetup program. The options are:

Usage:
losetup [options] [<loopdev>]
losetup [options] -f | <loopdev> <file>

Options:
-a, --all list all used devices
-d, --detach <loopdev> [...] detach one or more devices
-D, --detach-all detach all used devices
-f, --find find first unused device
-c, --set-capacity <loopdev> resize device
-j, --associated <file> list all devices associated with <file>

-e, --encryption <type> enable encryption with specified <name/num>
-o, --offset <num> start at offset <num> into file
--sizelimit <num> device limited to <num> bytes of the file
-p, --pass-fd <num> read passphrase from file descriptor <num>
-P, --partscan create partitioned loop device
-r, --read-only setup read-only loop device
--show print device name after setup (with -f)
-v, --verbose verbose mode

-h, --help display this help and exit
-V, --version output version information and exit

ok so I added fat_bits=16 parameter in my config but that makes no difference.

now mformat is different. if I specify C drive, it returns with nothing, but if I specify D drive, it gives me a geometry issue as follows:

bash-4.2# mformat d: mformat: Unknown geometry (You must tell the complete geometry of the disk, either in /etc/mtools.conf or […]
Show full quote

bash-4.2# mformat d:
mformat: Unknown geometry (You must tell the complete geometry of the disk,
either in /etc/mtools.conf or on the command line)
bash-4.2# mformat c:
bash-4.2#

After format, I ran the mdir on both drives, and on the C drive the contents appear....

bash-4.2# mdir c: Volume in drive C has no label Volume Serial Number is 5B99-7A26 Directory for C:/ […]
Show full quote

bash-4.2# mdir c:
Volume in drive C has no label
Volume Serial Number is 5B99-7A26
Directory for C:/

No files
33 287 680 bytes free

bash-4.2# mdir d:
init D: non DOS media
Cannot initialize 'D:'

I can copy files to mtool's C drive but not D drive. Perhaps its strange, but my mtools wants partition=1 to make basic mtools functions on the image to work.

root@openmediavault:~# losetup /dev/loop0 /home/bob/testhdd2 -o 128
losetup: /home/bob/testhdd2: Warning: file does not fit into a 512-byte sector; the end of the file will be ignored.

I didn't get this warning.

root@openmediavault:~# fdisk -l /dev/loop0 Disk /dev/loop0: 128.3 MiB, 134507520 bytes, 262710 sectors Units: sectors of 1 * 512 […]
Show full quote

root@openmediavault:~# fdisk -l /dev/loop0
Disk /dev/loop0: 128.3 MiB, 134507520 bytes, 262710 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
/dev/loop0p1 * 0 262079 262080 128M 6 FAT16

This is where it gets odd. I did fdisk -l and I get nothing returned.

root@openmediavault:~# fsck.vfat -v /dev/loop0

I tried this and I get different results:

dosfsck 3.0.11 (24 Dec 2010)
dosfsck 3.0.11, 24 Dec 2010, FAT32, LFN
Got 0 bytes instead of 512 at 0

What versions of the programs are you using? Maybe my versions are bad.

Reply 11 of 24, by darry

User metadata
Rank l33t++
Rank
l33t++

What distro/release are you running ?

I have a run-of-the-mill current Debian . I was unable to get 14-year-old DOSEmu 1.40 to build successfully (either 32-bit or 64-bit), so I built the current alpha release of DOSEmu2 to get mkfatimage16 (which I doubt has changed much in the last 28 years). I also built fdpp , djgpp-gcc and comcom32.exe/command.com to have a working command interpreter .

Here is the version info for my setup :

Distro and kernel :

root@openmediavault:~# cat /etc/debian_version
10.10
root@openmediavault:~# uname -a
Linux openmediavault 5.10.0-0.bpo.7-amd64 #1 SMP Debian 5.10.40-1~bpo10+1 (2021-06-04) x86_64 GNU/Linux
root@openmediavault:~#

Executables :

root@openmediavault:~# losetup --version
losetup from util-linux 2.33.1

root@openmediavault:~# mkfatimage16
Usage:
mkfatimage [-b bsectfile] [{[-t tracks] [-h heads] | -k Kbytes}]
[-l volume-label] [-f outfile] [-p ] [ -r ] [file...]
DOSEMU$▒▒▒1▒ؽ|▒Ѝf▒▒▒▒▒▒▒▒▒"|▒▒؎▒1▒▒▒▒▒▒ut▒▒▒▒▒}r▒▒▒no active partition found
▒▒▒▒read error while reading drive
▒▒▒partition signature != 55AA
▒▒r▒&▒>▒}U▒uω▒▒|▒▒U▒A▒r2▒▒U▒u,▒▒t'▒|▒▒▒|▒E
▒▒|▒B▒▒|▒ø▒|▒M▒u▒▒1۴▒^▒V<u▒▒ U▒▒<▒IBM 3 3 ▒▒)xV4 FAT12 ▒▒P▒[▒▒▒1۬▒▒▒▒▒▒▒▒▒

the Linux DOS Emulator, 4/1/93
Version 0.49

Robert Sanders
gt8134b@prism.gatech.edu

See README.first for instructions

press any key to return to Linux...

root@openmediavault:~# mdir --version
mdir (GNU mtools) 4.0.23
configured with the following options: enable-xdf disable-vold disable-new-vold disable-debug enable-raw-term

root@openmediavault:~# mformat --version
mformat (GNU mtools) 4.0.23
configured with the following options: enable-xdf disable-vold disable-new-vold disable-debug enable-raw-term

root@openmediavault:~# mcopy --version
mcopy (GNU mtools) 4.0.23
configured with the following options: enable-xdf disable-vold disable-new-vold disable-debug enable-raw-term

root@openmediavault:~# fdisk --version
fdisk from util-linux 2.33.1

Reply 12 of 24, by darry

User metadata
Rank l33t++
Rank
l33t++

Just a few thoughts . Sorry if any of this seems obvious and has already been verified or is not possible/relevant due to a specific point that I have not considered in your use case .

Are fat/vfat kernel modules loaded on your system ( lsmod | egrep -i fat) ?

Why not use separate files for the C and D images with partition=0 for each in mtools.conf ?

When the time comes to convert to an actual non DOSEMU partition image, all you need to do is remove the 128-byte dosemu header and you have a raw partition image that you can cat anywhere you need to . Actually, it might be worth creating a non DOSEMU image using DD , formatting it and mounting it via loop just to see if that works (without involving DOSEMU, mkfatimage16 or mtools) .

root@openmediavault:~#  dd if=/dev/zero of=testhdd iflag=fullblock bs=1M count=32 && sync
32+0 records in
32+0 records out
33554432 bytes (34 MB, 32 MiB) copied, 0.05366 s, 625 MB/s

root@openmediavault:~# mkfs.vfat testhdd
mkfs.fat 4.1 (2017-01-24)

root@openmediavault:~# fsck.fat -v testhdd
fsck.fat 4.1 (2017-01-24)
Checking we can access the last sector of the filesystem
Boot sector contents:
System ID "mkfs.fat"
Media byte 0xf8 (hard disk)
512 bytes per logical sector
2048 bytes per cluster
4 reserved sectors
First FAT starts at byte 2048 (sector 4)
2 FATs, 16 bit entries
32768 bytes per FAT (= 64 sectors)
Root directory starts at byte 67584 (sector 132)
512 root directory entries
Data area starts at byte 83968 (sector 164)
16343 data clusters (33470464 bytes)
32 sectors/track, 64 heads
0 hidden sectors
65536 sectors total
Checking for unused clusters.
testhdd: 0 files, 0/16343 clusters

root@openmediavault:~# losetup /dev/loop0 testhdd

root@openmediavault:~# mount /dev/loop0 /mnt

root@openmediavault:~# df -h /mnt/
Filesystem Size Used Avail Use% Mounted on
/dev/loop0 32M 0 32M 0% /mnt

root@openmediavault:~# ls -l /mnt
total 0

root@openmediavault:~#

Reply 13 of 24, by mike_canada

User metadata
Rank Member
Rank
Member
darry wrote on 2021-07-24, 06:19:

Are fat/vfat kernel modules loaded on your system ( lsmod | egrep -i fat) ?

That question just makes me think my computer is even more stranger. Once I executed that command, I got nothing in return, however my hard drive has partitions of different filesystems and one is currently mounted as a fat32 (vfat)

Why not use separate files for the C and D images with partition=0 for each in mtools.conf ?

I was doing some testing. Thing is the dosemu manual states that I should use "partition=1" for mtools.conf to access the image as a drive, and my tests agree with that.

Actually, it might be worth creating a non DOSEMU image using DD , formatting it and mounting it via loop just to see if that works (without involving DOSEMU, mkfatimage16 or mtools) .

Now that part of making an image and making it dos by linux is recognized by linux

When the time comes to convert to an actual non DOSEMU partition image, all you need to do is remove the 128-byte dosemu header and you have a raw partition image that you can cat anywhere you need to .

I'm going to check out dd some more, and if it is that simple, then all I would need to do is copy the entire file minus the 1st 128 bytes

Reply 14 of 24, by mike_canada

User metadata
Rank Member
Rank
Member

ok, so I did managed to trim the first 128 bytes, and ran fdisk and this time, a partition entry appeared, and now I managed to mount it. But when I tried using it in k3B cd writing tool, it wouldn't accept the image.

Somehow I gotta turn this new image that I can mount into a bootable one for CD burning

Reply 15 of 24, by Ringding

User metadata
Rank Member
Rank
Member
mike_canada wrote on 2021-07-24, 07:14:

That question just makes me think my computer is even more stranger. Once I executed that command, I got nothing in return, however my hard drive has partitions of different filesystems and one is currently mounted as a fat32 (vfat)

It can also be compiled in. Better check /proc/filesystems to confirm.

Reply 16 of 24, by darry

User metadata
Rank l33t++
Rank
l33t++
Ringding wrote on 2021-07-24, 08:01:
mike_canada wrote on 2021-07-24, 07:14:

That question just makes me think my computer is even more stranger. Once I executed that command, I got nothing in return, however my hard drive has partitions of different filesystems and one is currently mounted as a fat32 (vfat)

It can also be compiled in. Better check /proc/filesystems to confirm.

Good point . I was going on the assumption that these typically were not compiled into the kernel these days, but they definitely could be on OP's distro . I shouldn't be making assumptions .

Reply 17 of 24, by darry

User metadata
Rank l33t++
Rank
l33t++
mike_canada wrote on 2021-07-24, 07:32:

ok, so I did managed to trim the first 128 bytes, and ran fdisk and this time, a partition entry appeared, and now I managed to mount it. But when I tried using it in k3B cd writing tool, it wouldn't accept the image.

Somehow I gotta turn this new image that I can mount into a bootable one for CD burning

I am not an expert on partition tables, but their structure is at lesst well documented, so I can learn .

How DOSEMU and mkfatimage16 work with that header and how the works with multi partition images is something I have not found clear docs for yet (maybe I should look at source code comments).

When you strip the DOSEMU header, are you able to access/mount the content of both c: and d: partitions outside of DOSEMU/MTOOLS or only the first one ? If you only see the first one, I would imagine that there is still something DOSEMU specific left .

Reply 18 of 24, by mike_canada

User metadata
Rank Member
Rank
Member

I can only mount if I use the correct offset to the partition, but first, I used dd to strip the first 128 bytes off of /disk/image1 to create /disk/image2.

bash-4.2# mount /disk/image2 -o loop /mnt NTFS signature is missing. Failed to mount '/dev/loop0': Invalid argument The device ' […]
Show full quote

bash-4.2# mount /disk/image2 -o loop /mnt
NTFS signature is missing.
Failed to mount '/dev/loop0': Invalid argument
The device '/dev/loop0' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?
bash-4.2# fdisk -l /disk/image2

Disk /disk/image2: 33 MB, 33562112 bytes
4 heads, 17 sectors/track, 963 cylinders, total 65551 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
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/disk/image2p1 * 17 65551 32767+ 4 FAT16 <32M
bash-4.2# mount /disk/image2 -o loop,offset=$((17*512)) /mnt

Reply 19 of 24, by darry

User metadata
Rank l33t++
Rank
l33t++
mike_canada wrote on 2021-07-24, 16:48:

I can only mount if I use the correct offset to the partition, but first, I used dd to strip the first 128 bytes off of /disk/image1 to create /disk/image2.

bash-4.2# mount /disk/image2 -o loop /mnt NTFS signature is missing. Failed to mount '/dev/loop0': Invalid argument The device ' […]
Show full quote

bash-4.2# mount /disk/image2 -o loop /mnt
NTFS signature is missing.
Failed to mount '/dev/loop0': Invalid argument
The device '/dev/loop0' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?
bash-4.2# fdisk -l /disk/image2

Disk /disk/image2: 33 MB, 33562112 bytes
4 heads, 17 sectors/track, 963 cylinders, total 65551 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
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/disk/image2p1 * 17 65551 32767+ 4 FAT16 <32M
bash-4.2# mount /disk/image2 -o loop,offset=$((17*512)) /mnt

What I mean is that, according to

drive c: file="/disk/image" partition=1 offset=128 fat_bits=16
drive d: file="/disk/image" partition=0 offset=128 fat_bits=16

from you mtools.conf , you have two partitions in the /disk/image file . Are you able, after stripping the DOSEMU 128-byte header to create /disk/image2, to mount/access both of these partitions ( image2p1 AND image2p2 ) ? If you can, you might have want to try creating a fresh image with a partition table with 2 primary partitions with sufficient blocks and try to cat each of the image2p1 AND image2p2 partitions (without DOSEMU offset) into the newly created partitions

Something like


# make sure both partitions in /disk/image2 are accessible as loop devices and successfully mountable/readble (but not currently mounted) , assuming you use loop0, you would have
/dev/loop0p1 and /dev/loop0p2


# Create new image, adjust size as needed
root@openmediavault:~# dd if=/dev/zero of=/disk/imagenew iflag=fullblock bs=1M count=64 && sync

# Create 2 type 6 primary partitions with enough block
fdisk /disk/imagenew

# adjust max_part and modprobe loop module and create loop device
losetup /dev/loop1 /disk/imagenew

# cat filesystems into new image
cat /dev/loop0p1 > /dev/loop1p1
cat /dev/loop0p2 > /dev/loop1p2

# get rid of loop devices
losetup -f

# try to use /disk/imagenew instead of /disk/image2