Tip: dd command with progress bar

dd is a command very "silent" and therefore sometimes somewhat dangerous and exasperating. In this post we will show you how to make this fabulous command show us a progress bar similar to the one that appears when we download files with the wget command.

The dd command is a powerful tool that allows you to do many things, among them we find an easy way to clone partitions and even entire hard drives. It only has a small drawback, it is a very "silent" command because when executing it, the terminal prompt remains immobile, so it can cause nervousness by not knowing what is happening and how long it takes for it to finish executing.
All of this is solved with the pv command, which acts as a terminal pipe that measures the data that passes through it. It would be as follows:
dd if = / place / of / origin | pv | dd of = / place / of / destination

As a result, we would get a progress bar in the terminal, the information about bytes transferred, the time it has been running and the transfer rate, all in real time.

Also when finished it shows us statistics of the transfer rate, the total bytes transferred and the total time it took to transfer all the data.

Examples:

Clone a hard drive:

dd if = / dev / sda | pv | dd of = / dev / sdb

Clone a partition:

dd if = / dev / sdc2 | pv | dd of = / dev / sda1

Create an iso image of a partition or hard drive (excellent option for backups):

dd if = / dev / sda1 | pv | dd of = / home / user / backup.iso

In some distros pv may not come installed, so it will be enough to install it to be able to use this tip.


15 comments, leave yours

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Pierr facu said

    Other Tips to create a liveUsb

    dd if = / home / user / isodelsystem.iso | pv | dd of = / dev / sdx (sdx replace by the one corresponding to the pendrive / flash memory)

  2.   Jaime Yepes said

    very useful

  3.   kik1n said

    Very good tip.

  4.   Carlos said

    Thank you very much for the tip.
    Greetings.

  5.   porter said

    magnificent!!! 5*

  6.   rafaelzx said

    I have a question, if there is an iso, will I install it or how do I want the iso? : s

  7.   izkalotl said

    The iso image of a partition can serve as a backup, but it is not like an iso of an operating system, it will not be possible to install a system from an iso generated from a partition.

    For example you can make an iso image of your / home partition that would look like this: my_home.iso and save it on any partition or even another pc, and if by some misfortune you lose your / home partition you could restore it as if nothing had happened with a command like the following:

    dd if = / place / where / is / my_home.iso | pv | dd of = / dev / partition_where_home was

  8.   angel blade said

    More elegant than sending the URS1 signal via kill to the pid of the dd process

  9.   jhabbo said

    Excellent. Another similar tool: mbuffer
    dd if = file.source | mbuffer | dd of = file.destination
    Regards!

  10.   odnetnini III said

    A great tool, that solves problems for everyone, very useful for silent commands, the truth should be set by default in these commands.

  11.   Manuela. said

    Thank you very much for the tip. He had been looking for something like that for a long time. I use it for DVDs

    dd if = / dev / dvd | pv | dd of = / path / file.iso

  12.   Luis said

    Thank you very much.

    1.    let's use linux said

      You're welcome, Luis!

  13.   victor venegas said

    How do I install the pv command?

  14.   host.cl said