![]() |
(on Wikipedia)
https://www.gnu.org/software/coreutils/
A ubiquitous byte-copying tool.
I use this for copying disks, partitions and ISOs.
-
Part of GNU's "coreutils"
-
To try - http://dcfldd.sourceforge.net/ -- an enhanced version of GNU dd with features useful for forensics and security.
- Likely abandoned, as it was last updated 10 years ago.
- 2020-01-09 - 8.26 on Debian 9.9.0-i386-xfce-CD-1
- 2016-03-28 - 8.21 on Slackware 14.1
- 2016-03-26 - 8.21 on Lubuntu 14.04.4 LTS
-
As
dd
is part of coreutils, and coreutils is included with almost every Linux distribution, I've had it for a long time.
Checking dd progress ∞
No, don't bother to use that specialized piece of software, or other dd.
1) Begin your dd
2) In another terminal, run
\sudo \clear \watch -n5 '\sudo kill -USR1 $( \pgrep ^dd )'
watch
and pgrep
should be found in most places. sudo
in most places too. If they don't exist, it should still be doable to do:
\killall -USR1 dd
If you don't have watch
, you can do:
until [ 1 = 0 ]; do \killall -USR1 dd; sleep 10 ; done
Testing a device's speed ∞
Tested for USB sticks, but these should work with disks or whatever other storage.
Reading ∞
This is safe. It will not create any files or overwrite any data.
1) Begin your dd
\sudo \dd bs=1M count=1024 if=/dev/sdx of=/dev/null
2) In another terminal, run
\sudo \clear \watch -n5 '\sudo kill -USR1 $( \pgrep ^dd )'
Give it some time, and it will start giving a consistent speed.
Writing (DOES NOT WORK) ∞
-
TODO - this doesn't work, because the system will do write caching.
- I know about dropping caches, but investigate this some more.
- https://www.binarytides.com/linux-test-drive-speed/
- I know about dropping caches, but investigate this some more.
This is not safe! It will overwrite a drive!
-
For a safer thing to do, mount the device and point your dd
of=
to some file on a partition on that device.
1) Begin your dd
\sudo \dd bs=1M count=1024 if=/dev/zero of=/dev/sdx
2) In another terminal, run
\sudo \clear \watch -n5 '\sudo kill -USR1 $( \pgrep ^dd )'
Give it some time, and it will start giving a consistent speed.
Don't dd an entire drive ∞
I believe this is what I did:
dd if=/dev/sda of=/dev/sdb
- turn off sdb
- boot into sda
- auto-mount partitions from sda
- turn on sdb
-
now \df will report things mounted from sdb
It would make more sense if I had sdb
on when I booted up, but I'm certain that was not the case.
This is because the dd
also cloned the UUIDs. That's very very bad.
Now I have leftovers from sdb
presumed to be mounted, but they're actually sda
! I can turn off sdb
and there's no change, and I can read/write from my supposedly-sdb
-mounted partition. Yeargh.
This did "do something", but did not change the output of df
:
\mount -oremount /dev/sdx1
Fiddling with inserting/removing USB stick seems to have resolved it. Turning the drive on assigns it to /dev/sdc
now.
Copying an MBR from one drive to another ∞
source='/dev/sda' target='/dev/sdb' \dd \ if="$source" \ of="$target" \ bs=446 \ count=1
Last updated 2020-06-16 at 13:16:35
style update
Added "Copying an MBR from one drive to another"