[ale] dd and cat

Glenn C. Lasher Jr. critter at wizvax.net
Sat Jun 10 08:37:02 EDT 2000


On Fri, 9 Jun 2000, Ben Phillips wrote:

> If I want to replicate, say, a floppy disk, I can do it with 'cat /dev/fd0 >
> image' followed by repeated instances of 'cat image > /dev/fd0'.
> 
> But the recommended way to do that is usually with 'dd' instead.  Why?  What
> do they do different?

You can also do cp /dev/fd0 image, followed by cp image /dev/fd0 (though
some configurations will ask if you want to overwright fd0).  

The main bonus to dd is that it blocks the data (in 512 byte blocks by
default) and that your floppy drive is a block device.  In my experience,
this is not particularly important for fd0 (floppy driver is fairly
tolerant), but if you write to a tape, for example, instead of floppy, you
should use dd to pad the last record.  For example, to back up my
PostgreSQL databasen, I do this:
	pg_dumpall | dd of=/dev/st0 bs=1024 conv=sync

The of parameter directs it to the tape (a 2.3GB 8mm drive), bs sets the
block size to 1024, and conv=sync causes it to pad out the last block with
nulls before closing the file.



--
Critter at Wizvax.Net
Don't Steal - The government hates competition.
PGP key available at http://www.wizvax.net/critter/pgpkey.html.


--
To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.





More information about the Ale mailing list