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
28939991
Commit
28939991
authored
Aug 09, 2023
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve hdd script
parent
dc699720
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
6 deletions
+9
-6
fix_disk.sh
hdd/fix_disk.sh
+1
-1
functions.sh
hdd/functions.sh
+8
-5
No files found.
hdd/fix_disk.sh
View file @
28939991
...
...
@@ -101,7 +101,7 @@ done
# [23743.306922] blk_update_request: critical medium error, dev sdc, sector 510634067
# [ 6.934350] blk_update_request: I/O error, dev sda, sector 16780432
dmesg |
grep
-E
"(blk_update_request|end_request|print_req_error): (critical medium error|I/O error)"
|
sed
-e
"s|.*, dev
\(
sd[a-z]
\)
, sector
\(
[0-9]*
\)
.*|
\1
\2
|g"
|
sort
-u
|
\
dmesg |
grep
-E
"(blk_update_request|end_request|print_req_error): (critical medium error|I/O error)"
|
sed
-e
"s|.*, dev
\(
[a-z].*
\)
, sector
\(
[0-9]*
\)
.*|
\1
\2
|g"
|
sort
-u
|
\
while
read
devname sector
;
do
#for i in $BLOCKLIST ; do
echo
...
...
hdd/functions.sh
View file @
28939991
...
...
@@ -6,6 +6,9 @@ fatal()
exit
1
}
SUDO
=
''
[
"
$UID
"
=
"0"
]
||
SUDO
=
'sudo'
# arg: /dev/sd?
is_hdd
()
{
...
...
@@ -39,7 +42,7 @@ print_drive_vendor()
{
local
OUT
=
''
local
TF
=
$(
mktemp
)
smartctl
-i
$1
>
$TF
$SUDO
smartctl
-i
$1
>
$TF
OUT
=
"
$(
get_smart_field
$TF
"Model Family"
|
sed
-e
's/ .*//'
)
"
[
-n
"
$OUT
"
]
||
OUT
=
"
$(
get_smart_field
$TF
"Model Number"
|
sed
-e
's/ .*//'
)
"
[
-n
"
$OUT
"
]
||
OUT
=
"
$(
get_smart_field
$TF
"Vendor"
)
"
...
...
@@ -51,7 +54,7 @@ print_drive_product()
{
local
OUT
=
''
local
TF
=
$(
mktemp
)
smartctl
-i
$1
>
$TF
$SUDO
smartctl
-i
$1
>
$TF
OUT
=
"
$(
get_smart_field
$TF
"Device Model"
|
sed
-e
's/ / /'
)
"
[
-n
"
$OUT
"
]
||
OUT
=
"
$(
get_smart_field
$TF
"Model Number"
|
sed
-e
's/ / /'
)
"
[
-n
"
$OUT
"
]
||
OUT
=
"
$(
get_smart_field
$TF
"Product"
)
$(
get_smart_field
$TF
"Revision"
)
"
...
...
@@ -63,7 +66,7 @@ print_drive_rotation()
{
local
OUT
=
''
local
TF
=
$(
mktemp
)
smartctl
-i
$1
>
$TF
$SUDO
smartctl
-i
$1
>
$TF
OUT
=
"
$(
get_smart_field
$TF
"Rotation Rate"
|
sed
-e
's/ .*//'
)
"
echo
"
$OUT
"
rm
-f
$TF
...
...
@@ -150,7 +153,7 @@ print_serno()
{
# 'Serial number' for SAS
# 'Serial Number' for SATA
smartctl
-i
"
$1
"
|
grep
-i
"Serial Number: "
|
sed
-e
"s/.*Serial Number: *//gi"
|
tail
-c
5
$SUDO
smartctl
-i
"
$1
"
|
grep
-i
"Serial Number: "
|
sed
-e
"s/.*Serial Number: *//gi"
|
tail
-c
5
#hdparm -i "$1" | grep "SerialNo=" | sed -e "s/.*SerialNo=//g" | tail -c 5
}
...
...
@@ -158,7 +161,7 @@ print_wwn()
{
# 'Serial number' for SAS
# 'Serial Number' for SATA
smartctl
-i
"
$1
"
|
grep
-i
"LU WWN Device Id: "
|
sed
-e
"s/.*LU WWN Device Id: *//gi"
|
tail
-c
5
$SUDO
smartctl
-i
"
$1
"
|
grep
-i
"LU WWN Device Id: "
|
sed
-e
"s/.*LU WWN Device Id: *//gi"
|
tail
-c
5
#hdparm -i "$1" | grep "SerialNo=" | sed -e "s/.*SerialNo=//g" | tail -c 5
}
...
...
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