From afc9c8d0b911f1364fecac0eb58d9e1b83bc566d Mon Sep 17 00:00:00 2001 From: Daniel Erat Date: Sun, 27 Dec 2009 17:55:29 -0800 Subject: [PATCH] Make image_to_usb.sh warn if given a partition. Review URL: http://codereview.chromium.org/522014 --- image_to_usb.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/image_to_usb.sh b/image_to_usb.sh index 7aa6707d29..f824836436 100755 --- a/image_to_usb.sh +++ b/image_to_usb.sh @@ -55,6 +55,18 @@ then # Output to a block device (i.e., a real USB key), so need sudo dd echo "Copying USB image ${FLAGS_from} to device ${FLAGS_to}..." + # Warn if it looks like they supplied a partition as the destination. + if echo $FLAGS_to | grep -q '[0-9]$'; then + drive=$(echo $FLAGS_to | sed -re 's/[0-9]+$//') + if [ -b "$drive" ]; then + echo + echo "NOTE: It looks like you may have supplied a partition as the " + echo "destination. This script needs to write to the drive's device " + echo "node instead (i.e. ${drive} rather than ${FLAGS_to})." + echo + fi + fi + # Make sure this is really what the user wants, before nuking the device if [ $FLAGS_yes -ne $FLAGS_TRUE ] then