dd and image files



Keywords: dd image file image files .img files device flash bios .exe file

So, here's the plain detailed explanation I would have liked to receive instead of all the nonsense I got.

Let's suppose we have a Linux system and a FreeDOS boot floppy that we want to make available on the net for people who want to flash their BIOS with an .exe file, the only kind provided by the motherboard manufacturer.

On this floppy disk (fd), we have files such as command.com for instance. The Linux cp command could copy them but, unfortunately, since both OS differ in their conception, the files might slightly differ. Besides, in order for the floppy to be used for booting, we'll also need its boot sector and file allocation table (FAT). And it would be so nice to have all the stuff in just one file!

In Linux/Unix, everything is a file: a directory is a file containing a list of files and even devices are refered to as file and it so happens that in the /dev directory, we have a file named fd0 that refers to our floppy disk. (That's the device that's usually mounted on /mnt/floppy in fstab.)

For copying, Linux also offers a utility called dd. This utility copies files bit for bit, no question asked. If dd sees our /dev/fd0 file, it sees the boot sector, the FAT, the files, etc. as just a succession of bits in one file.

So, if you:

dd if=/dev/fd0 of=fdboot.img

(if=input file of=output file)

every single bit of data on the floppy will be copied to the image file, which will allow you to distribute the floppy as a single file. Wherever you copy the file, it will appear as fdboot.img.

Note that you don't even have to mount the floppy to copy it. Countrary to the case for cp, it doesn't even need to be part of your filesystem: the device is accessed directly.

But what if we do the opposite dd operation?

dd if=fdboot.img of=/dev/fd0

Well, exactly the opposite will happen. Every bit of the file will be written to device and you'll get an exact copy of the original floppy.

Whenever building or recomstituting an image file from a 1.44 MB floppy, you'll see:

2880+0 records in
2880+0 records out

That's because each record is 512 bytes long. Since there are 1440 k on the floppy, we have double the records.

This is how dd builds image files and reconstitute their content through a device file.

.



Relevant Pages

  • Re: BIOS upgrading
    ... One interesting way is to create a boot floppy image file, ... and then copy your new BIOS file to it. ... if you mess up your BIOS update, you may not be able to get at the ...
    (Fedora)
  • BIOS upgrade
    ... then link through support until you find an image file ... What you do first is take note of what Bios version you ... Sometimes you just boot off a bootable Floppy (get one ... >Is it possible to clear and edit the BIOS?? ...
    (microsoft.public.windowsxp.hardware)
  • Re: Total Backup without a Floppy Disk
    ... the image file was bigger than 1GB. ... > yes you need a floppy. ... >>way to do this backup with a CD Rom boot disk or some ...
    (microsoft.public.windowsxp.general)
  • Re: Startup disk/CD
    ... how does one create a startup onto a CD? ... Use an image file of a startup floppy, or an actual one if you have a ... floppy drive on the machine you make the CD with, ...
    (microsoft.public.windowsxp.general)
  • Re: XP upgrade now freezes at bootup
    ... Usually the exe file will prompt ... So I will create a boot disk and then use the exe from the ... 2nd floppy within DOS? ... >disk and another floppy with the unzipped AOPEN BIOS file. ...
    (microsoft.public.windowsxp.video)