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.
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)
very useful
Very good tip.
Thank you very much for the tip.
Greetings.
magnificent!!! 5*
I have a question, if there is an iso, will I install it or how do I want the iso? : s
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
More elegant than sending the URS1 signal via kill to the pid of the dd process
Excellent. Another similar tool: mbuffer
dd if = file.source | mbuffer | dd of = file.destination
Regards!
A great tool, that solves problems for everyone, very useful for silent commands, the truth should be set by default in these commands.
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
Thank you very much.
You're welcome, Luis!
How do I install the pv command?
Thank you
https://www.host.cl