forked from pocopico/tinycore-redpill
-
Notifications
You must be signed in to change notification settings - Fork 32
/
edisk.sh
executable file
·21 lines (20 loc) · 836 Bytes
/
edisk.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash
for edisk in $(sudo fdisk -l | grep "Disk /dev/sd" | awk '{print $2}' | sed 's/://' ); do
model=$(lsblk -o PATH,MODEL | grep $edisk | head -1)
echo
echo
if [ $(sudo fdisk -l | grep "83 Linux" | grep ${edisk} | wc -l ) -gt 0 ]; then
echo "Skip this disk as it is a loader disk. $model"
continue
else
echo "Erase Disk. $model"
while true; do
read -r -p "Can I really erase this disk $edisk? (yY/nN) : " answer
case $answer in
[Yy]* ) sudo dd if=/dev/zero of=${edisk} bs=1k count=1; sudo blockdev --rereadpt ${edisk}; echo "Disk Erase Complete. $edisk"; break;;
[Nn]* ) echo "Cancel Erase Disk. $edisk"; break;;
* ) echo "Please answer y or Y or n or N";;
esac
done
fi
done