Linux How-To Monitor DD Progress Copying A Drive to a New One

Linux How-To Use DD to Copy A Drive to a New One

There are times when it's necessary to migrate all the data from one disk to another. These include
  • Upgrading to a larger disk
  • Pre-emptivey moving to a new drive following a SMART alert
  • Making a copy before moving a server
etc

There are lots of software tools that can be used, both open-source/free and paid-for, for example CloneZilla

One of the simplest is simply to use the Linux command 'dd' from a recovery disk

dd is a command-line tool for copying disk content (filesystems) from one location to another, primarily used to make a 'file' of a specific size for speed/io testing, or to copy an entire disk image.

WARNING: dd is often called data-destryer for good reason if you're not 100% sure on what you are doing !

As simple and quick as DD is, as with most CLI tools, it operates 'silently' unless there are errors to report - and so there are disadvantages for use as a drive duplication too, like being able to monitor the progress of the disk copy - below are the 2 most common solutions ...

How to show progress during a dd copy

Simple Method - using iostat

If you started your machine with a SysRescCD Live-Linux distribution (the most widely used way to get a box 'up' to be able to DD the contents - then you have access to another command-line tool called 'iostat' <p.> To check how far your disk duplication has reached, simply open another terminal window (ALT-F2) and type:
$ iostat

This will report the KB_read and kB_wrtn (written) for your disks - divide the written by 1024 and you have the amount of MB completed so far, and can guestimate the remaining time based on the size of the disk (which you can obtain from an 'fdisk -l'

Advanced Method - sending a USR1 kill to dd

For a more 'interactive' progress report you can send a USR1signal to the dd process from another terminal window ...
  1. Determine the process-id (pid) for the running dd command:
    $ pgrep -l '^dd$'
    This will output the pid and binary name e.g. 2188 dd
  2. Send the USR1 signal to the pid:
    $ kill -USR1 2188
    When dd picks up the USR1 signal it will print the current statistics to STDERR on the original terminal and continue.
  3. Switch to the terminal running dd and view the output:
    e.g.
    12698193+0 records in
    12698193+0 records out
    54735860224 bytes (55 GB) copied, 4529.87 seconds, 12.1 MB/s
  4. Use the 'watch' command to execute the USR1 kill every minute:
    $ watch -n 60 kill -USR1 2188
  5. Kill the watch when the copy has completed with CTRL-C
  • 1 användare blev hjälpta av detta svar
Hjälpte svaret dig?

Relaterade artiklar

What are the exact specs of your hardware?

We do not disclose the full hardware specifications of our servers, as they are eachy...

How do I stop Cpanel reporting /usr/bin/crontab permissions are wrong. Please set to 4755.

If you get this message in CPanel when adding/ediiting/viewing the cron jobs ......

How do I force Statistics (Webalizer and AWstats) to run on Plesk Servers ?

Updating Webalizer and AWStats on Linux Plesk Servers from SSH The plesk control panel is...

How much is HELM ? What Helm licences do you offer ?

Web Host Automation (HELM Authors) sold the control panel rights and code some years ago to...

How do I install or update Xen Tools on a Linux VPS?

Login to your VPS as root (or use "su -" from a user account). Enter the following commands: #...

Powered by WHMCompleteSolution