Skip to content

Instantly share code, notes, and snippets.

@josch
Created July 2, 2015 16:46
Show Gist options
  • Save josch/ba0617edc27018438d0a to your computer and use it in GitHub Desktop.
Save josch/ba0617edc27018438d0a to your computer and use it in GitHub Desktop.
#!/bin/sh
set -x
set -e
DEV=/dev/sdb
if ! sudo parted -lm 2>/dev/null | grep scsi | grep "$DEV" > /dev/null; then
echo "refusing to work on a device that is not a scsi disk" >&2
exit 1
fi
if sudo fdisk -l "$DEV" | grep "^$DEV" > /dev/null; then
echo "refusing to work on partitioned drive" >&2
echo "if you are sure, you might want to call `sgdisk --zap-all $DEV`" >&2
exit 1
fi
sudo sgdisk --new 0:0:100M --new 0:0:0 "$DEV"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment