Created
April 9, 2015 07:08
-
-
Save gdunstone/4d27b424ee5ca253cd00 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -lt 1 ] | |
then | |
echo "USAGE: $0 <block device>" | |
exit 1 | |
fi | |
read -p "about to format $1, Are you sure?" -n 1 -r | |
echo # (optional) move to a new line | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
echo -e "o\nn\np\n\n\n+100M\nt\nc\nn\n\n\n\n\nw\n" | fdisk $1 | |
fi | |
read -p "copying over, erase everything in root and boot?" -n 1 -r | |
echo # (optional) move to a new line | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
tmp=/tmp/spc_os_format_$RANDOM | |
devs=($1*) | |
mkdir -p $tmp/root | |
mkdir -p $tmp/boot | |
mount $devs[1] $tmp/boot | |
mount $devs[2] $tmp/root | |
tar -xvf SPC-OS*.tar.gz -C $tmp | |
umount $tmp/boot | |
umount $tmp/root | |
rm -rf $tmp | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment