LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-30-2016, 05:06 PM   #1
dbc254
Member
 
Registered: Oct 2003
Location: Philadelphia
Distribution: Linux Mint 17.3
Posts: 43

Rep: Reputation: 0
Question 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 ?
 
Old 10-30-2016, 05:31 PM   #2
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
Probably not. You'd make ground beef out of your backup.
 
1 members found this post helpful.
Old 10-30-2016, 05:31 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,119

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Read the manpage for dd.
Sounds suspiciously like a xyproblem.
 
1 members found this post helpful.
Old 10-31-2016, 04:46 PM   #4
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,973

Rep: Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622
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.
 
Old 10-31-2016, 09:31 PM   #5
Fred Caro
Senior Member
 
Registered: May 2007
Posts: 1,007

Rep: Reputation: 167Reputation: 167
Why not use rsync?
 
Old 10-31-2016, 10:21 PM   #6
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,973

Rep: Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622
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.
 
Old 11-01-2016, 02:45 AM   #7
Jjanel
Member
 
Registered: Jun 2016
Distribution: any&all, in VBox; Ol'UnixCLI; NO GUI resources
Posts: 999
Blog Entries: 12

Rep: Reputation: 363Reputation: 363Reputation: 363Reputation: 363
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!

Last edited by Jjanel; 11-01-2016 at 02:57 AM.
 
Old 11-01-2016, 03:12 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,789

Rep: Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304
Quote:
Originally Posted by syg00 View Post
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
 
1 members found this post helpful.
Old 11-01-2016, 04:58 AM   #9
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by dbc254 View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Write a shell script that receives a word, an input file and an output file. The scripts copies all the lines in the input file that contain mandy2112 Linux - Newbie 3 08-18-2016 10:11 AM
[SOLVED] awk or sed to use CSV as input and XML as template and output to a single file bridrod Linux - Newbie 6 03-13-2012 07:00 PM
[SOLVED] Multiple input into seq command from pipe / single column unique numbers geehog Programming 4 05-14-2011 12:18 AM
how to create a single line of output from multiple variable lines of input steven.c.banks Linux - General 2 02-03-2010 03:09 PM
input single integer value, output the value as separate digits hubabuba Programming 2 03-02-2005 10:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration