Accessing Atari hard disk partitions under Linux with mtools
Overview
Atari ST hard drives formatted with standard Atari drivers (such as AHDI or ICD) use non-standard partition table structures in sector 0 that modern desktop operating systems (Linux, Windows, macOS) do not automatically mount.
However, since the underlying filesystems on these partitions are GEMDOS-compatible (standard FAT16 variant), Linux users on can use kernel loop devices paired with mtools to read from and write files directly to these partitions without reformatting the media.
This guide will mainly be used by people using SD cards but it should also work with IDE and SCSI disks.
Prerequisites
You need an SD card reader attached to your Linux computer. Internal or USB should work but internal (/dev/mmcblk*) are preferred.
Debian and Ubuntu users should ensure mtools and util-linux (which provides losetup) are installed.
sudo apt update sudo apt install mtools util-linux
Step-by-Step Guide
Step 1: Identify your SD Card Device
Insert your UltraSatan SD card into your Linux PC. Identify the block device node using lsblk or dmesg.
lsblk
Example output:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 476.9G 0 disk mmcblk0 179:0 0 7.4G 0 disk ├─mmcblk0p1 179:1 0 30.5M 0 part ├─mmcblk0p2 179:2 0 488.3M 0 part └─mmcblk0p3 179:3 0 433.9M 0 part
In this guide, we assume the SD card is located at /dev/mmcblk0. Replace /dev/mmcblk0 with your actual device name.
Step 2: Enable Atari Partition Table Support in Linux
The Linux kernel includes native support for AHDI/ICD partition tables, but partition scanning must be forced when attaching loop devices.
Attach the physical SD card to a loop device and scan for partition slices:
sudo losetup -f -P /dev/sdc
To verify which loop device was assigned, run:
losetup -a
Example output:
/dev/loop0: [0005]:830 (/dev/mmcblk0)
Check if partition sub-nodes were automatically detected:
ls /dev/loop0*
If partitions are found, you will see entries like /dev/loop0p1 (Partition C:), /dev/loop0p2 (Partition D:), etc.
Step 3: Configure mtools Environment
Standard Atari GEMDOS FAT partitions often lack standard modern BIOS Parameter Blocks (BPB). To prevent mtools from throwing alignment or boot-sector check errors, export the following environment variable in your terminal session:
export MTOOLS_SKIP_CHECK=1
Step 4: Accessing Files with mtools
You can now target the loop partition slice (e.g., /dev/loop0p1) using mtools utility commands.
Listing Directory Contents (mdir)
To list files on the first Atari partition (Drive C:):
mdir -i /dev/loop0p2 ::
Copying Files TO the Atari Partition (mcopy)
To copy a local file (e.g., GAME.PRG) into the root folder of the Atari partition:
mcopy -i /dev/loop0p2 GAME.PRG ::
To copy a file into a specific folder on the Atari partition (note double colons ::):
mcopy -i /dev/loop0p2 GAME.PRG ::AUTO/
Copying Files FROM the Atari Partition
To copy a file from the Atari partition back to your Linux host:
mcopy -i /dev/loop0p2 ::README.TXT ./
Creating Directories (mmd)
To create a new directory on the Atari partition:
mmd -i /dev/loop0p2 ::GAMES
Step 5: Safely Detaching the Device
Once file operations are complete, flush disk writes and detach the loop device before removing the SD card.
sync sudo losetup -d /dev/loop0
Troubleshooting
Error: "Device or resource busy" when running losetup
If the kernel had previously automounted parts of the drive, unmount them before running losetup:
sudo umount /dev/mmcblk0*
Error: No partition slices appear under /dev/loop0
If ls /dev/loop0p* returns nothing, your Linux kernel may be missing AHDI partition support in its default build config. As a workaround, you can specify direct byte offsets using parted or fdisk -l /dev/sdc to find the starting sector of partition C: and pass the offset to losetup:
# Example mounting using a known byte offset (e.g., sector 2048 * 512 = 1048576) sudo losetup -f -o 1048576 /dev/mmcblk0
See Also
Linux Disk Commands - Managing ST floppy disks using Linux