快速磁盘克隆

发布于 2024-07-05 03:58:22 字数 1570 浏览 7 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

强者自强 2024-07-12 03:58:22

您可以尝试使用 bs 参数来增加块大小; 默认情况下,我相信 dd 使用的块大小等于磁盘的首选块大小,这意味着需要更多的读取和写入来复制整个磁盘。 Linux 的 dd 支持人类可读的后缀:

dd if=/dev/sda of=/dev/sdb bs=1M

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:

dd if=/dev/sda of=/dev/sdb bs=1M
傲性难收 2024-07-12 03:58:22

对我来说最快:

dd if=/dev/sda bs=1M iflag=direct | dd of=/dev/sdb bs=1M oflag=direct

达到约 100MiB/s,而其他选项(单进程、无直接、默认 512b 块大小,...)甚至达不到 30MiB/s...

要查看进度,请在另一个控制台中运行:

watch -n 60 killall -USR1 dd

The fastest for me:

dd if=/dev/sda bs=1M iflag=direct | dd of=/dev/sdb bs=1M oflag=direct

reaches ~100MiB/s, whereas other options (single process, no direct, default 512b block size, ...) don't even reach 30MiB/s...

To watch the progress, run in another console:

watch -n 60 killall -USR1 dd
终弃我 2024-07-12 03:58:22

Commodore Jaeger 的说法是正确的:

dd if=/dev/sda of=/dev/sdb bs=1M

此外,调整驱动器上的“预读”通常可以提高性能。 默认值可能是 256,最佳值可能是 1024。每个设置都不同,因此您必须运行基准测试才能找到最佳值。

# blockdev --getra /dev/sda
256
# blockdev --setra 1024 /dev/sda
# blockdev --getra /dev/sda
1024
# blockdev --help
Usage:
  blockdev -V
  blockdev --report [devices]
  blockdev [-v|-q] commands devices
Available commands:
    --getsz (get size in 512-byte sectors)
    --setro (set read-only)
    --setrw (set read-write)
    --getro (get read-only)
    --getss (get sectorsize)
    --getbsz    (get blocksize)
    --setbsz BLOCKSIZE  (set blocksize)
    --getsize   (get 32-bit sector count)
    --getsize64 (get size in bytes)
    --setra READAHEAD   (set readahead)
    --getra (get readahead)
    --flushbufs (flush buffers)
    --rereadpt  (reread partition table)
    --rmpart PARTNO (disable partition)
    --rmparts   (disable all partitions)
#

Commodore Jaeger is right about:

dd if=/dev/sda of=/dev/sdb bs=1M

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.

# blockdev --getra /dev/sda
256
# blockdev --setra 1024 /dev/sda
# blockdev --getra /dev/sda
1024
# blockdev --help
Usage:
  blockdev -V
  blockdev --report [devices]
  blockdev [-v|-q] commands devices
Available commands:
    --getsz (get size in 512-byte sectors)
    --setro (set read-only)
    --setrw (set read-write)
    --getro (get read-only)
    --getss (get sectorsize)
    --getbsz    (get blocksize)
    --setbsz BLOCKSIZE  (set blocksize)
    --getsize   (get 32-bit sector count)
    --getsize64 (get size in bytes)
    --setra READAHEAD   (set readahead)
    --getra (get readahead)
    --flushbufs (flush buffers)
    --rereadpt  (reread partition table)
    --rmpart PARTNO (disable partition)
    --rmparts   (disable all partitions)
#
满栀 2024-07-12 03:58:22

如果两个磁盘使用不同的通道(例如SATA),您可以使用高性能工具,例如fastDD。 作者声称:

“在这项工作中,我们回顾了可靠且高效的问题
复制数据,调用所有硬件和软件机制
干预和干预复制过程。 我们的考虑有
已用 fastdd 进行编码,这是一个能够非常快速地复制数据的 C++ 程序
正如我们在测试中所展示的那样,效率很高。”

此外,该工具的语法与旧的 dd 非常相似。

http://www.dei.unipd.it/~zagonico/fastdd/

https://github.com/zagonico86/fastdd

if the two disks use different channel (e.g., SATA) you can use high performance tool like fastDD. The authors claim:

"In this work, we reviewed the problem of reliably and efficiently
copying data, recalling all the hardware and software mechanisms which
intervene and interfer in the copying process. Our consideration have
been coded in fastdd, a C++ program able to copy data very
efficiently, as we show in our test."

Moreover the tool keeps a syntax very similar to the old dd.

http://www.dei.unipd.it/~zagonico/fastdd/

https://github.com/zagonico86/fastdd

多情癖 2024-07-12 03:58:22

关于您的更新:您的硬盘缓存有多大? (特别是写作方面)。 这可能太多了,您可能需要减少它以防止不必要的阻塞。

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.

江湖正好 2024-07-12 03:58:22

也许您可以使用两个进程,

dd if=indevfile | dd of=outdevfile

我假设您可以设置其他适合您的 dd 选项。
这有一些开销,但应该允许读取之间的异步
一个磁盘并写入另一个磁盘。

Maybe you can use two processes

dd if=indevfile | dd of=outdevfile

I'll assume you can set the other dd options as it suits you.
This has some overhead but should allow asynchrony between reading
one disk and writing the other.

面如桃花 2024-07-12 03:58:22

你确定它不是同时做的吗? 我希望磁盘缓存能够确保这种情况发生。 如果没有,非阻塞甚至异步读/写可能会有所帮助,

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,

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文