-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherase-disk.sh
executable file
·40 lines (26 loc) · 994 Bytes
/
erase-disk.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
diskutil list
echo "Which disk do you want to wipe? (/dev/diskX)"
read -p "Enter the name of the disk: " diskname
diskname=${diskname}
# Disk Erase
echo "------------ ERASING DISK ------------"
diskutil unmountDisk $diskname
gpt destroy $diskname
diskutil eraseDisk ExFAT Untitled $diskname
echo "------------ ERASE COMPLETED ------------"
diskutil list $diskname
# Smart Analysis
echo "------------ SMART ANALYSIS ------------";
smartctl -a $diskname
serialNumber=$(smartctl -a ${diskname} | grep "Serial Number" | awk -F':' '{print $2}' | awk '{ gsub(/ /,""); print }')
echo "------------ DUMPING SMART ANALYSIS TO FILE ------------"
smartctl -a $diskname > ./smart-values/$serialNumber.txt
# Ejecting the device
echo "Do you want to eject? (Default -> yes)?"
read -p "Eject:" eject
eject=${eject:-yes}
if [ "$eject" = "y" ] || [ "$eject" = "Y" ] || [ "$eject" = "yes" ]; then
echo "------------ DISK EJECTED ------------"
diskutil unmountDisk $diskname
fi