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
5d248d50
Commit
5d248d50
authored
Dec 17, 2017
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add scripts for mdadm recover
parent
e9f620b1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
0 deletions
+48
-0
listmdstat.sh
hdd/listmdstat.sh
+10
-0
raid_restore.sh
hdd/raid_restore.sh
+38
-0
No files found.
hdd/listmdstat.sh
0 → 100755
View file @
5d248d50
#!/bin/sh
HDDLIST
=
''
for
i
in
/dev/sd?
;
do
hdparm
-i
$i
|
grep
"Model="
|
grep
"WDC"
&&
HDDLIST
=
"
$HDDLIST
|
$(
basename
$i
)
"
done
# TODO: csed?
cat
/proc/mdstat | egrep
--color
"(NONONO
$HDDLIST
)"
\ No newline at end of file
hdd/raid_restore.sh
0 → 100755
View file @
5d248d50
get_array_uuid
()
{
local
dev
=
"
$1
"
mdadm
-E
$dev
|
grep
"Array UUID : "
|
sed
-e
"s|.*Array UUID : ||"
}
get_md_by_uuid
()
{
#ARRAY /dev/md/1 metadata=1.2 UUID=1912da86:6089954c:2aead1ca:77f06477 name=azbykar.localdomain:1
grep
"UUID=
$1
"
/etc/mdadm.conf |
cut
-d
" "
-f
2
}
get_dm_status
()
{
[
-r
"
$1
"
]
||
return
mdadm
-D
$1
|
grep
"State : "
|
sed
-e
"s|.*State : ||"
}
dmsetup remove_all
for
dev
in
/dev/sd
*
;
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
"
$MDDEV
"
]
||
continue
# TODO: check only missed in array
if
echo
"
$STATUS
"
|
grep
-q
"degraded"
;
then
echo
"
$STATUS
"
|
grep
-q
"recovering"
&&
echo
"Skip
$MDDEV
, already recovering ..."
&&
continue
echo
"Restore degrated
$MDDEV
...."
# TODO: --readwrite for SSD
mdadm
$MDDEV
--re-add
$dev
fi
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