About to DD a drive - how to be sure which is which?
Linux - NewbieThis 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!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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.
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.
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.
[...]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).