I want to create image from hard disk without free space (useless space) in linux(ex3 type).

I've been tried to create image with dd command but this command gave us total size of hard disk.

I need data on this hard disk without free space.

thanks a lot.


Sounds like Partimage might be what you are looking for?

  • I use Partimage and this is the best way to go.
    – M.Rezaei
    Dec 13 '09 at 11:20
  • 2
    For a filesystem-agnostic solution, you can fill the filesystem with nulls ("dd if=/dev/zero of=/some/file ; rm /some/file") and then use dd's "conv=sparse" option. The downsides are: 1) This will be less efficient than a tool which knows the filesystem; and 2) so far as I can tell, using anything other than dd's default 512-byte block size will cause this to not work (or at least miss enough sparse space as to be useless), which will dramatically increase the time for dd to do its job. Dec 14 '09 at 1:32
  • @GeoffFritz 3) This won't work when any of the filesystems that the image needs to reside on or be transported via don't support sparse files.
    – cdhowie
    Mar 18 '13 at 21:02
  • no ext4 support tho Jul 20 '18 at 23:23

One option would be to create the file system image as a sparse file. You could first run an utility such as zerofree on your ext3 file system to make sure all free blocks are filled with zeros, and then just image the disk with dd and pipe the image through cp with the --sparse=always option to force it to create a sparse file:

dd if=/dev/whatever | cp --sparse=always /dev/stdin disk.image
  • This is just crazy enough to work. I wouldn't have thought of piping the byte stream through cp. Have you done this before or are you anticipating that it will work?
    – Scott Pack
    Dec 12 '09 at 14:14
  • 1
    I had not actually done anything like this before, but I did test the idea with a dummy ext3 file system image before posting, and it seems to work. If dd had an option to create sparse files, the cp trick would be unnecessary. Apparently such an option was proposed a couple of years ago, but since the man page does not mention it, I assume the patch was not accepted: mail-archive.com/bug-coreutils@gnu.org/msg11795.html
    – jackem
    Dec 13 '09 at 14:59

If you're using LVM, clonezilla is the way to go.


+1 Partimage . The system rescue CD might help if you just want to save something. Plug in a removable drive and/or a network mount once it has booted and write the image to disk.

If you're trying to image an entire drive for transport, don't forget to save the partition table (and the boot sector for a bootable)


I use partimage for get image also this program worke with command.

If you get image by bash script you work with this and dumpe2fs or xfsdump commands.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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