You are not logged in.

#1 2015-07-22 02:37:20

Llama
Banned
From: St.-Petersburg, Russia
Registered: 2008-03-03
Posts: 1,379

Hard Drive Cloning

Hi,

I've just bought a new hard drive, 3 Tb. I want my old disk cloned as is, nothing more. I'm trying the simplest approach from the Wiki:

$ sudo dd if=/dev/sda of=/dev/sdb bs=512 conv=noerror,sync

It's been running for 11 hours, and no end in sight. What am I doing wrong?

Offline

#2 2015-07-22 02:51:56

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: Hard Drive Cloning

What are you doing wrong?  Using DD on a 3 TB drive!

How are the drives connected?

Are you really using anywhere near the 3 TB?


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2015-07-22 03:06:11

progandy
Member
Registered: 2012-05-17
Posts: 5,307

Re: Hard Drive Cloning

How are the drives connected and what read/write speed do your two drives provide? If everything works out to 100MB/s average then you should be able to clone 3TB in about 9 hours.
By the way, I think dd will work a bit better with a larger block size like bs=16M

If you want to get a status report, run a "killall -USR1 dd" in a second terminal, then view the output in the one with dd.

Edit: Please be sure /dev/sda* and /dev/sdb* is not mounted or your new copy will probably be corrupt. If arch is installed on /dev/sda, then I suggest you boot the install cd and use that to clone the disks.

Last edited by progandy (2015-07-22 03:12:51)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

#4 2015-07-22 03:13:24

Llama
Banned
From: St.-Petersburg, Russia
Registered: 2008-03-03
Posts: 1,379

Re: Hard Drive Cloning

Trilby wrote:

What are you doing wrong?  Using DD on a 3 TB drive!

OK. What else should I use?

How are the drives connected?

sda is my regular SATA drive, target sdb on USB.

Are you really using anywhere near the 3 TB?

Actual volume is less that 1.5 Tb.

Offline

#5 2015-07-22 07:24:59

frostschutz
Member
Registered: 2013-11-15
Posts: 1,642

Re: Hard Drive Cloning

bs=512 will copy using 4096 syscalls (2048x read(), 2048x write()) per MiB, too much for the CPU to handle. That would be ~500k syscalls per second for 100MiB/ish copy speeds - and syscalls, particularly I/O syscalls, are slow.

bs=16M on the other hand is too large, particularly with conv=noerror, it will leave you with a 16M hole for a single bad sector. Basically with noerror you want to pick the smallest blocksize that is still performant.

For noerror, bs=4k is better, it will already give you normal copy speeds compared to bs=512 and 4k is the blocksize used by filesystems anyway.

Optimal speeds are around bs=64k bs=128k bs=256k

bs=1M is the human readable option, it only gets slower after that. If the blocksize is too large, the disks will no longer work in parallel, instead one disk will idle while the other is writing or reading. Thus the speed cuts in half.

With one exception: If you're copying from/to the very same disks (e.g. moving partitions) a very large blocksize (bs=128M - bs=1G) lets the disk work linear instead of doing tons of seeks.

If you started off a slow dd you can cancel it and resume it, if you know how much data was already copied. For example if you're sure that you already copied a certain amount of data you could do something like this:

# dd if=/dev/source of=/dev/target bs=1M seek=42000 skip=42000

that would resume at the 42000MiB position. You should pick this value a bit smaller then the amount of data you're sure you've already copied. Better to copy a small region again, than to misjudge and leave a small region uncopied.

Last edited by frostschutz (2015-07-22 07:46:45)

Offline

#6 2015-07-22 10:51:10

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: Hard Drive Cloning

sdb being on a usb is the most impotant point here.  There is a good range in the estimates depending on your exact hardware, but here is an example giving usb-connected-harddrive write speeds around 30MB/s.  With that the estimated transfer time would be would be 12.1 days.  This is making a lot of assumptions: first that this 3MB/s number if good - it might not be, you might get much better write speeds.  But on the other side, this 12 day estimate is also assumming that whatever transfer speed you get can be maintained for a very extended period of time.  Also this is calculating on the USB IO only.  If we use the information about the number of system calls above, this 12 days would likely turn into something on the order of months.

You ask about other options - this is why I asked whether you were actually using the full 3TB.  If that drive is filled to the brim with data you want transferred, then there likely are not better options, but you should definitely get the target drive connected to a sata connector or something other than usb.  If you are not using the full 3TB, just partition the new drive in a similar way as the first, use rsync, and then adjust the fstab and bootloader on the target drive.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#7 2015-07-22 10:54:44

frostschutz
Member
Registered: 2013-11-15
Posts: 1,642

Re: Hard Drive Cloning

USB is not a problem... if it's USB3. smile

USB2 is a bit slow but still not as slow as dd with bs=512.

> 12.1 days

1.21?

If the dd is still running you can get a progress indication using killall -SIGUSR1 dd

Last edited by frostschutz (2015-07-22 10:56:06)

Offline

#8 2015-07-22 11:10:27

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: Hard Drive Cloning

No, defintely 12.1.  I don't know what the actual transfer speeds are, but just using the 3MB/s value from the link I provided we get 3 x 1024 x 1024 MB / 3 = 1048576 seconds.  1048576 / 3600 = 291.2711 hours.  291.2711 / 24 = 12.1363 days.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#9 2015-07-22 11:12:46

frostschutz
Member
Registered: 2013-11-15
Posts: 1,642

Re: Hard Drive Cloning

3MB/s is silly. USB 2 is ~30MB/s.

Offline

#10 2015-07-22 11:21:37

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: Hard Drive Cloning

3 may be too low, but remember, we're talking about *write* speed over the usb.  I've found other estimates that put that around 10-15MB/s under the best of conditions.  So maybe 3-4 days.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#11 2015-07-22 11:31:05

frostschutz
Member
Registered: 2013-11-15
Posts: 1,642

Re: Hard Drive Cloning

...

If you have a USB2 hard disk that gets only 15MB/s writing, I'd return it. That's not normal.

USB sticks are a different matter.

Last edited by frostschutz (2015-07-22 11:32:05)

Offline

#12 2015-07-22 15:10:04

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: Hard Drive Cloning

For reference, cloning my 640 GB drive to an identical drive via a USB (2?) enclosure using "dd" takes me 5h30m.

I'm considering using CloneZilla in the future, since it might have some "tricks" to speed things up. smile

Offline

#13 2015-07-22 17:03:12

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,623

Re: Hard Drive Cloning

drcouzelis:

That is 27 MBytes/sec.  It is also about 218 MBits/Sec.    That is a pretty good chunk of the 280 MBit/sec rate that can be generally achieved on USB 2.0.  No doubt, the rest of the bandwidth is being used for overhead.

If data on the drive is sparse, then it is possible to speed things up by not copying the empty chunks.  If the drive is full, the only thing that would help is a bigger pipe, or lossless compression.

Edit:  Added 2.0

Llama:  Of course, you should plan on this taking 3/0.6 times longer.  That ratio is 5x what drcouzelis's transfer takes  (Assuming the clone is a USB 2.0 device)

Last edited by ewaller (2015-07-22 17:07:47)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#14 2015-07-23 12:07:22

andrekp
Member
Registered: 2012-06-07
Posts: 112

Re: Hard Drive Cloning

FWIW, I find it's usually easier to just to a copy, retaining all attributes, from partition to partition, as suggested in the Arch wiki.  You probably don't care if the disks are EXACT copies of each other, just that all files get moved and retain attributes.  In the end, cp is safer and more fool proof than dd, I think.

Offline

#15 2015-07-23 13:49:03

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,623

Re: Hard Drive Cloning

andrekp wrote:

In the end, cp is safer and more fool proof than dd, I think.

And, IMHO, rysnc is even safer and more fool proof.  And can be interrupted and restarted. And can show progress.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#16 2015-07-23 14:53:55

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: Hard Drive Cloning

ewaller wrote:
andrekp wrote:

In the end, cp is safer and more fool proof than dd, I think.

And, IMHO, rysnc is even safer and more fool proof.  And can be interrupted and restarted. And can show progress.

Using "rsync" is a great idea, and got me really excited! ...but then I remembered why I use "dd": other operating systems. Using "dd" also makes an exact copy of my partition table, Haiku installation, OpenBSD installation, and whatever else I can't remember I installed. big_smile

Anyway, I agree, if it works in your situation, "rsync" is a great solution!

Offline

#17 2015-07-23 16:26:07

mwillems
Member
Registered: 2014-08-09
Posts: 93

Re: Hard Drive Cloning

Rsync offers a lot of advantages over cp, not least of which is checksumming each copied file to make sure it didn't change as it was being copied.  If a file is changed during a cp of that file, you get a silently corrupted "backup", which rsync would have detected and prevented. But rsync offers no assurance that two different files were not copied in an inconsistent state (it does not snapshot the whole filesystem, it just copies at the file level).  A full system rsync can often take significant time allowing for lots of file changes in the interim, so I advise running rsync a second time immediately after the first run as a precaution if you're running rsync on a read-write mounted filesystem.   

For many usage scenarios it doesn't really matter if files are modified during an rsync run (a lot of data is atomic and most files don't care what other files are doing), but if you have files that are updated automatically in the background and rely on other files being in a consistent state (virtual machines and snapshots of said machines, data with metadata stored in a separate file, etc.) a second rsync will provide some assurance that your backup files will be in a (more or less) consistent state.  I have definitely gotten borked rsync backups of running virtual machines/snapshots before, so I learned my lesson.

Offline

#18 2015-07-23 21:15:02

Roken
Member
From: South Wales, UK
Registered: 2012-01-16
Posts: 1,351

Re: Hard Drive Cloning

Honestly, how many more threads asking to copy drives must we see? Search, people, search. This has been covered to death.


Ryzen 5900X 12 core/24 thread - RTX 3090 FE 24 Gb, Asus B550-F Gaming MB, 128Gb Corsair DDR4, Fractal Design Define 7 XL, 5 HD (2 NvME PCI, 4SSD) + 1 x optical.
Linux user #545703

/ is the root of all problems.

Offline

#19 2015-07-23 21:33:37

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: Hard Drive Cloning

I'm surprised no-one has mentioned Clonezilla. It's available as an Arch package but if your source drive contains your root partition then you're better off using the Live CD...

http://clonezilla.org/

Last edited by Slithery (2015-07-23 21:33:46)


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#20 2015-07-23 21:45:05

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,648

Re: Hard Drive Cloning

slithery wrote:

I'm surprised no-one has mentioned Clonezilla. It's available as an Arch package but if your source drive contains your root partition then you're better off using the Live CD...

drcouzelis wrote:

I'm considering using CloneZilla in the future, since it might have some "tricks" to speed things up. smile

Offline

#21 2015-07-23 21:51:27

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: Hard Drive Cloning

It's late, I've had a long day...


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#22 2015-07-27 02:40:19

Llama
Banned
From: St.-Petersburg, Russia
Registered: 2008-03-03
Posts: 1,379

Re: Hard Drive Cloning

slithery wrote:

I'm surprised no-one has mentioned Clonezilla. It's available as an Arch package but if your source drive contains your root partition then you're better off using the Live CD...

http://clonezilla.org/

It's worth a try, then. Copying by cp won't work on the big user partition, unlike the root you're warning me against.

Offline

Board footer

Powered by FluxBB