Server Fault is a question and answer site for system and network administrators. 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

Is there a way to use 'dd' command to get a hard drive image that ignores the free space on the hard drive?

share|improve this question

migrated from Dec 20 '09 at 0:20

This question came from our site for professional and enthusiast programmers.

Similar question:… – jackem Dec 20 '09 at 8:32

No. dd is a block-by-block copy that ignores content (nothing is ever free, just not yet overwritten). If you want to ignore free space you have to use a logical imaging tool such as Ghost, Acronis or similar.

share|improve this answer
Do you know any command base application to do this? I need this application to run from the live linux. – salman Dec 19 '09 at 16:55
Depending on the filesystem, there may be a utility which understands the filesystem structure and can dump only blocks in use, for example dumpe2fs or xfsdump. – ephemient Dec 19 '09 at 17:25
how use this commands to get backup without the free space? – M.Rezaei Dec 22 '09 at 10:33

As others have pointed out that is not possible with dd. It's a very low level tool and just copies the bitstream from one device to another or file. Partimage however is capable of doing what you're looking for and it supports a long list of file systems. The easiest way to use this is to download the clonezilla livecd. It's a livecd that has wrapped partimage with an easy to use wizard.

share|improve this answer

If you first make sure that the free space on the hard drive is filled with zeros, it's possible to convert the disk image into a sparse file, where the zeros won't take up storage space. Details in an another answer.

share|improve this answer

You need to use file system level utilities that recognise used and free space. One program that uses a nice GUI for accomplishing this is GParted, but there are several GUI and command line tools to copy, resize, and modify file systems.

share|improve this answer

It was my understanding that dd does a bit-by-bit copy, so you'd get free space and all.

So, no. I don't think so.

share|improve this answer

No, dd knows nothing about filesystems so can't tell what parts of the disc are or aren't in use.

If most of the disc that is unused has never been used since a full-format (so is still all zeroes), running the output of dd through gzip will nicely compress it away to nothing, though.

share|improve this answer

Your Answer


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