This repository has been archived by the owner on Aug 16, 2021. It is now read-only.
forked from kmova/zfs-utilities
-
Notifications
You must be signed in to change notification settings - Fork 3
/
format_disk.sh
66 lines (66 loc) · 1.64 KB
/
format_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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh
##This script will format the new disk.
#Usages:sh format.sh da(number).EG- sh format.sh da2
if [ $# -lt 1 ]
then
echo "Usages: $0 danumber"
exit;
fi
number=$1
timestamp=$(date +"%d%h%Y_%H%M")
FILE=/root/support/"newdisk_$timestamp"
mkdir -p $FILE
procstat -kka > $FILE/proc.out.1
grep "dnode_special_close" $FILE/proc.out.1
if [ $? -eq 0 ]
then
echo "Please contact CloudByte Support"
echo "Cannot proceed as dnode_special_close situation on Node"
exit
fi
pgrep "zpool|zfs|gmultipath|smartctl|sg_persist"
if [ $? -eq 0 ]
then
count=1
while [ $count -lt 11 ]
do
echo $count
sleep 1
pgrep "zpool|zfs|gmultipath|smartctl|sg_persist"
if [ $? -ne 0 ]
then
break
fi
count=`expr $count + 1`
if [ $count -eq 11 ]
then
echo"Cannot format the disk as command are in hang state "
exit
fi
done
fi
cd $FILE
echo "Executing zpool status"
zpool status > $FILE/zpoolstatus.out
echo "camcontrol output"
camcontrol devlist > $FILE/cam.out
echo "Executing gmultipath status"
gmultipath status > $FILE/gmultipath.out
echo "smartctl output of disk "
smartctl -x -T permissive /dev/$number > $FILE/smart_$number.out
echo $number
grep $number gmultipath.out
if [ $? -eq 0 ]
then
echo "Check the da path is correct as it already labelled"
echo "Else please contact CloudByte Support"
exit
else
echo "Starting formatting of disk "
echo "Collected files are located at "$FILE
nohup camcontrol format /dev/$number -qy > /dev/null 2>&1 &
echo "Camcontrol format will take some to complete"
echo "You can check the status using the below command"
echo "## camcontrol format /dev/$number -r ##"
exit
fi