How can I know how long `dd` cloning will take?

67

Solution 1

Use the program pv for any piped stream to see a live report of data transfered. It can be used for any application using pipes. It is also a great tool for seeing rate of transfer to things like USB, External disks, networked computers.

dd if=infile | pv > outfile

Or for direct copying, just use this:

pv infile > outfile

Example:

sudo pv /dev/sda1 > /home/user/sda1.ext4.img

Solution 2

Typical. When I ask something I then find the answer somehow (even if I looked for hours.. but magically I find it AFTER creating the question -.- ). Anyway for what I checked with dd --help which mentions at the end of the help (I can't really believe I did not see THAT) the following:

Sending a USR1 signal to a running `dd' process makes it
print I/O statistics to standard error and then resume copying.

   $ dd if=/dev/zero of=/dev/null& pid=$!
   $ kill -USR1 $pid; sleep 1; kill $pid
   18335302+0 records in
   18335302+0 records out
   9387674624 bytes (9.4 GB) copied, 34.6279 seconds, 271 MB/s

What this means is that in another terminal you would run the following line using the Process ID of the DD you want to check. For example in my case is Process Id 4112. You can see the process ID by typing ps -e and looking for dd or just ps -e|grep dd and looking at the number in the front. Take note of that number and then type in another terminal window kill -USR1 4112; sleep 1; This will give me the time, seconds elapsed since it began and how much is has copied. At least now I know it takes about 8 hours to copy 1TB of information at about 40MB/s.

Solution 3

Regarding using kill to display info on a Mac, you have to pass it the -INFO flag instead of the -USR1 flag. And remember that it shows the info in the terminal where your dd process is running, so if you open a new tab to type kill -INFO $PID (where $PID is the number you found using ps -e | grep dd), you'll have to switch back to the tab where dd is running to see the output.

Now if only I could figure out how to display that output as GB or MB instead of plain bytes...

Solution 4

There is already another extended dd called dcfldd that do many funny stuff as this you are asking for http://dcfldd.sourceforge.net/

  1. sudo apt-get install dcfldd
  2. Instead of dd you write dcfldd
Share:
67

Related videos on Youtube

Gabriel Theron
Author by

Gabriel Theron

Updated on September 18, 2022

Comments

  • Gabriel Theron
    Gabriel Theron almost 2 years

    I'm trying to post some data with AJAX. I'm sending a serialized form, but nothing is sent. What can go wrong ? How can I fix it?

    $.ajax({
        url: 'postcreaorganisation',
        type: 'POST',
        data: $('#form').serializeArray(),
        processData: false,
        success: function(data) {
            //success action
        },
        error:function (xhr, ajaxOptions){
            //error action
        }  
    });
    

    Thanks in advance!

    Edit : I should specify that I use that code in a dialog confirm button's action.

    • Th0rndike
      Th0rndike about 12 years
      is that your url? postcreaorganisation?
    • Gabriel Theron
      Gabriel Theron about 12 years
      Yep. Nothing wrong here (it's a controller). And I checked, the controller receives the post, for that matter.
    • Klaus Byskov Pedersen
      Klaus Byskov Pedersen about 12 years
      Your form's id is form? And you are sure that the (relative) url is correct?
    • Anthony Grist
      Anthony Grist about 12 years
      So the AJAX request is sent, just minus the form data? Have you tried using $('#form').serialize(); instead?
    • akalucas
      akalucas about 12 years
      @GabrielTheron and the controller handles the request correctly? What is the exact data that you get back?
    • Gabriel Theron
      Gabriel Theron about 12 years
      Both URL and id are correct. Only a post request is sent. I'll try serialize(); and tell you what I get. The controller, for the moment, simply prints the data it receives, which is Array or array (0) {} (if I encode with JSON)
    • Gabriel Theron
      Gabriel Theron about 12 years
      The content of the post is always empty, both with serialize() and serializeArray(). It's my controller that prints Array or array (0) {}.
    • Bhavesh G
      Bhavesh G about 12 years
      use firebug in mozilla or use developer tools in google chrome; analyze network status, and check there if any error.
    • Gabriel Theron
      Gabriel Theron about 12 years
      I used Firebug to see the content of the POST. It's empty, but there is no network error of any kind. Everything works fine, except it doesn't seem to find the form/"believes" it's empty
    • gen_Eric
      gen_Eric about 12 years
      Try to console.log($('#form').serializeArray()). Make sure there's something there. Do all your form fields have name attributes?
    • Gabriel Theron
      Gabriel Theron about 12 years
      With name it works. I generated ids instead of name :/ It works now, thanks a lot!
    • Admin
      Admin over 8 years
      there is another discussion with various ways of doing this askubuntu.com/questions/215505/…
    • Admin
      Admin over 5 years
      The duplicate question has a more updated answer.
    • Admin
      Admin over 5 years
      @Garrett correct. Hence why this was marked as a duplicate of that one. Thank you.
  • Gabriel Theron
    Gabriel Theron about 12 years
    Thank you again for that very helpful answer ^^
  • Mechanical snail
    Mechanical snail over 11 years
    pv is much more convenient though.
  • Luis Alvarado
    Luis Alvarado over 11 years
    Can you additionally add a case for creating a clone of a disc, like dd if=/dev/sda of=/dev/sdb with the pv command.
  • Mechanical snail
    Mechanical snail over 11 years
    @LuisAlvarado: pv /dev/sda > /dev/sdb. Also gives you a nice progress bar.
  • Luis Alvarado
    Luis Alvarado over 11 years
    @Mechanicalsnail - Wait, are you saying I can clone a disc like that?
  • Rucent88
    Rucent88 over 11 years
    @LuisAlvarado, yes, you can clone a disc like that. Mech has used another partition as the output, but you could also output to a regular file named like "sda.img"
  • Luis Alvarado
    Luis Alvarado over 11 years
    +1 but the last update to that app was in 2006. Even if it works I would still fall with the normal dd or pv until I had tried dcfldd with a lot of non-important information.
  • balupton
    balupton about 10 years
    This didn't work on OSX, it just killed it... which is unfortunate, as it had already been running for an hour... :(
  • Luis Alvarado
    Luis Alvarado about 10 years
    @balupton highly recommend you post that as a bug in launchpad. Maybe is something related to all OSX or your particular case. Just tried it right now (Not OSX) and it worked, so you might be the proud owner of a huge bug. Go kill it!
  • Trevor Rudolph
    Trevor Rudolph almost 10 years
    dont forget dd if=/dev/sda | pv | dd of=/dev/sdb
  • Trevor Rudolph
    Trevor Rudolph almost 10 years
    maybe even try the size argument -s in bytes of source
  • Nux
    Nux almost 9 years
    Do NOT run kill $pid. This might kill the copy proccess. @Luis your answer is a bit missleading. All you need to do is run ps -a | grep dd and then send the signal to aquired pid kill -USR1 123456789 (where "123456789" is the pid).
  • Luis Alvarado
    Luis Alvarado almost 9 years
    @nux Hi friend and thanks for the comment. In this case, it is coming directly from the man page. Just in case, for DD, when it receives the dummy USR1, it behaves like a more verbose log, so it outputs the last line mentioned in the example.
  • Marc.2377
    Marc.2377 almost 8 years
    @balupton "On BSD systems, you need to send the INFO signal. Linux doesn't have a SIGINFO and uses USR1 instead." See here
  • Jorn
    Jorn over 5 years
    For those of you who can now finally monitor the throughput but wonder why it's <10kiB/s, see unix.stackexchange.com/a/322224/120881
  • abhchand
    abhchand about 3 years
    FYI on OSX it seems you can now press CTRL + t which gives you progress output. I'm not sure if this is a new feature, but it's available for me on OSX Catalina (10.15) and is much easier than most solutions here :)