💻 Create a Harddisk Image for Hatari on Linux

➤ Martin Döring, 15th of February 2025

EmuTOS has an integrated Harddisk driver. If you own a real harddisk, normally you are provided with corresponding drivers and tools. There is a couple of software for that, see in the links section below.

But what, if you want to use harddisk images in Hatari with EmuTOS? As of today there is no integrated way to

The following guide will show you how to do all this on Linux, in my case Manjaro Linux.

The fast Lane

Hatari comes with a script which is able to generate a harddisk image file with exactly one Atari compatible partion in it. If this is what you want, just call it like so:

/usr/bin/atari-hd-image 512

Limitations:

If you want more, for example one boot drive and one seperate drive for data, just go on.

Creating a Harddrive Image File

You can easily create a harddisk image file of the size of 512MB with one of these commands on Linux, the first is much faster and spares your harddisk:

fallocate -l 512M hd512mb.img

or

truncate -s 512M hd512mb.img

or

dd if=/dev/zero of=hd512mb.img count=512 bs=1M

So, 512 times 1M will give us a harddisk image of 512 MiB.

Partitioning the Harddisk Image

All Linux tools for partitioning are written in a way, that they can not be used on common files, but only on device files. So the first we will do is to make a device out of our harddisk image file:

sudo losetup --partscan --show --find hd512mb.img

The command will output the new device on linux:

/dev/loop0

Now that we have our pseudo harddisk device, we need to partition it. You could imagine the file as the physical harddisk and the partitions will give us drives, like on DOS or Windows, like C:, D: etc.

You can use different programs for this (fdisk, cfdisk, ...). We will use the graphical cfdisk here:

sudo cfdisk /dev/loop0

First you need to choose to create a "dos" partition table, this is what EmuTOS needs.

Then you see the whole harddisk, but currently there is just unused space. You can navigate the tool with the right and left arrows. Choose "new" and create a new primary partition. When done press T to choose the type 06 to mark our new partition as FAT16 type. FAT16 is the filesystem type which is natively supported by EmuTOS (and TOS).

When done choose save and then quit the tool. If you want to see your success, list the block devices:

lsblk

You will now see the newly created partition(s) on your harddisk image.

NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0         7:0    0     2G  0 loop 
├─loop0p1   259:4    0   512M  0 part 

Formatting the partition(s)

We marked our partition to contain a FAT16 filesystem and now we will create it. This is called "formatting a partition". Modern Linux or Windows systems like to make use of the larger FAT32 filesystem, which is default. So we need to tell our command to use the smaller FAT16 filesystem on our partition:

sudo mkfs.fat -v -F 16 -n "C" /dev/loop0p1 

Now we are done and just need to release our harddisk image from the Linux system:

sudo losetup -D

Use in Hatari

Put your harddrive image file somewhere you like, possibly in a folder with other Atari stuff. Start Hatari and press F12 to show the configuration menu, then choose "hard disks", then ACSI - then the "browse" button in the upper right corner. Choose your new harddisk image and if you like, afterwards choose "boot from harddisk".

Now a new drive C should show up. Well made, congratulations!

Troubleshooting

If you make use of more than one harddisk partition and at the same time you map a GEMDOS drive which mirrors your underlying Linux filesystem, it may happen in Hatari 2.5.0 that your first harddisk drive is overlayed by the GEMDOS drive's content and is not accessable.

But there is a quick fix: Just go in your hatari.cfg and set explicitely the drive letter for your GEMDOS drive, 0=C, 1=D, 2=E... In the following example 4=G, G like GEMDOS:

[HardDisk]
nGemdosDrive = 7

Going further

You can create up to 4 primary partitions in one harddisk image file. If this is not enough, you need to create an extended partition which then can hold a couple of secondary partitions, like so:

Device        Boot  Start     End  Sectors   Size Kn Type
/dev/loop0p1           63 1000061   999999 488,3M  6 FAT16
/dev/loop0p2      1000062 4000058  2999997   1,4G  5 Extended
/dev/loop0p5      1000125 2000060   999936 488,3M  6 FAT16
/dev/loop0p6      2000124 3000059   999936 488,3M  6 FAT16
/dev/loop0p7      3000123 4000058   999936 488,3M  6 FAT16

Links

For EmuTOS you need none of them. But if you want to use an old Atari TOS in Hatari or do not want to use Linux, you possibly am glad to purchase one of the following harddisk drivers/tools:

🌐 HDDRIVER from Dr. Uwe Seimet
🌐 Atari ST hard disk driver SW from Péter Putnik
🌐 Atari's own Harddisk driver (ancient)
🌐 Hatari script for harddisk image file generation

➤ Back
➤ Privacy Information