Creating and Writing Floppy Disk Images in Linux with dd

Linux dd read write floppy images

This article will show you how to read and write images to floppy disks in Linux – Perfect for vintage computing (MS-DOS, Macintosh, etc.)

I dabble a bit in vintage computing – finding old computers, fixing them up, and getting them back into action – usually for playing games on era-appropriate hardware.

Part of this usually involves re-installing the operating system and loading up software.

This used to be pretty simple – when Windows computers came with floppy disk drives and included the required tools, it was pretty easy to get some MS-DOS software onto a disk ready for use on an older machine.

That, of course, isn’t the case anymore. Modern Windows PCs lack floppy drives and lack the tools for creating boot disks.

Linux to the rescue!

Linux has the required tools built right in, and cheap, compatible USB floppy disk drives are ubiquitous. So within no time at all, you’ll have your vintage PC back in action, like mine below.

Presario D33

The dd Command

The dd command will be used to read and write floppy images.

The full user manual for the dd command can be found by running:

man dd

…but all of the information you need to read and write floppy images is below.

Creating Floppy Disk Images in Linux to Backup Disks

If you have driver disks (which can be hard to track down online) or any other old disks still laying around, it’s worth making a backup before trying to use them – just in case you wear the disk out.

Attach your USB floppy drive with the disk you wish to back up inserted.

Now, we need to find out the path to the newly attached USB floppy drive – run:

sudo fdisk -l

The fdisk command will output a list of storage devices attached to your system. Among them (hopefully last in the list to make it easy to find) will be the device you just plugged in.

We’ll be using the sudo command frequently – many of these tasks require administrative privileges.

Next, use the dd command to read the contents of the filesystem on the floppy device. Note that /dev/sdb should be replaced with the path to the floppy device as identified on your system above:

sudo dd bs=512 count=2880 if=/dev/sdb of=my-image.img

The device names sdb/sdb may differ on your system! Make sure you identify your drive correctly, so you don’t accidentally destroy data.

The dd command has several options which can be specified – above; bs defines the number of bytes to be read or written at a time, the count option defines the number of blocks to be read or written – in this case, we specify enough blocks for a 1.44MB floppy disk. if defines the in file – in this case, the path to the floppy drive device, and of the out file – the name of the image we wish to write to.

Writing Disk Images to Floppy Disks in Linux

Once you’ve read the contents of a disk to an image file (or acquired one online), it can be written to a new disk for use.

*Writing a disk image will destroy anything that’s already on the target disk – make sure that a) you don’t have anything you want to keep on the disk and b) you have identified the correct device on your system as your floppy disk drive, so you don’t accidentally overwrite data on the wrong device!

The following command will read the image my-image.img and write it to the floppy device at /dev/sdb

sudo dd if=my-image.img of=/dev/sdb bs=512 conv=sync ; sync

Formatting a Floppy/Troubleshooting

Floppy disks are flimsy, magnetic storage, unsuitable for long-term (and sometimes even short-term) data preservation. Please don’t put your only copy of anything on a floppy; it could be corrupted at pretty much any moment.

If you keep getting issues while writing a disk image, try the following.

  • Running sudo eject /dev/sdb to force eject the drive
  • Disconnect and reconnect the drive with the disk inserted
  • Reformatting the disk by running mke2fs /dev/sdb
    • Again, make sure you have the right device path before trying to reformat!
    • Once re-formatted, try imaging the disk again.
  • Formatting the disk from your MS-DOS or vintage machine – USB floppy drives don’t do a deep-level format, but older drives from the era will

If you’re having trouble creating an image from an existing disk, the best you can do is try it using a different disk drive or computer.

SHARE:
nv-author-image

Brad Morton

I'm Brad, and I'm nearing 20 years of experience with Linux. I've worked in just about every IT role there is before taking the leap into software development. Currently, I'm building desktop and web-based solutions with NodeJS and PHP hosted on Linux infrastructure. Visit my blog or find me on Twitter to see what I'm up to.

Leave a Reply

Your email address will not be published. Required fields are marked *