[TriLUG] cp of /dev hangs, but not tar
robdale at gmail.com
Tue Jun 19 20:35:15 EDT 2007
On 6/19/07, Joseph Mack NA3T <jmack at wm7d.net> wrote:
> On Tue, 19 Jun 2007, Michael Tharp wrote:
> > No, but there are plenty of finitely-sized device nodes that contain
> > useful data. For example. you could `cp --copy-contents /dev/cdrom
> > foobar.iso`, although for this purpose I usually utilize dd.
> OK so cp can do the same job as dd (under the right
> circumstances). Why do you "usually" use dd? Is there some
> other wrinkle?
dd gives you much more control at the byte level.
Things I've found it useful for...
- copying the partition table before making changes
dd if=/dev/sda of=part.bak bs=512 count=1
- wipe the MBR
dd if=/dev/zero of=/dev/sda bs=446 count=1
- making empty files, as in preparation for a filesystem or swap file
dd if=/dev/zero of=encrypted.fs bs=1G count=1
- wiping devices (before fancy data destroyers came along)
dd if=/dev/urandom of=/dev/sda
- extracting pieces from files, in particular proprietary binary files
dd if=foo.dat of=data.interesting skip=4 bs=32 count=128
- copying filesystems
- reading around bad blocks
More information about the TriLUG