Yesterday I was searching a way to create and use img files using linux, and found a few simple commands that do the job.
Create a disk image from the phisical drive:
cat /dev/fd0 > imagefile.img
Copy image to the phisical drive:
cat imagefile.img > /dev/fd0
Simple isn’t it? And now the fun part :P
If we need it we can create an empty image and mount it using linux’s loop devices.
Creating the image:
$ dd bs=512 count=2880 if=/dev/zero of=imagefile.img
$ mkfs.msdos imagefile.img
Mounting it:
$ sudo mkdir /media/floppy1/
$ sudo mount -o loop floppy.img /media/floppy1/
Alternatively with a path as suggested by Anders Lennqvist in a comment to this post
Create a disk image from a physical diskette:
cat /dev/fd0 > /path/imagefile.img
Copy the image to a diskette:
cat /path/imagefile.img > /dev/fd0
There’s an even easier way to do this using mkfs.msdos, skipping the need for the dd command. Also, on my system, mkfs.msdos is in the /sbin directory, which is not usually in a user’s path. So, the new command is
Create an empty floppy image of 1.44 MB:
$ /sbin/mkfs.msdos -C /path/imagefile.img 1440
Simple isn’t it? And now the fun part :P
If we need it we can create an empty image-file and mount it using linux’s loop devices.
Creating an empty floppy image: (here 1.44MB)
$ dd bs=512 count=2880 if=/dev/zero of= /path/imagefile.img
Format it:
$ mkfs.msdos /path/imagefile.img
Mounting it:
$ sudo mkdir /media/floppy1/
$ sudo mount -o loop /path/imagefile.img /media/floppy1/
Thank you Anders!
Salena Vorik pointed out here a disk image can be created in an easier way:
There’s an even easier way to do this using mkfs.msdos, skipping the need for the dd command. Also, on my system, mkfs.msdos is in the /sbin directory, which is not usually in a user’s path. So, the new command is
Create an empty floppy image of 1.44 MB:
$ /sbin/mkfs.msdos -C /path/imagefile.img 1440
Thank you Salena!