How to use dd ddrescue to merge two disk images
Hello to all the users
I'm not sure on how to use dd or ddrescue to do what follow I have two disks images disk1.bin (700MB) and disk2.bin (300MB) Since disk2.bin is only partial but complete, from first byte 0 up to last byte 300M and something, I need to overwrite the same first 300MB of disk1.bin with the content of disk2.bin with all the available disk2.bin bytes Since I have no space for backups, I need to issue the correct command, and here I'm asking kind hints Can you kindly hint which is the best correct command either with dd or ddrescue to achieve such merging process? Thank you Cor |
I do not really understand it. First, you must have space enough to complete it, otherwise it will be really hard, but probably not impossible. Next, overwriting the first 300 MB will mean the remaining 400 will not be available any more.
What is the real goal? |
Quote:
Quote:
Given the question has even been raised, one certainly has to doubt the ability to recover (all) the data. |
Hello Pan and Syg
thank you both for your kind replies disk1.bin covers the entire drive, but it is damaged in many areas, damages are present also in its first 300MB, disk2.bin is an previous image that stopped imaging at more or less 50%, but such rough first 300MB are perfect and error free. Now creating an image where the first part of 700MB is made with the disk2.bin content and the rest of the 700MB remains the original disk1.bin content, will provide the most valuable result. I know how to do it with a double passage - dump disk1.bin on top of an hard drive - repeat the operation using disk2.bin as source I'd like to skip this solution as it requires an additional hard drive while I'm pretty sure it can be done "at once", especially with dd. So the question, kindly remains: how to achieve a byte to byte merge/overwrite of disk1.bin and disk2.bin, picking as source disk2.bin to displace on top of disk1.bin. Thank you Cor |
you can achive it easily, just you will need to take disk2.bin and append the content of disk1.bin (after cutting the first part).
The problem is that as long as disk1.bin and disk2.bin is opened you will not be able to remove them from the disk, therefore this small app will create an additional new file (even when you try appending). So actually I would rather use a pendrive (or whatever) to move onto another drive/host, split disk1 and concatenate disk2 and disk1. |
As I understand it, you want to overwrite the first part of disk1.bin with the contents of disk2.bin. That is pretty simple:
Code:
dd if=disk2.bin conv=notrunc of=disk1.bin Note: Dangerous as Hell to be doing this without any backup for the data. |
Hello rknichols
thank you so much your one is the kind and piece of info I was wondering about Thank you to pan64 too About the note Note: Dangerous as Hell to be doing this without any backup for the data. I will be able to regenerate disk1.bin as many times I want, but I must move to another site. Don't worry, I know what you mean :-), BTW thank you P.S. do you think it will create some kind of intermediate file, or will it physically overwrite the disk1.bin? |
Physically overwrite.
|
one last curiosity
you don't use parameters as 512byte or 1k or more are those intended for disk drive operations only? Thank you |
You can use them. Totally optional. The operation will be more efficient with a larger blocksize, and if you are trying to move a specific amount of data a different blocksize might make the calculation easier. I typically use 32k since one time in the (now distant) past I did some testing and found that there wasn't much improvement when going larger. In the interest of conciseness, I didn't mention blocksize.
|
And if you didn't want to use all of the disk2.bin (you say you want the first 300MB)
then you could use Code:
dd if=disk2.bin conv=notrunc bs=1M count=300 of=disk1.bin You can get quite elaborate because there is also a "skip" option to skip records before reading, and "seek" options to skip doing output for the number of records (allows you to position the output so that the input starts being written at the given location). As always, having backups really helps. |
All times are GMT -5. The time now is 11:48 AM. |