dd and image files
- From: TonyTheJavaTiger <TonyTheJavaTiger@xxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 30 Oct 2006 23:42:58 -0500
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.
.
- Follow-Ups:
- Re: dd and image files
- From: Chris F.A. Johnson
- Re: dd and image files
- Prev by Date: Installed Fedora Core 6
- Next by Date: Re: dd and image files
- Previous by thread: Installed Fedora Core 6
- Next by thread: Re: dd and image files
- Index(es):
Relevant Pages
|