7

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.

5 Answers 5

5

Sounds like Partimage might be what you are looking for?

4
  • I use Partimage and this is the best way to go.
    – M.Rezaei
    Dec 13, 2009 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, 2009 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, 2013 at 21:02
  • no ext4 support tho Jul 20, 2018 at 23:23
6

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
2
  • 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, 2009 at 14:14
  • 2
    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/[email protected]/msg11795.html
    – jackem
    Dec 13, 2009 at 14:59
1

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

0

+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)

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .