This post leverages support for Atari Hard Disk Interface Partition (AHDI) partition tables in the Linux kernel, activated by default in Debian,
and in the parted partition editor.
Accessing the content of a partition using a user mounted loop device
This is the easiest procedure and should be tried to first.
Depending if your Linux kernel has support for AHDI partition tables, and the size of the FAT system on the partition, this procedure might not work. In that case, try the procedure using mtools further below.
Attach a disk image called hd80mb.image to a loop device:
$ udisksctl loop-setup --file hd80mb.image
Mapped file hd80mb.image as /dev/loop0
Notice how the kernel detected the partition table:
$ dmesg | grep loop0
[160892.151941] loop0: detected capacity change from 0 to 164138
[160892.171061] loop0: AHDI p1 p2 p3 p4
Inspect the block devices created for each partition:
$ lsblk | grep loop0
If the partitions are not already mounted by udisks2 under /media/, mount them manually:
$ sudo mount /dev/loop0p1 /mnt/
$ ls /mnt/
SHDRIVER.SYS
When you are finished copying data, unmount the partition, and detach the loop device.
$ sudo umount /mnt
$ udisksctl loop-delete --block-device /dev/loop0
Accessing the content of a partition using mtools and parted
This procedure uses the mtools package and the support for the AHDI partition scheme in the parted partition editor.
Display the partition table, with partitions offsets in bytes:
$ parted st_mint-1.5.img -- unit B print
...
Partition Table: atari
Disk Flags:
Number Start End Size Type File system Flags
1 1024B 133170175B 133169152B primary boot
2 133170176B 266339327B 133169152B primary
3 266339328B 399508479B 133169152B primary
4 399508480B 532676607B 133168128B primary
Set some Atari-friendly mtools options:
$ export MTOOLS_SKIP_CHECK=1
$ export MTOOLS_NO_VFAT=1
List the content of the partition, passing as parameter the offset in bytes of the partition: For instance here we are interested in the second partition, and the parted output above indicates that this partition starts at byte offset 133170176 in the disk image.
$ mdir -s -i st_mint-1.5.img@@133170176
Volume in drive : has no label
Directory for ::/
demodata 2024-08-27 11:43
1 file 0 bytes
Directory for ::/demodata
We can also use the command mcopy with a similar syntax to copy data from and to the disk image.
For instance we copy a file named file.zip to the root directory of the second partition:
$ mcopy -s -i st_mint-1.5.img@@133170176 file.zip ::
Recompiling mtools to access large partitions
With disk images having large AHDI partitions (well considered large in 1992 …), you might encounter the error
mdir -s -i cecile-falcon-singlepart-1GB.img@@1024
init: sector size too big
Cannot initialize '::'
This error is caused by the non-standard large logical sectors that the TOS uses for large FAT partitions (see the Atari Hard Disk Filesystem reference on page 41, TOS partitions size)
We can inspect the logical sector size using fsck tools:
$ udiskctl loop-setup --file cecile-falcon-singlepart-1GB.img
$ sudo fsck.fat -Anv /dev/loop0p1
fsck.fat 4.2 (2021-01-31)
...
Media byte 0xf8 (hard disk)
16384 bytes per logical sector
To access the partition, you need to patch mtools, so that it supports a logical sector size of 16384 bytes. For this
you need to change the MAX_SECTOR macro from 8192 to 16384 in msdos.h in the mtools distribution and recompile.
A rebuilt mtools is then able to access the partition:
$ /usr/local/bin/mdir -s -i cecile-falcon-singlepart-1GB.img@@1024
Volume in drive : has no label
Directory for ::/
CECILE SYS 8462 1998-03-27 22:42
NEWDESK INF 804 2024-09-09 9:23
2 files 9 266 bytes
1 072 463 872 bytes free
The largest possible logical sector size according to the Microsoft FAT specification is 4096, see
BPB_BytsPerSec in https://academy.cba.mit.edu/classes/networking_communications/SD/FAT.pdf
Now on an Atari partition this value may rise to 16384 for larger partitions, with the results that these partitions cannot be mounted on Linux, which respects the FAT specification defined maximum, see https://github.com/torvalds/linux/blob/fc033cf25e612e840e545f8d5ad2edd6ba613ed5/fs/fat/inode.c#L1440
LikeLike