-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathhdcure.sh
More file actions
executable file
·49 lines (42 loc) · 805 Bytes
/
Copy pathhdcure.sh
File metadata and controls
executable file
·49 lines (42 loc) · 805 Bytes
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
41
42
43
44
45
46
47
48
49
#!/usr/bin/env bash
typeset -i i SECTOR MIN MAX rc
SECTOR=$1
DEVICE=/dev/sda
# Find MIN
let rc=1 i=SECTOR
while ((rc != 0)); do
sudo hdparm --read-sector $i $DEVICE > /dev/null 2>&1
rc=$?
if [[ $rc != 0 ]]
then
echo "$i: bad"
MIN=$i
let i--
else
break;
fi
done
echo "Found MIN: $MIN"
# Find MAX
let rc=1 i=SECTOR
while ((rc != 0)); do
sudo hdparm --read-sector $i $DEVICE > /dev/null 2>&1
rc=$?
if [[ $rc != 0 ]]
then
echo "$i: bad"
MAX=$i
let i++
else
break;
fi
done
echo "Found MAX: $MAX"
echo "Write zeros to [$MIN..$MAX?] (y/n)"
read ui
if [[ $ui == 'y' ]]
then
for ((i=MIN;i<=MAX;i++)); do
sudo hdparm --write-sector $i --yes-i-know-what-i-am-doing $DEVICE
done
fi