Skip to content

Instantly share code, notes, and snippets.

@nikolareljin
Last active June 8, 2021 14:01
Show Gist options
  • Save nikolareljin/78175e2d9574028b29e7192adc67dbf1 to your computer and use it in GitHub Desktop.
Save nikolareljin/78175e2d9574028b29e7192adc67dbf1 to your computer and use it in GitHub Desktop.
# ------------------------------------------------
# Clone the drives with GUI dialog.
# Uses `dialog` which needs to be installed first..
#
# Use:
# gui_dd <input drive> <output drive>
# ------------------------------------------------
function gui_dd() {
in_d=$1
out_d=$2
if [[ -z $in_d ]] || [[ -z $out_d ]]; then
echo "Input and output drives not specified!"
exit 1
}
if [[ -z $(which pv) ]]; then
echo "Please install pv cli tool"
exit 1
fi
if [[ -z $(which dialog) ]]; then
echo "Dialog not installed. fallback to non-gui"
dd if=${in_d} of=${out_d} bs=128M
else
(pv -n ${in_d} | dd of=${out_d} bs=128M conv=notrunc,noerror) 2>&1 | \
dialog --gauge "Clonning drive ${in_d} -> ${out_d}, please wait..." 10 70 0
clear
fi
echo "Clonning completed"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment