Search code examples
linuxstorageddparallel-io

Fast Disk Cloning


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.

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


Solution

  • 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)
    #