Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

6 Answers 6

up vote 2 down vote accepted

Sounds like Partimage might be what you are looking for?

share|improve this answer
    
I use Partimage and this is the best way to go. –  M.Rezaei Dec 13 '09 at 11:20
1  
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. –  Geoff Fritz 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

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
share|improve this answer
    
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

I think this could interest You: http://ubuntuforums.org/showthread.php?t=675685

share|improve this answer
1  
For posterity, in case the ubuntuforums link goes down, the answer was to use Clonezilla (or the Windows equivalent) –  Matt Simmons Dec 12 '09 at 13:38

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

share|improve this answer

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

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

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.