<p>Is there a way to have Linux read ahead when cloning a disk?  I use the program named "dd" to clone disks.  The last time I did this it seemed as though the OS was reading then writing but never at the same time.  Ideally, the destination disk would be constantly writing without waiting that's of course if the source disk can keep up.</p>

<p>UPDATE: I normally choose a large block size when cloning (ex. 16M or 32MB).</p>

[{'answer_id': 54631, 'author': 'Thomas Kammeyer', 'author_id': 4410, 'author_profile': 'https://Stackoverflow.com/users/4410', 'pm_score': 1, 'selected': False, 'text': "<p>Maybe you can use two processes</p>\n\n<pre><code>dd if=indevfile | dd of=outdevfile\n</code></pre>\n\n<p>I'll assume you can set the other dd options as it suits you.\nThis has some overhead but should allow asynchrony between reading\none disk and writing the other.</p>\n"}, {'answer_id': 54639, 'author': 'Leon Timmermans', 'author_id': 4727, 'author_profile': 'https://Stackoverflow.com/users/4727', 'pm_score': 0, 'selected': False, 'text': "<p>Are you sure it isn't doing that at the same time? I would expect the disk caches to make sure it that happens. If not, non-blocking or even asynchronous reads/writes may help,</p>\n"}, {'answer_id': 54642, 'author': 'Commodore Jaeger', 'author_id': 4659, 'author_profile': 'https://Stackoverflow.com/users/4659', 'pm_score': 3, 'selected': False, 'text': "<p>You might try increasing the block size using the bs argument; by default, I believe dd uses a block size equal to the disk's preferred block size, which will mean many more reads and writes to copy an entire disk. Linux's dd supports human-readable suffixes:</p>\n\n<pre><code>dd if=/dev/sda of=/dev/sdb bs=1M\n</code></pre>\n"}, {'answer_id': 54682, 'author': 'Leon Timmermans', 'author_id': 4727, 'author_profile': 'https://Stackoverflow.com/users/4727', 'pm_score': 0, 'selected': False, 'text': '<p>About your update: How big are the caches of your HDs? (specially the writing one). It may be that that is too much and you may need to reduce it to prevent unnecessary blocking.</p>\n'}, {'answer_id': 55793, 'author': 'John Vasileff', 'author_id': 5076, 'author_profile': 'https://Stackoverflow.com/users/5076', 'pm_score': 4, 'selected': True, 'text': '<p>Commodore Jaeger is right about:</p>\n\n<pre><code>dd if=/dev/sda of=/dev/sdb bs=1M\n</code></pre>\n\n<p>Also, adjusting "readahead" on the drives usually improves performance.  The default may be something like 256, and optimal 1024.  Each setup is different, so you would have to run benchmarks to find the best value.</p>\n\n<pre><code># blockdev --getra /dev/sda\n256\n# blockdev --setra 1024 /dev/sda\n# blockdev --getra /dev/sda\n1024\n# blockdev --help\nUsage:\n  blockdev -V\n  blockdev --report [devices]\n  blockdev [-v|-q] commands devices\nAvailable commands:\n    --getsz (get size in 512-byte sectors)\n    --setro (set read-only)\n    --setrw (set read-write)\n    --getro (get read-only)\n    --getss (get sectorsize)\n    --getbsz    (get blocksize)\n    --setbsz BLOCKSIZE  (set blocksize)\n    --getsize   (get 32-bit sector count)\n    --getsize64 (get size in bytes)\n    --setra READAHEAD   (set readahead)\n    --getra (get readahead)\n    --flushbufs (flush buffers)\n    --rereadpt  (reread partition table)\n    --rmpart PARTNO (disable partition)\n    --rmparts   (disable all partitions)\n#\n</code></pre>\n'}, {'answer_id': 13249678, 'author': 'SteveMenard', 'author_id': 1802853, 'author_profile': 'https://Stackoverflow.com/users/1802853', 'pm_score': 3, 'selected': False, 'text': "<p>The fastest for me:</p>\n\n<pre><code>dd if=/dev/sda bs=1M iflag=direct | dd of=/dev/sdb bs=1M oflag=direct\n</code></pre>\n\n<p>reaches ~100MiB/s, whereas other options (single process, no direct, default 512b block size, ...) don't even reach 30MiB/s...</p>\n\n<p>To watch the progress, run in another console:</p>\n\n<pre><code>watch -n 60 killall -USR1 dd\n</code></pre>\n"}, {'answer_id': 24758991, 'author': 'Paolinux', 'author_id': 1901651, 'author_profile': 'https://Stackoverflow.com/users/1901651', 'pm_score': 2, 'selected': False, 'text': '<p>if the two disks use different channel (e.g., SATA) you can use high performance tool like fastDD. The authors claim:</p>\n\n<blockquote>\n  <p>"In this work, we reviewed the problem of reliably and efficiently\n  copying data, recalling all the hardware and software mechanisms which\n  intervene and interfer in the copying process. Our consideration have\n  been coded in fastdd, a C++ program able to copy data very\n  efficiently, as we show in our test."</p>\n</blockquote>\n\n<p>Moreover the tool keeps a syntax very similar to the old <code>dd</code>.</p>\n\n<p><a href="http://www.dei.unipd.it/~zagonico/fastdd/" rel="nofollow">http://www.dei.unipd.it/~zagonico/fastdd/</a></p>\n\n<p><a href="https://github.com/zagonico86/fastdd" rel="nofollow">https://github.com/zagonico86/fastdd</a></p>\n'}]
['https://Stackoverflow.com/questions/54612', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4778/']