LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   DD multiple input, single output file? (https://www.linuxquestions.org/questions/linux-newbie-8/dd-multiple-input-single-output-file-4175592543/)

dbc254 10-30-2016 05:06 PM

DD multiple input, single output file?
 
I have 2 SSD's in my desktop /dev/sda + /dev/sdb Previous to the installation of the 2nd drive, I would simply;

if=/dev/sda of=/dev/sdb. sdb was my external backup drive

Is there a way to if=/dev/sda + /dev/sdb of=/dev/sdc ?

AwesomeMachine 10-30-2016 05:31 PM

Probably not. You'd make ground beef out of your backup.

syg00 10-30-2016 05:31 PM

Read the manpage for dd.
Sounds suspiciously like a xyproblem.

jefro 10-31-2016 04:46 PM

dd would be a wrong choice for this unless you did dd to a file from each device. I guess you could tar them together or copy them binary but you'd end up making the deal too complex.

dd is a choice for backup's but not a great tool for everyday use.

dd command sda to some file then dd command sdb to some file on sdc, you can add in compression to make it smaller. You could zero out free space on drives to make the image smaller too.

Fred Caro 10-31-2016 09:31 PM

Why not use rsync?

jefro 10-31-2016 10:21 PM

I think the OP could use rsync if the data is only file data. dd captures the entire data on the device in his syntax. dd can be used for many things but almost no one uses it for files.

Jjanel 11-01-2016 02:45 AM

Now your external drive is sdc? Is it bigger than the sum of the old-ssd sda + new-ssd sdb?
Consider (post) the sizes of your partitions (fdisk -l)...
IF you had just one each, sda1&sdb1, you could make two same-sized partitions on sdc &
dd sda1 to sdc1 and sdb1 to sdc2 (tho sdc wouldn't be bootable: MBR before 1st partition)
I know zero about UEFI/GPT and SSDs (just old hdd); I see you are a LONG-time Linux'er!

pan64 11-01-2016 03:12 AM

Quote:

Originally Posted by syg00 (Post 5624942)
Read the manpage for dd.
Sounds suspiciously like a xyproblem.

I'm really surprised how creative constructions posted here, at LQ, time by time. They tried to use commands without practice and without knowing what is really happening (another example was to set/use shell variables within an embedded awk script). I wouldn't say this time it is an xyproblem, because the OP wanted to backup now two drives instead of one, so (s)he just wanted to add one more parameter to dd. Which actually could be exactly the right way (as if you want to do it with copy or tar). But unfortunately that won't work, because dd is different.

Try for example:
Code:

mount /dev/sdc into /mnt/sdc
dd if=/dev/sda of=/mnt/sdc/filea
dd if=/dev/sdb of=/mnt/sdc/fileb


jpollard 11-01-2016 04:58 AM

Quote:

Originally Posted by dbc254 (Post 5624937)
I have 2 SSD's in my desktop /dev/sda + /dev/sdb Previous to the installation of the 2nd drive, I would simply;

if=/dev/sda of=/dev/sdb. sdb was my external backup drive

Is there a way to if=/dev/sda + /dev/sdb of=/dev/sdc ?

Don't do that.

Very likely you would end up with garbage. Dumping /dev/sda contains all the partition definitions and the data. Appending another set of partition definitions and data only confuses the result.

You can't restore the result - well, you could restore /dev/sda (it would error out when the device is full)
, But estoring /dev/sdc from it would require you to know the starting point.

Now said you wanted was an output put on /dev/sdc - and no it won't work. The partition definitions only come at the beginning of the disk - thus the /dev/sdb portion would still be inaccessible.

You CAN concatenate multiple inputs. The easiest way is
Code:

(dd if=inputdata ; dd if=moreinputdata) >outputdata
This works because without an "of" specification, dd writes to stdout. Thus you can combine the output of two dd commands into one output file.

In your case the result won't be usable.

You can't even do a "dd if=/dev/sda of=/dev/sdc1" for instance either... UNLESS there are no partitions on /dev/sda. Again, the problem is the partition tables.

If /dev/sda has partitions, then the first blocks copied to /dev/sdc1 will be the partition table - not the filesystem home block, thus the partition will not have a valid filesystem.

The only time this would work is if /dev/sda was not partitioned, but was entirely dedicated to a single filesystem. It works then because the first blocks copied would be the home block of the filesystem.


All times are GMT -5. The time now is 06:42 AM.