Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
etersoft-admin-essentials
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
etersoft-admin-essentials
Commits
df625fe1
Commit
df625fe1
authored
Jan 13, 2018
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update raid scripts
parent
f339d0cf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
89 additions
and
0 deletions
+89
-0
fail_ssd.sh
hdd/fail_ssd.sh
+45
-0
raid_restore.sh
hdd/raid_restore.sh
+44
-0
No files found.
hdd/fail_ssd.sh
0 → 100755
View file @
df625fe1
#!/bin/sh
is_hdd
()
{
# /dev/sd?
local
drive
=
"
$(
echo
"
$1
"
|
cut
-c1-8
)
"
[
-b
"
$drive
"
]
||
fatal
hdparm
-i
"
$drive
"
|
grep
-q
"Model=WDC"
}
dev_in_md
()
{
local
md
=
"
$1
"
local
dev
=
"/dev/sd"
mdadm
-D
"
$md
"
|
grep
"
$dev
"
|
sed
-e
"s|.*
$dev
|
$dev
|"
}
print_dev_type
()
{
is_hdd
$dev
&&
echo
"HDD"
||
echo
"SSD"
}
#mdadm /dev/$md --remove /dev/sda1
#mdadm /dev/$md --add /dev/sda1
#echo 'repair' >/sys/block/$md/md/sync_action
echo
"Drive list:"
for
dev
in
/dev/sd?
;
do
echo
"
$(
print_dev_type
$dev
)
:
$dev
"
done
echo
for
md
in
/dev/md?
*
;
do
echo
"Process
$md
..."
for
dev
in
$(
dev_in_md
$md
)
;
do
echo
"
$(
print_dev_type
$dev
)
:
$dev
"
is_hdd
$dev
&&
continue
[
"
$1
"
=
"--fail"
]
||
continue
# TODO with SSD
echo
"# mdadm
$dm
--fail
$dev
"
mdadm
$md
--fail
$dev
done
done
hdd/raid_restore.sh
View file @
df625fe1
...
...
@@ -8,6 +8,7 @@ get_array_uuid()
get_md_by_uuid
()
{
#ARRAY /dev/md/1 metadata=1.2 UUID=1912da86:6089954c:2aead1ca:77f06477 name=azbykar.localdomain:1
# TODO: use UUID: in mdadm -D /dev/md?
grep
"UUID=
$1
"
/etc/mdadm.conf |
cut
-d
" "
-f
2
}
...
...
@@ -17,13 +18,45 @@ get_dm_status()
mdadm
-D
$1
|
grep
"State : "
|
sed
-e
"s|.*State : ||"
}
is_hdd
()
{
# /dev/sd?
local
drive
=
"
$(
echo
"
$1
"
|
cut
-c1-8
)
"
[
-b
"
$drive
"
]
||
fatal
hdparm
-i
"
$drive
"
|
grep
-q
"Model=WDC"
}
dev_in_md
()
{
local
md
=
"
$1
"
local
dev
=
"/dev/sd"
mdadm
-D
"
$md
"
|
grep
"
$dev
"
|
sed
-e
"s|.*
$dev
|
$dev
|"
}
print_dev_type
()
{
is_hdd
$dev
&&
echo
"HDD"
||
echo
"SSD"
}
dmsetup remove_all
echo
"Drive list:"
for
dev
in
/dev/sd?
;
do
echo
"
$(
print_dev_type
$dev
)
:
$dev
"
done
DEVS
=
"/dev/sd*"
[
-n
"
$1
"
]
&&
DEVS
=
"
$1
"
for
dev
in
$DEVS
;
do
ARRAYUUID
=
$(
get_array_uuid
$dev
)
[
-n
"
$ARRAYUUID
"
]
&&
MDDEV
=
$(
get_md_by_uuid
$ARRAYUUID
)
||
MDDEV
=
''
STATUS
=
"
$(
get_dm_status
$MDDEV
)
"
echo
"
$dev
-
$ARRAYUUID
-
$MDDEV
, status:
$STATUS
"
[
-n
"
$ARRAYUUID
"
]
&&
[
-z
"
$MDDEV
"
]
&&
echo
"!!!! can't detect md for
$dev
"
[
-n
"
$MDDEV
"
]
||
continue
# TODO: check only missed in array
if
echo
"
$STATUS
"
|
grep
-q
"degraded"
;
then
...
...
@@ -34,4 +67,14 @@ for dev in /dev/sd? ; do
fi
done
echo
echo
"Drives not in RAID:"
for
dev
in
/dev/sd
*
;
do
# strict
cat
/proc/mdstat |
grep
-q
"
$(
basename
$dev
)
\[
"
&&
continue
# use parts from it
cat
/proc/mdstat |
grep
-q
"
$(
basename
$dev
)
[0-9]*
\[
"
&&
continue
echo
"
$dev
"
done
# TODO: how to check?
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment