Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to get a copy of an HDD that is a real 1:1, I mean not just the filesystem but also the geometry and the partition table and everything in between.

if I'll just use

dd if=/dev/sdb of=/tmp/file

this will generate what I'm looking for ?

share|improve this question
Only if the disk is sane. It will also be inefficient because dd reads only 512 bytes at a time. Add conv=noerror,sync to copy disks with errors (or better use ddrescue) and use bigger block size otherwise to improve performance (or better, use ddrescue) – Stéphane Chazelas Jun 15 '14 at 19:57
up vote 6 down vote accepted

Yes, this should be fine. Be sure to unmount your disk first and make sure there is enough space in the target directory. /tmp is a tmpfs in memory and not on disk on some systems, look at the output of mount to check.

On a root shell you can also simply do:

cat /dev/sdb >/tmp/file
share|improve this answer

Alternatively, just copy it:

cp /dev/sdb /tmp/sdb.img

Please note Stephane's comment below for a potential benefit of using cp.

share|improve this answer
cp --sparse=always with GNU cp could help you save space. – Stéphane Chazelas Jun 15 '14 at 19:59
Will this copy boot loaders and partition tables? – Sparhawk Jun 16 '14 at 5:02
@Sparhawk - cp is at least simpler. You can likely achieve much the same performance and results using dd- and with GNU dd even something akin to --sparse=always - but it will take some tweaking. cp is pretweaked. And yes, you should be able to simply cp the image back over the /dev/ice but any such action will, of course, be completely destructive to whatever was on the /dev/ice before you did. – mikeserv Jun 16 '14 at 5:18
@Sparhawk, a good cp implementation will automatically optimise the block size, so will be faster than dd. Don't use --sparse=always when you copy to a disk though, only when copying to a file. – Graeme Jun 16 '14 at 8:17
@StéphaneChazelas For me, cp --sparse=always created an identical file to dd. I wonder if it works for volumes, but not whole devices? – Sparhawk Jul 13 '14 at 2:33

There is an informative article on the Arch distro wiki here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.