From 4732d5d0c39da39f2098c3e19cb5f7dcd7d429bb Mon Sep 17 00:00:00 2001 From: Hung-Te Lin Date: Mon, 4 Oct 2010 11:01:11 +0800 Subject: [PATCH] crosutils: Improve dd in image_to_usb.sh 1. add oflags=sync to allow interrupting dd without hanging system I/O for a long time (since bs=4M, the speed is almost the same) 2. use pv to provide progress report if available. (add pv into host-depends in http://codereview.chromium.org/3608004) BUG=none TEST=manually: 1. install pv in chroot, then execute image_to_usb.sh --to /dev/sdX and verified there's progress bar 2. ctrl-c to break the dd process and verified it can stop immediately 3. remove pv from chroot, then execute image_to_usb.sh and verify that it still works Change-Id: I62fc373a4feee6d7e61897325d9e1e6d84a74d63 Review URL: http://codereview.chromium.org/3581007 --- image_to_usb.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/image_to_usb.sh b/image_to_usb.sh index f40e57a4a3..81a3ab58dd 100755 --- a/image_to_usb.sh +++ b/image_to_usb.sh @@ -236,7 +236,11 @@ then if [ ${FLAGS_install} -ne ${FLAGS_TRUE} ]; then echo "Copying ${SRC_IMAGE} to ${FLAGS_to}..." - sudo dd if="${SRC_IMAGE}" of="${FLAGS_to}" bs=4M + if type pv >/dev/null 2>&1; then + sudo pv -ptre "${SRC_IMAGE}" | sudo dd of="${FLAGS_to}" bs=4M oflag=sync + else + sudo dd if="${SRC_IMAGE}" of="${FLAGS_to}" bs=4M oflag=sync + fi sync else if [ ${INSIDE_CHROOT} -ne 1 ]; then