LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 08-13-2011, 11:23 AM   #1
Seventh
Member
 
Registered: Dec 2003
Location: Boston, MA
Distribution: Redhat / Debian
Posts: 269

Rep: Reputation: 30
About to DD a drive - how to be sure which is which?


Hey guys,

I realize this is super basic, so my apologies. I'm about to clone a drive with the DD command, and I just want to make sure that my source and target are correct so that I don't get them backwards.

I know there's a command that'll list all of the connected devices, and another that will show me if my drive is formatted NTFS. I just can't for the life of me remember what it is.

Any insight would be very much appreciated!
 
Old 08-13-2011, 11:47 AM   #2
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,252

Rep: Reputation: 313Reputation: 313Reputation: 313Reputation: 313
Maybe you think about "fdisk -l" or "parted -l"?
 
Old 08-13-2011, 11:56 AM   #3
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 112Reputation: 112
The input file is the one you read

The output file is the one that will be changed same as the input file in the command
Code:
dd if=/dev/sda of=/dev/sdb
Get your devices names from fdisk -l as suggested by eSelix

Last edited by saikee; 08-13-2011 at 11:59 AM.
 
Old 08-13-2011, 12:23 PM   #4
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Or you can do a ls -l /dev/disk/by-part and a ls -l /dev/disk/by-label/ to get a more compact and (in my opinion) an easier to read description.

Then there's always the lshw-gui that (if you search in the display) gives you information about all the hardware known to the kernel.
 
Old 08-13-2011, 01:12 PM   #5
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
You probably want to use the mount command for one or two reasons. Firstly, if the partition is mounted, you can use mount to confirm which partition you want to use as a source & which to use as a destination. Running it without any commandline options will show you which partitions are mounted, and their mountpoints. Secondly, you will want to umount both the source and destination partitions before you start the cloning process. mount can confirm that you have done so.

--- rod.
 
Old 08-13-2011, 02:44 PM   #6
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Quote:
Originally Posted by theNbomr View Post
You probably want to use the mount command for one or two reasons. Firstly, if the partition is mounted . . .
--- rod.
Well, the O.P. wants to clone the drive, not a partition on the drive, so mounting it would, I think, be counter-productive.

The problem with cloning a drive with dd is that you end up with identical partition tables, and the "new" table may not be correct for the output drive unless it is identical to the old drive.

You (the O.P.) might find it useful to download and burn the Clonezilla live system, and to use it to clone the drive. (The site has documentation and how-to information.)
 
Old 08-13-2011, 03:23 PM   #7
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Point taken.
However, while the OP uses the term 'drive' it isn't always the case that new users distinguish between drives and partitions. Also, no matter whether it is a drive or a partition, it shouldn't be mounted.

--- rod.
 
Old 08-13-2011, 05:54 PM   #8
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 112Reputation: 112
I don't normally bother with mounting and umounting the partitions during cloning.

The instruction in dd is to read from the block device directly and so the operation is unaffected if the partitions are mounted. The filing system is simply not used. However if one is stupid enough to change the source disk information during cloning then on exit of the Linux could record the change on the source only and not on the target.

I have cloned many times with a target disk different in size to the source disk and sometime the target is smaller in capacities too. The key requirement is the total number of cylinders to be cloned should always be able to fit into the target disk. When either the source or the target has exhausted the number of cylinders to be read or written dd simply ceases the operation but the end result is health and serviceable.

Technically there is nothing wrong to clone a 2TB hard disk, that has say 1.4TB used up in partitions and the last 0.6TB as unallocated space into a 1.5TB target disk. The cloning will continue, after the first 1.4TB has been cloned, by copying the unallocated space across. When the 1.5TB limit of the target disk has been exhausted dd simply complains no more sector available on the target and terminates itself. However both hard disks have 1.4TB data, the source has 0.6TB unallocated space and the target has 0.1TB hard disk space. Both disks have no error or cause for any operating system to complain about.
 
Old 08-13-2011, 06:39 PM   #9
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Quote:
Originally Posted by saikee View Post
[...]Both disks have no error or cause for any operating system to complain about.
Well, that's interesting. Every time I've done that, I needed to use gparted to make the partition table conform to the physical drive, and any attempt to use the unallocated space on the cloned drive without "fixing" the partition table caused my system to complain. And I also needed to use tune2fs (IIRC) to give the drive's partition(s) a UUID different from that of the source. (That's just because I almost always mount using the UUID= form, and I often want both drive mounted.)

But, hey, it all depends on what you're trying to accomplish.

Still, as I said above, the simple solution is clonezilla (which is, to a large extent, just dd scripts, but nicely packaged).
 
  


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
I want to copy my hard drive to a larger hard drive and boot from the new drive. lpmorgan1 Ubuntu 8 09-08-2009 12:26 AM
Removed bad hard drive from computer, now flash drive won't mount. checkmate3001 Linux - Hardware 6 08-15-2008 01:03 AM
cannot delete drive from root desktop - cannot mount usb flash drive - openSuSE 10.2 bluecog6 Linux - General 6 01-29-2007 04:18 PM
Installing SuSE on an external FireWire drive: YaST can't edit partitions on drive kivimaki Linux - Distributions 2 09-13-2004 09:52 PM
slackware 9.1 mounting problems (cd drive, cd writer drive, win partition (ntfs)) mr.gizm0 Slackware 8 05-11-2004 07:23 PM


All times are GMT -5. The time now is 12:07 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration