This article is all  about getting a progress bar, or progress output (usually dd is silent).
DD PROGRESS OUTPUT
##################
To get dd progress, launch dd and then get its pid
dd [options] &
PID will show when an app is backgrounded
(if not use ps aux | grep dd to get pid)
kill -USR1 <put dd pid here>
example: kill -USR1 1002
Tip to help remember USR1: For the kill method remember user1, the number one user gets to see all of the stats and options, so kill with signal USR1 pointed at dd gives you progress
REQUIREMENTS: probably have to be in chroot, you need to be in /bin/bash and not /sh
dd if=/dev/sda1 of=/kostia/sda1-bak bs=4M& sleep 1 && pid=`pidof dd`; while [[ -d /proc/$pid ]]; do kill -USR1 $pid && sleep 10 && clear; done
NOTE: This will show progress but if you cancel out of it with CONTROL-C its still running to completely stop it get its process id (pid) and kill it.
ps aux | egrep -i “d[d]”
WHATS THE DEAL WITH [d]? Well usually grep finds its own process in ps when ever you look for a process so this just removes it, its identical -well not really, but seems to have the same effect- to: ps aux | egrep -i “dd” | egrep -v egrep
or
pidof dd
For me it was 3186
kill -9 3186
killall -9 dd
DD WITH A PROGRESS BAR
######################
INSTALLING
==========
REQUIREMENTS: Need to install an app called pv and probably be in chroot
First check internet:
ping 8.8.8.8
ping www.google.com
If you can ping both continue
If you can ping 8.8.8.8 but not www.google.com then you need to specify a dns server:
echo “nameserver 8.8.8.8” > /etc/resolv.conf
If you cant ping either then check networking issues either as configured on linux or in your network
Installing time:
apt-get update
apt-get -y install pv
How to use pv:
http://www.catonmat.net/blog/unix-utilities-pipe-viewer/
USE
===
My recap about pv use:
* pv can be put between 2 processes where it catches bytes from stdin and pushes them to stdout while measuring speed, etc. – in this case to see ETA and progress bar you need to specify the size of file in bytes with –size or -s parameter next to pv.
* pv is also like a “cat” where it outputs to stdout, so you can use it to read a file if you want and below it will show you how fast it read it – pv knows the size of the file in this case so you dont need to specifiy –size, or -s it will show you the progress and ETAs automatically
SIMILAR TOPIC FOUND ONLINE USING PV WITH DD AND LIKE CAT
=========================================================
Exerpt from online blog:
From the package description:
pv – Pipe Viewer – is a terminal-based tool for monitoring the progress of data through a pipeline. It can be inserted into any normal pipeline between two processes to give a visual indication of how quickly data is passing through, how long it has taken, how near to completion it is, and an estimate of how long it will be until completion.
Install pv and put it between input / output only dd commands.
Note: you cannot use it when you already started dd.
dd if=/dev/urandom | pv | dd of=/dev/null
Output:
1,74MB 0:00:09 [ 198kB/s] [      <=>                               ]
You could specify the approximate size with the –size (or -s) if you want a time estimation, units are bytes.
Other uses – like a cat:
You can also use it to output to stdout:
pv /home/user/bigfile.iso | md5sum
Output
50,2MB 0:00:06 [8,66MB/s] [=======>         ] 49% ETA 0:00:06
Note: that in this case, pv recognizes the size automatically.
MEASURING SPEEDS/BOTTLENECK WITH PV:
====================================
* in these examples pv always outputs the slowest speed, so it will show you the bottleneck
* in these i let the average speed stabalize
# pv /dev/zero > /dev/null
.7GB 0:00:06 [15.8GB/s] [      <=>                                                   ]
# pv /dev/zero | md5sum
7GB 0:00:05 [ 426MB/s] [     <=>                                                    ]
# pv /dev/urandom | md5sum
66MB 0:00:04 [16.5MB/s] [    <=>                                                     ]
# pv /dev/urandom > /dev/null
37MB 0:00:08 [17.1MB/s] [         <=>                                                ]
* Notice that /dev/zero can spit to /dev/null @ 15.8 GB/s MB/s so you can assume thats the read speed from /dev/zero
* Now look at calculating /dev/zero thru md5sum its much slower 425 MB/s. So md5sum slowed it down. We know the max speed of md5sum is 426 MB/s. So now the question is how fast is it to read from our random number generator which we know to be slow? And with that speed in mind will it slow down through md5sum? My logical assumption is if urandom read to null is slower then 425 then it shouldnt be slowed down if we calc urandom thru md5sum… And thats the case notice that /dev/urandom to md5sum is 16.5 MB/s and to null is just a tiny bit faster 17.1 MB/s
WITH DD
=======
SIMPLE
# dd if=/dev/sda | pv| dd of=/kostia/test1
SIMPLE (Note you can specify the bs just on the first dd, but i feel better doing it to both)
# dd if=/dev/sda bs=1M | pv | dd of=/kostia/test1 bs=1M
ABOVE JUST SHOWS SPEED BUT TO GET EVERYTHING NEED TO SPECIFY SIZE IN BYTES
FOR JUST A DISK YOU CAN DO THIS TO GET THE SIZE:
fdisk -l /dev/sda
AT TOP WILL SHOW SIZE IN BYTES:
FOR ME IT WAS 21474836480
FOR LOGICAL VOLUME:
lvdisplay –units b
IF YOU ONLY HAVE ONE LOGICAL VOLUME:
lvdisplay –units b | awk ‘/LV Size/ { print $3 }’
WILL SHOW YOU THE LOGICAL VOLUMES SIZE UNDER THE lv size attribute
IF YOU HAVE A RAID MD:
mdadm -D /dev/md2
THEN THE Array Size IS SPECIFIED IN Kilobytes SO MULTIPLY IT BY 1024
mdadm -D /dev/md2 | awk ‘/Array Size/ { print $3 }’
OR IN ONE SHOT – Just change the md2 to match your raid:
ANSWER IN BYTES:
mdadm -D /dev/md2 | awk ‘/Array Size/{printf(“%s\n”,$4*1024)}’
OR:
mdadm -D /dev/md2 | awk ‘/Array Size/{print($4*1024)}’
IF YOU GET AN e IN YOUR ANSWER THEN ITS BEST TO TAKE THE NUMBER FROM KILOBYTES AND MULT BY 1024 IN GOOGLE:
mdadm -D /dev/md2 | awk ‘/Array Size/{print($4)}’
THEN IN GOOGLE SEARCH “X kilobytes = ? bytes” WHERE X YOU PUT THE NUMBER YOU GOT FROM RUNNING ABOVE COMMAND
OR SEARCH THE SAME THING IN wolframalpha.com
OR JUST MULT THE # BY 1024
AFTER YOU GET THE SIZE PUT IT HERE AFTER THE S:
# dd if=/dev/sda bs=1M | pv -s 21474836480 | dd of=/kostia/test1 bs=1M
TO IMAGE DISK
#############
Dont use dd
Use ddrescue (or dd_rescue if your stuck with the old one)

Leave a Reply

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