From 3b9dfcb43fc986e4045a5635f7e185f92a935679 Mon Sep 17 00:00:00 2001 From: Jay Faulkner Date: Fri, 31 Jan 2014 15:13:52 -0800 Subject: [PATCH] speedup(image): Use dd to write image - Converting the image to raw first takes around 2 seconds in a ramdisk, but using dd to image the disk speeds up imaging almost 2x by allowing use of direct IO and blocksizes. - We may need, in the future, to be able to configure the options passed to dd based on the hardware we're imaging onto. These options have been confirmed as better than qemu-img on most hardware. --- teeth_agent/shell/write_image.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/teeth_agent/shell/write_image.sh b/teeth_agent/shell/write_image.sh index 5a2835230..ad68298b8 100755 --- a/teeth_agent/shell/write_image.sh +++ b/teeth_agent/shell/write_image.sh @@ -27,8 +27,14 @@ DEVICE="$2" log "Erasing existing mbr from ${DEVICE}" dd if=/dev/zero of=$DEVICE bs=512 count=10 -# Converts image to raw and writes to device -log "Imaging $IMAGEFILE onto $DEVICE" -qemu-img convert -O raw $IMAGEFILE $DEVICE +## Doing two steps allows us to use dd, which allows us to tweak things like +## blocksize and allows use of direct io +# Converts image to raw +log "Imaging $IMAGEFILE to RAW format" +qemu-img convert -O raw $IMAGEFILE /tmp/image.raw + +# Write image onto device +log "Imaging $DEVICE" +dd if=/tmp/image.raw of=$DEVICE bs=64K oflag=direct log "${DEVICE} imaged successfully!"