diff options
author | Jonas Gunz <himself@jonasgunz.de> | 2020-02-04 15:19:53 +0100 |
---|---|---|
committer | Jonas Gunz <himself@jonasgunz.de> | 2020-02-04 15:19:53 +0100 |
commit | 801ef3965191aae15e1ffd482bec642bac6c7105 (patch) | |
tree | f12188505d620342643ec90d4c826fb029ab2400 /scripts | |
parent | af53908079962c3208d2dbf6a2c98b5862f4c0b5 (diff) | |
download | dotfiles-801ef3965191aae15e1ffd482bec642bac6c7105.tar.gz |
Added scripts/ Added bootusb
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/bootusb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/scripts/bootusb b/scripts/bootusb new file mode 100755 index 0000000..7f80501 --- /dev/null +++ b/scripts/bootusb @@ -0,0 +1,44 @@ +#!/bin/bash + +if [ $# -ne 2 ] +then + echo Usage: $0 SOURCE SINK + exit 1 +fi + +if [ ! -e $1 -o ! -e $2 ] +then + echo "Filename(s) invalid." + exit 2 +fi + +if grep $2 /etc/mtab > /dev/null +then + echo Device is mounted. Aborting + exit 3 +fi + +read -p "Writing $1 to $2. Continue? (y/N)" cont +case $cont in + [yY]);; + *) + echo Aborting. + exit 4;; +esac + +sudo -v + +FILESIZE=$(du -b $1 | cut -f 1) +BLOCKSIZE=$(sudo blockdev --getsize64 $2) + +if [ $FILESIZE -gt $BLOCKSIZE ] +then + echo $1 is too large for $2. + exit 5 +fi + +echo Writing $FILESIZE Bytes to $2 + +dd if=$1 | pv --size $FILESIZE | sudo dd of=$2 + +exit 0 |