crosutils: refine image_to_usb progress output and performance

Adding "-B 4m" to balance pipe (+10% speed on some SD) and -b to make progress more readable.
Since the size report from pv (k=1024) and dd(k=1000) are different, we also disable dd's summary report to prevent confusion.

BUG=none
TEST=executed: ./image_to_usb.sh --from=... --to=/dev/sdX (ok)

Change-Id: I184c4ce2d9a8274079ddb26f0420ccf8f2a674dd

Review URL: http://codereview.chromium.org/3608013
This commit is contained in:
Hung-Te Lin 2010-10-08 10:35:10 +08:00
parent 4befe39060
commit 7e366a5ed3

View File

@ -237,7 +237,10 @@ then
if [ ${FLAGS_install} -ne ${FLAGS_TRUE} ]; then if [ ${FLAGS_install} -ne ${FLAGS_TRUE} ]; then
echo "Copying ${SRC_IMAGE} to ${FLAGS_to}..." echo "Copying ${SRC_IMAGE} to ${FLAGS_to}..."
if type pv >/dev/null 2>&1; then if type pv >/dev/null 2>&1; then
sudo pv -ptre "${SRC_IMAGE}" | sudo dd of="${FLAGS_to}" bs=4M oflag=sync # pv displays file size in k=1024 while dd uses k=1000.
# To prevent confusion, we suppress the summary report from dd.
sudo pv -ptreb -B 4m "${SRC_IMAGE}" |
sudo dd of="${FLAGS_to}" bs=4M oflag=sync status=noxfer
else else
sudo dd if="${SRC_IMAGE}" of="${FLAGS_to}" bs=4M oflag=sync sudo dd if="${SRC_IMAGE}" of="${FLAGS_to}" bs=4M oflag=sync
fi fi