Some questions on using did command to image
I know the dd command can make a bit-by-bit clone. I know it can also make an image. The image should avoid copying unused blocks therefore that is what I want to use.
So, here are my questions: 1) What command line syntax would I use to make the dd image and compress it at the same time? 2) What command line syntax would I use to uncompress and restore the dd image at the same time? 3) What limitations regarding files system type (ext, nfts, fat, etc) and what limitations regarding hard drive size (both source and destination) do I face with this approach? This looks like it has potential but the command line is very scary. Any insight or resources would be appreciated. Thank you. |
dd is not the most appropriate tool for this task because it has no way of determining which blocks are unused. To do that, you would need something else that can analyze the file system and create a list of blocks to save. I don't know how to do that, but I would like to find out.
However, if you insist on using dd, one simple approach would begin by filling the unused space with zeroes. Example: Code:
dd if=/dev/zero of=bigfile If you execute dd and gzip as two consecutive commands, the destination would have to be large enough to temporarily hold both the uncompressed image and the compressed image. If you pipe the output of dd into gzip, you eliminate the need for temporary storage of the uncompressed image. Example: Code:
dd if=/dev/sda1 | gzip - > dd_image_sda1.gz # to make the dd image and compress it Quote:
|
let's take 1 step back:
what are you trying to achieve with that? |
To simply answer the questions:
There is no way to avoid copying unused blocks using dd. It creates a bit-by-bit copy. That includes all blocks, of course. All you can do is fill the empty space with zeroes, so that the compressed image will be small (the zeroes compress very well to almost nothing). See the example by beryllos. 1.) Code:
dd if=/dev/sda conv=sync,noerror bs=64K | gzip -c > /mnt/sdb1/sda.img.gz Code:
gunzip -c /mnt/sdb1/sda.img.gz | dd of=/dev/sda 3.) There are no limitations on filesystems at all - dd does a bit by bit copy and does not care at all about filesystems. The target must be of equal or larger size than the original. A smaller target disk (where you want to restore to) is not possible with this. I lifted the info from here and have indeed actually successfully used it multiple times: https://wiki.archlinux.org/index.php/disk_cloning |
Interesting. I was hoping to make a backup (image) that would avoid unused blocks but it looks like I can't do so. I will just look for some other imaging solution. Thank you all.
|
rsync?
|
See if fsarchiver or partimage (part of clonezilla) suit your purpose.
|
FWIW, I've been using fsarchiver to make backup images, and have found it to work well enough.
|
All times are GMT -5. The time now is 08:52 PM. |