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!
Notices
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I read on lifehacker that cloning a drive with Linux is easy as running this command.
Code:
dd if=/dev/sda of=/dev/sdb
Is this true? Apparently it is a bit for bit copy but I just can't imagine the process being this simple. Has anyone successfully cloned a drive with this method? I don't want to brick my data by using unsafe methods.
I read on lifehacker that cloning a drive with Linux is easy as running this command.
Code:
dd if=/dev/sda of=/dev/sdb
Is this true? Apparently it is a bit for bit copy but I just can't imagine the process being this simple. Has anyone successfully cloned a drive with this method? I don't want to brick my data by using unsafe methods.
It certainly can be that easy.
That command gets EVERYTHING, MBR, partition layout and all.
There may be snags with different drive geometry, size etc. but you can try the clone before deleting the original ...
I read on lifehacker that cloning a drive with Linux is easy as running this command.
Code:
dd if=/dev/sda of=/dev/sdb
Is this true? Apparently it is a bit for bit copy but I just can't imagine the process being this simple. Has anyone successfully cloned a drive with this method? I don't want to brick my data by using unsafe methods.
Yes, it is that simple.......BUT
You have to be absolutely sure that you have the correct device designations---there is no "undo".
You may want to set the block size for best speed. You can run trials like so:
Code:
dd if=/dev/sda of=/dev/sdb bs=M count=N
Start with M=2048 and keep the product of M*N the same---let's say ~ 100MBytes. As you change the block size, look at how long the operation takes. I don't remember the results the last time I tried this----it is useful to experiment a bit to see how it works and whether the block size makes any difference.
AND---the target drive has to be the same size as the source--or larger.
There is a megathread here somewhere--started by member "Awesome machine"----more than you ever wanted to know about "dd".
Curiousity got to me---on this machine (Lenovo laptop, 4G RAM), there is a dramatic increase in speed when the block size is larger than ~1K---I have no idea why.....
Hmmmm - such (small) tests are meaningless unless in-storage buffers are purged.
drop-caches is useful these days, but I still prefer to reboot between any disk tests.
As for "dd", IMHO it should be avoided at all costs for non-forensic backups. Period.
Hmmmm - such (small) tests are meaningless unless in-storage buffers are purged.
drop-caches is useful these days, but I still prefer to reboot between any disk tests.
As for "dd", IMHO it should be avoided at all costs for non-forensic backups. Period.
Well Hmmmmmm to you too......
<<begin dumb questions>>
What is an in-storage buffer?....drop-cache?
<<resume normal mode>>
What exactly is wrong with dd for backup? Beside---OP did not ask about backup---the question was about cloning a drive......dd do dat dandy....
Sorry - should have been "drop_caches" (underscore).
Disk read are buffered in page cache ("cached" in the free command et al). Subsequent reads to the same data may (will) be resolved from those buffers (in RAM), negating any disk read effects.
See drop_caches in "man proc" for how this can (now) be ameliorated.
"dd" copies everything blindly - including errors in the underlying filesystem. Makes backups (including clones) suspect at best.
Sorry - should have been "drop_caches" (underscore).
Disk read are buffered in page cache ("cached" in the free command et al). Subsequent reads to the same data may (will) be resolved from those buffers (in RAM), negating any disk read effects.
See drop_caches in "man proc" for how this can (now) be ameliorated.
So the solution to this would be to fsck all filesystems first, before you clone the disk using dd.
Maybe. (or in my opinion "no").
fsck validates the filesystem, not the files/data within. That's why you can wind up with lots of "bit and pieces" of files in lost+found.
So, if the fsck is followed by remedial action on damaged files, then "dd" is fine. But a script that just fsck's then dd, uh-uh; still too risky.
Wait, not one application I know of can deal with the data in the filesystem, I can't even imagine how that should be possible. So in your opinion even a simple backup scheme using cp isn't trustworthy, because the data may already be corrupted before the transfer?
"I don't want to brick my data by using unsafe methods."
Well, I can say that if you ask then don't do it. dd had been known to bite most of us at one time or another.
EDDY1 posted an alternative to using a file based copy. As with dd and almost every other program there are many issues.
Issue tends to be size, geometry and then second is how the system boots. The geometry is sometimes difficult to fix while the boot naming tends to be more fixable.
I don't know of any fool proof way to copy a drive. I have used dd hundreds of times both directly and using G4U disks.
Like Porky says, When hunting for rabbits, you have to be vwery vwery cawful, hahahaha.
If I have a drive with the essential data readable, and I then clone it for backup, it seems I have not lost anything----I still have a better backup than if I had done nothing.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.