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:
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:
1NTFS signature is missing. 2Failed to mount '/dev/loop1': Invalid argument 3The device '/dev/loop1' doesn't seem to have a valid NTFS. 4Maybe the wrong device is used? Or the whole disk instead of a 5partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?
And dmesg shows these new errors:
1[17242.765605] REISERFS warning (device loop1): sh-2021 reiserfs_fill_super: can not find reiserfs on loop1 2[17242.765691] EXT3-fs (loop1): error: can't find ext3 filesystem on dev loop1. 3[17242.765729] EXT2-fs (loop1): error: can't find an ext2 filesystem on dev loop1. 4[17242.765765] EXT4-fs (loop1): VFS: Can't find ext4 filesystem 5[17242.765821] FAT-fs (loop1): invalid media value (0x00) 6[17242.765824] FAT-fs (loop1): Can't find a valid FAT filesystem 7[17242.765859] FAT-fs (loop1): invalid media value (0x00) 8[17242.765862] FAT-fs (loop1): Can't find a valid FAT filesystem 9[17242.766190] isofs_fill_super: bread failed, dev=loop1, iso_blknum=45, block=90
and running ccd2iso (imagefile) (isofile) gives this error:
1Unrecognized 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.
mike_canadawrote 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:
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:
1NTFS signature is missing. 2Failed to mount '/dev/loop1': Invalid argument 3The device '/dev/loop1' doesn't seem to have a valid NTFS. 4Maybe the wrong device is used? Or the whole disk instead of a 5partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?
And dmesg shows these new errors:
1[17242.765605] REISERFS warning (device loop1): sh-2021 reiserfs_fill_super: can not find reiserfs on loop1 2[17242.765691] EXT3-fs (loop1): error: can't find ext3 filesystem on dev loop1. 3[17242.765729] EXT2-fs (loop1): error: can't find an ext2 filesystem on dev loop1. 4[17242.765765] EXT4-fs (loop1): VFS: Can't find ext4 filesystem 5[17242.765821] FAT-fs (loop1): invalid media value (0x00) 6[17242.765824] FAT-fs (loop1): Can't find a valid FAT filesystem 7[17242.765859] FAT-fs (loop1): invalid media value (0x00) 8[17242.765862] FAT-fs (loop1): Can't find a valid FAT filesystem 9[17242.766190] isofs_fill_super: bread failed, dev=loop1, iso_blknum=45, block=90
and running ccd2iso (imagefile) (isofile) gives this error:
1Unrecognized 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 .
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.
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:~# 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.
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
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
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
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 came across a post just now from stackoverflow.com that states:
1Let's say $IMAGE is set to the path to your image file. You could write a small script by using 2 3fdisk -u sectors -l $IMAGE 4 5to get a list of partitions inside the image. And then use a sequence of 6 7mount -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
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?
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#
If I do not specify a specific loopX device, losetup fails :
1 root@openmediavault:~# losetup /dev/loop /home/bob/testhdd2 -o 128 2losetup: /dev/loop: failed to set up loop device: No such file or directory 3root@openmediavault:~# losetup -l 4root@openmediavault:~# 5
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) :
1root@openmediavault:~# modprobe -r loop 2root@openmediavault:~# lsmod | egrep loop 3root@openmediavault:~# losetup /dev/loop0 /home/bob/testhdd2 -o 128 4losetup: /home/bob/testhdd2: failed to set up loop device: Resource temporarily unavailable 5root@openmediavault:~# losetup -l 6root@openmediavault:~# losetup /dev/loop0 /home/bob/testhdd2 -o 128 7losetup: /home/bob/testhdd2: Warning: file does not fit into a 512-byte sector; the end of the file will be ignored. 8root@openmediavault:~# losetup -l 9NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE DIO LOG-SEC 10/dev/loop0 0 128 0 0 /home/bob/testhdd2 0 512 11root@openmediavault:~# lsmod | egrep loop 12loop 40960 1 13root@openmediavault:~# mount /dev/loop0 /mnt/testhdd2 14root@openmediavault:~# ls -l /mnt/testhdd2 15total 25252 16-rwxr-xr-x 1 root root 25428012 Jul 23 02:23 audiodump.wav 17-rwxr-xr-x 1 root root 212992 Jul 23 03:28 comcom32.exe 18-rwxr-xr-x 1 root root 212992 Jul 23 03:28 command.com 19drwxr-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
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 ?
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 .
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:/
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
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:
1Usage: 2 losetup [options] [<loopdev>] 3 losetup [options] -f | <loopdev> <file> 4 5Options: 6 -a, --all list all used devices 7 -d, --detach <loopdev> [...] detach one or more devices 8 -D, --detach-all detach all used devices 9 -f, --find find first unused device 10 -c, --set-capacity <loopdev> resize device 11 -j, --associated <file> list all devices associated with <file> 12 13 -e, --encryption <type> enable encryption with specified <name/num> 14 -o, --offset <num> start at offset <num> into file 15 --sizelimit <num> device limited to <num> bytes of the file 16 -p, --pass-fd <num> read passphrase from file descriptor <num> 17 -P, --partscan create partitioned loop device 18 -r, --read-only setup read-only loop device 19 --show print device name after setup (with -f) 20 -v, --verbose verbose mode 21 22 -h, --help display this help and exit 23 -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
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 :
1Distro and kernel : 2 3root@openmediavault:~# cat /etc/debian_version 410.10 5root@openmediavault:~# uname -a 6Linux openmediavault 5.10.0-0.bpo.7-amd64 #1 SMP Debian 5.10.40-1~bpo10+1 (2021-06-04) x86_64 GNU/Linux 7root@openmediavault:~# 8 9Executables : 10 11root@openmediavault:~# losetup --version 12losetup from util-linux 2.33.1 13 14root@openmediavault:~# mkfatimage16 15Usage: 16 mkfatimage [-b bsectfile] [{[-t tracks] [-h heads] | -k Kbytes}] 17 [-l volume-label] [-f outfile] [-p ] [ -r ] [file...] 18DOSEMU$▒▒▒1▒ؽ|▒Ѝf▒▒▒▒▒▒▒▒▒"|▒▒؎▒1▒▒▒▒▒▒ut▒▒▒▒▒}r▒▒▒no active partition found 19▒▒▒▒read error while reading drive 20▒▒▒partition signature != 55AA 21▒▒r▒&▒>▒}U▒uω▒▒|▒▒U▒A▒r2▒▒U▒u,▒▒t'▒|▒▒▒|▒E 22▒▒|▒B▒▒|▒ø▒|▒M▒u▒▒1۴▒^▒V<u▒▒ U▒▒<▒IBM 3 3 ▒▒)xV4 FAT12 ▒▒P▒[▒▒▒1۬▒▒▒▒▒▒▒▒▒ 23 24 the Linux DOS Emulator, 4/1/93 25 Version 0.49 26 27 Robert Sanders 28 gt8134b@prism.gatech.edu 29 30 See README.first for instructions 31 32 press any key to return to Linux... 33 34root@openmediavault:~# mdir --version 35mdir (GNU mtools) 4.0.23 36configured with the following options: enable-xdf disable-vold disable-new-vold disable-debug enable-raw-term 37 38root@openmediavault:~# mformat --version 39mformat (GNU mtools) 4.0.23 40configured with the following options: enable-xdf disable-vold disable-new-vold disable-debug enable-raw-term 41 42root@openmediavault:~# mcopy --version 43mcopy (GNU mtools) 4.0.23 44configured with the following options: enable-xdf disable-vold disable-new-vold disable-debug enable-raw-term 45 46root@openmediavault:~# fdisk --version 47fdisk from util-linux 2.33.1
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) .
1root@openmediavault:~# dd if=/dev/zero of=testhdd iflag=fullblock bs=1M count=32 && sync 232+0 records in 332+0 records out 433554432 bytes (34 MB, 32 MiB) copied, 0.05366 s, 625 MB/s 5 6root@openmediavault:~# mkfs.vfat testhdd 7mkfs.fat 4.1 (2017-01-24) 8 9root@openmediavault:~# fsck.fat -v testhdd 10fsck.fat 4.1 (2017-01-24) 11Checking we can access the last sector of the filesystem 12Boot sector contents: 13System ID "mkfs.fat" 14Media byte 0xf8 (hard disk) 15 512 bytes per logical sector 16 2048 bytes per cluster 17 4 reserved sectors 18First FAT starts at byte 2048 (sector 4) 19 2 FATs, 16 bit entries 20 32768 bytes per FAT (= 64 sectors) 21Root directory starts at byte 67584 (sector 132) 22 512 root directory entries 23Data area starts at byte 83968 (sector 164) 24 16343 data clusters (33470464 bytes) 2532 sectors/track, 64 heads 26 0 hidden sectors 27 65536 sectors total 28Checking for unused clusters. 29testhdd: 0 files, 0/16343 clusters 30 31root@openmediavault:~# losetup /dev/loop0 testhdd 32 33root@openmediavault:~# mount /dev/loop0 /mnt 34 35root@openmediavault:~# df -h /mnt/ 36Filesystem Size Used Avail Use% Mounted on 37/dev/loop0 32M 0 32M 0% /mnt 38 39root@openmediavault:~# ls -l /mnt 40total 0 41 42root@openmediavault:~#
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
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
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.
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 .
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 .
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
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
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
1 2# 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 3/dev/loop0p1 and /dev/loop0p2 4 5 6# Create new image, adjust size as needed 7root@openmediavault:~# dd if=/dev/zero of=/disk/imagenew iflag=fullblock bs=1M count=64 && sync 8 9# Create 2 type 6 primary partitions with enough block 10fdisk /disk/imagenew 11 12# adjust max_part and modprobe loop module and create loop device 13losetup /dev/loop1 /disk/imagenew 14 15# cat filesystems into new image 16cat /dev/loop0p1 > /dev/loop1p1 17cat /dev/loop0p2 > /dev/loop1p2 18 19# get rid of loop devices 20losetup -f 21 22# try to use /disk/imagenew instead of /disk/image2 23