Skip to contentSkip to conversation

Disk Monitoring

DISCUSSION Wolfgang Denk 8 participants 19 messages Jun 28, 2017 – Jul 1, 2017 MD RAID

lore
Share & tools
lore
#0 lore raw

Dear Gandalf,

Quoted 5 lines · In message <CAJH6TXgvrVckHDmh1oiN9mupLrsS2NP3J44bG1_wE9Nnx4=yHQ@mail.gmail.com>…

1) all raid controllers have proactive monitoring features, like patrol read, consistency check and (more or less) some SMART integration.
Any counterpart in mdadm?

As Wol already pointed out, you should use smaartctl to monitor the state of the disk drives, ideally on a regular base. Changes (increases) of numbers like "Reallocated Sectors", ""Current Pending Sectors" or ""Offline Uncorrectable Sectors" are always suspicious. If they increase just by one, and then stay constant for weeks you can probably ignore it. But if you see I/O errors in the system logs and/or "Reallocated Sectors" increasing every few days then you should not wait much longer and replace the respective drive.

Attached are two very simple scripts I use for this purpose; "disk-test" simply runs smartctl on all /dev/sd? devices and parses the output. The result is something like this:

$ sudo disk-test
=== /dev/sda : ST1000NM0011 S/N Z1N2RA6E *** ERRORS ***
        Reallocated Sectors:     1
=== /dev/sdb : ST2000NM0033-9ZM175 S/N Z1X1J1K9 OK
=== /dev/sdc : ST2000NM0033-9ZM175 S/N Z1X1JEF6 OK
=== /dev/sdd : ST2000NM0033-9ZM175 S/N Z1X4XSN9 OK
=== /dev/sde : ST2000NM0033-9ZM175 S/N Z1X4X6G8 OK
=== /dev/sdf : ST2000NM0033-9ZM175 S/N Z1X54EA1 OK
=== /dev/sdg : ST2000NM0033-9ZM175 S/N Z1X5443W OK
=== /dev/sdh : ST2000NM0033-9ZM175 S/N Z1X4XAHQ OK
=== /dev/sdi : ST2000NM0033-9ZM175 S/N Z1X4X6NB OK
=== /dev/sdj : TOSHIBA MK1002TSKB S/N 32E3K0K2F OK
=== /dev/sdk : TOSHIBA MK1002TSKB S/N 32F3K0PRF OK
=== /dev/sdl : TOSHIBA MK1002TSKB S/N 32H3K10CF *** ERRORS ***
        Reallocated Sectors:     1
=== /dev/sdm : TOSHIBA MK1002TSKB S/N 32H3K0ZLF OK
=== /dev/sdn : TOSHIBA MK1002TSKB S/N 32H3K104F OK
=== /dev/sdo : TOSHIBA MK1002TSKB S/N 32H1K31DF OK
=== /dev/sdp : TOSHIBA MK1002TSKB S/N 32F3K0PUF OK
=== /dev/sdq : TOSHIBA MK1002TSKB S/N 32E3K0JZF OK

Here I have two drives with 1 reallocated sector each, which I consider harmeless as it has stayed constant for several months.

The second script "disk-watch" is intended to be run as a cron job on a regular base (here usually twice per day). It will send out email whenever the state changes (don't forget to adjust the MAIL_TO setting). You may also want to clean up the entries in /var/log/diskwatch every now and then (or better add it to your logrotate configuration).

HTH.

Best regards,

Wolfgang Denk

Signature · 7 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]
Yes, it's a technical challenge, and  you  have  to  kind  of  admire
people  who go to the lengths of actually implementing it, but at the
same time you wonder about their IQ...
         --  Linus Torvalds in <[email protected]>

#!/bin/sh

DISKS="$(echo /dev/sd?)"

PATH=$PATH:/sbin:/usr/sbin

for i in ${DISKS}
do

	SMARTDATA=$(smartctl -a $i | \
	egrep 'Device Model:|Serial Number:|Reallocated_Sector_Ct|Current_Pending_Sector|Offline_Uncorrectable|failed|Unknown USB' | \
	grep -v ' -  *0$')
	LINES=$(echo "${SMARTDATA}" | wc -l)
	HEAD=$(echo "${SMARTDATA}" | \
	       sed -n -e 's/Device Model: //p' \
		      -e 's!Serial Number:!S/N!p')	
	BODY=$(echo "${SMARTDATA}" | \
	       awk '$2 ~ /Reallocated_Sector_Ct/	{ printf "Reallocated Sectors:   %3d\n", $10 }
		    $2 ~ /Current_Pending_Sector/	{ printf "Current Pending Sect:  %3d\n", $10 }
		    $2 ~ /Offline_Uncorrectable/	{ printf "Offline Uncorrectable: %3d\n", $10 }
		    $0 ~ /failed:.*AMCC/		{ printf "Unsupported AMCC/3ware controller\n" }
		    $0 ~ /SMART command failed/		{ printf "Device does not support SMART\n" }
		    $0 ~ /Unknown USB bridge/		{ printf "Unknown USB bridge\n" }
		'
	     )
	if [ $LINES -eq 2 ]
	then
		echo === $i : ${HEAD} OK
	else
		echo === $i : ${HEAD} "*** ERRORS ***"
		echo "${BODY}" | sed -e 's/^/	/'
	fi

done

#!/bin/sh

D_TEST=/usr/local/sbin/disk-test
D_LOGDIR=/var/log/diskwatch
MAIL_TO="root"

[ -x ${D_TEST} ] || { echo "ERROR: cannot execute ${D_TEST}" >&2 ; exit 1 ; }

[ -d ${D_LOGDIR} ] || \
	mkdir -p ${D_LOGDIR} || \
		{ echo "ERROR: cannot create ${D_LOGDIR}" >&2 ; exit 1 ; }

cd ${D_LOGDIR} || { echo "ERROR: cannot cd ${D_LOGDIR}" >&2 ; exit 1 ; }

rm -f previous

[ -L latest ] && mv latest previous

NOW=$(date "+%F-%T")

${D_TEST} >${NOW}

ln -s "${NOW}" latest

DIFF=''

[ -r previous ] && DIFF=$(diff -u previous latest)

[ -z "${DIFF}" ] && exit 0

mailx -s "$(hostname): SMART DISK WARNING" ${MAIL_TO} <<+++ Disk status change:
${DIFF}

Recent results:
$(cat latest)
+++

#1 lore raw

2017-06-28 15:19 GMT+02:00 Wolfgang Denk <[email protected]>:

Quoted 8 lines

As Wol already pointed out, you should use smaartctl to monitor the state of the disk drives, ideally on a regular base. Changes (increases) of numbers like "Reallocated Sectors", ""Current Pending Sectors" or ""Offline Uncorrectable Sectors" are always suspicious. If they increase just by one, and then stay constant for weeks you can probably ignore it. But if you see I/O errors in the system logs and/or "Reallocated Sectors" increasing every few days then you should not wait much longer and replace the respective drive.

Sure, but smart is not always reliable.
My personal experience was that Patrol Read feature on LSI controllers [1] saved me multiple times. During a patrol read some bad sectors where found (probably in an unallocated part of the array, thus the OS doesn't know anything about that).

I've proactive replaced the drive and the day after resync, another disk failed totally.
Without "Patrol Read" that scrubs all disks, one by one (consistency check is a different thing),
probably this server would fails totally with data loss

Linux kernels detect something bad only by accessing to the failed sector. If that sector is not used,
kernel knows nothing. HW RAID like LSI are able to read the whole disks, block by block, even the unused part,
detecting failures before something is trying to write to that sector.

If you have a bad sector on an unused part of the array, when you have to rebuild due to another disk failure, you'll
hit a URE and the whole array is failed.

Simple example:

disk0 has sector X (unused) failed.
It's unused, thus, kernel knows nothing about that and is operting normally, no warning message or anything. If you don't access sector X, you wont be notified.

Now, disk1 hard-fail. You have to replace that.
During the resync, you have to resync the whole array, but disk0, sectorX is unreadable.
The resync will fail and the whole array is down.

Am I missing something?

[1] http://www.dell.com/downloads/global/power/ps1q06-20050212-Habas.pdf

#2 lore raw

Am 29.06.2017 um 11:52 schrieb Gandalf Corvotempesta:

Quoted 9 lines

Linux kernels detect something bad only by accessing to the failed sector. If that sector is not used,
kernel knows nothing. HW RAID like LSI are able to read the whole disks, block by block, even the unused part,
detecting failures before something is trying to write to that sector

If you have a bad sector on an unused part of the array, when you have to rebuild due to another disk failure, you'll
hit a URE and the whole array is failed

there is nothing like "unused part of the array" since the linux-raid-layer knows nothing about the filesystem on top and hence a raid-check (scrub) reads every block as said hardware controller

#3 lore raw

2017-06-29 12:10 GMT+02:00 Reindl Harald <[email protected]>:

Quoted 3 lines

there is nothing like "unused part of the array" since the linux-raid-layer knows nothing about the filesystem on top and hence a raid-check (scrub) reads every block as said hardware controller

Yes, this during a scrub.
Without a scrub, kernel know nothing about an unused part of the array.

Let's assume a unreadable sector is found during a scrub. What happens? mdadm kick-out the disk from the array? It tried to reallocate the failed sector somewhere keeping the disk up and running (and thus, resolving the URE that would prevent a successful resync?)

#4 lore raw

Am 29.06.2017 um 12:14 schrieb Gandalf Corvotempesta:

Quoted 5 lines

2017-06-29 12:10 GMT+02:00 Reindl Harald <[email protected]>:

Quoted 3 lines

there is nothing like "unused part of the array" since the linux-raid-layer knows nothing about the filesystem on top and hence a raid-check (scrub) reads every block as said hardware controller

Quoted 7 lines

Yes, this during a scrub.
Without a scrub, kernel know nothing about an unused part of the array.

Let's assume a unreadable sector is found during a scrub. What happens? mdadm kick-out the disk from the array? It tried to reallocate the failed sector somewhere keeping the disk up and running (and thus, resolving the URE that would prevent a successful resync?)

it tries to re-write the data block (depending if repair is enabled)

normally the disk firmware itself is aware of that event and realloctes a spare block so the rewrite just suceeds until the disk runs out of spare sectors

but well, even if it just kicks out the disk soon enough you can replace it, the array rebuilds and nothing happened - without smart-check/scrub sooner or later it's detected due rebuild after a disk failed and the array is gone

#5 lore raw
In reply to Gandalf Corvotempesta
Quoted 5 lines · Gandalf Corvotempesta

2017-06-29 12:10 GMT+02:00 Reindl Harald <[email protected]>:

Quoted 3 lines

there is nothing like "unused part of the array" since the linux-raid-layer knows nothing about the filesystem on top and hence a raid-check (scrub) reads every block as said hardware controller

Quoted 7 lines

Yes, this during a scrub.
Without a scrub, kernel know nothing about an unused part of the array.

Let's assume a unreadable sector is found during a scrub. What happens? mdadm kick-out the disk from the array? It tried to reallocate the failed sector somewhere keeping the disk up and running (and thus, resolving the URE that would prevent a successful resync?)

As I said, read up on disk failure modes. If mdadm finds an unreadable sector, it does a full stripe read, recalculates the unreadable sector, and writes it back.

If the read failed because the magnetism has decayed, this will reset it and everything will be hunky-dory again.

If the read failed because the magnetic layer is failing, it will trigger a relocate (which SMART should pick up) and alarm bells should start ringing. It might be benign, the magnetic properties of the layer might be failing such that that bit can no longer record properly, or it could be that the layer itself is starting to fail, at which point you are heading for platter failure, a head crash, and serious pain.

Cheers,
Wol

#6 lore raw
In reply to Gandalf Corvotempesta
Quoted 11 lines · Gandalf Corvotempesta

disk0 has sector X (unused) failed.
It's unused, thus, kernel knows nothing about that and is operting normally, no warning message or anything. If you don't access sector X, you wont be notified.

Now, disk1 hard-fail. You have to replace that.
During the resync, you have to resync the whole array, but disk0, sectorX is unreadable.
The resync will fail and the whole array is down.

Am I missing something?

Not really. It's just that you have to set up the monitoring yourself, whichever way you feel comfortable with.

SMART has a selftest feature which causes the disk to read sectors. You can do whole disk at once (long selftest) or in segments (selective selftest). I prefer the selective since that allows you to place the selftest in the time window of least activity.

Instead of spending an entire day (or two) testing the whole drive you can put in an hour or two of testing every night and have it cover the entire drive over X days.

mdadm can also perform RAID checks, reading everything including parity, RAID layer would attempt to fix read errors then, and you can also check mismatch_cnt.

The mdadm checks can also done region by region to distribute load over several days but I think it's still not a direct option for mdadm, the region can be set via /proc or /sys somewhere...

Both smartmontools and mdadm should be set up to run such checks periodically, and instantly notify you by email if any problem occurs.

If a disk has problems, replace it, otherwise it's a gamble. Whatever promises RAID makes regarding redundancy, it always assumes the other drives to work 100%.

It's very unlikely to encounter read errors during rebuild if you ran regular checks and didn't forcibly keep bad drives.

Regards
Andreas Klauer

#7 lore raw
In reply to Gandalf Corvotempesta
Quoted 3 lines · On Thursday 29 of June 2017 11:52:01 Gandalf Corvotempesta wrote:

During a patrol read some bad sectors where found (probably in an unallocated part of the array, thus the OS doesn't know anything about that).

One can read of all disks/partitions used by RAIDs by script /usr/share/mdadm/checkarray

In many distros it is set to be performed monthly out-of-box.

Signature · 4 lines
Mateusz Korniak
"(...) mam brata - poważny, domator, liczykrupa, hipokryta, pobożniś,
 	krótko mówiąc - podpora społeczeństwa."
				Nikos Kazantzakis - "Grek Zorba"
#8 lore raw

2017-06-29 12:14 GMT+02:00 Mateusz Korniak <[email protected]>:

Quoted 4 lines

One can read of all disks/partitions used by RAIDs by script /usr/share/mdadm/checkarray

In many distros it is set to be performed monthly out-of-box.

I know this and I'm running weekly. (just to be sure)
What Is unclear to me is why an hardware raid controller like LSI, has two different kind of checks: patrol read and consistency check.

#9 lore raw
Quoted 9 lines · Gandalf Corvotempesta

2017-06-29 12:14 GMT+02:00 Mateusz Korniak <[email protected]>:

Quoted 4 lines

One can read of all disks/partitions used by RAIDs by script /usr/share/mdadm/checkarray

In many distros it is set to be performed monthly out-of-box.

I know this and I'm running weekly. (just to be sure)
What Is unclear to me is why an hardware raid controller like LSI, has two different kind of checks: patrol read and consistency check.

Because they're two completely different things.

A patrol check reads the entire disk. It doesn't give two hoots what the data is, it just cares that the data can actually be retrieved from the disk.

A consistency check, on the other hand, wants to make sure that the data is correct. It will read both copies of a mirror and compare them. Or it will read the data from 4/5/6, calculate the parities, then read them from disk and compare them.

In other words, a patrol check looks for a failing disk. A consistency check looks for corrupt data. (A consistency check does a patrol check as a side effect, but you might not want to do just that, as it is computationally much more expensive. You might want to do a patrol check every day, and a consistency check of a weekend.)

Cheers,
Wol

#10 lore raw

2017-06-29 16:33 GMT+02:00 Wols Lists <[email protected]>:

Quoted 5 lines

In other words, a patrol check looks for a failing disk. A consistency check looks for corrupt data. (A consistency check does a patrol check as a side effect, but you might not want to do just that, as it is computationally much more expensive. You might want to do a patrol check every day, and a consistency check of a weekend.)

Ok, so, if resources are not a problem, someone could only run a consistency check and totally skip the patrol check. Right ?

What about md reliability? There are many detractors out there.

https://bugzilla.kernel.org/show_bug.cgi?id=99171

One of the most common complaint is the absence of write-back cache, and if you force a "writeback" you'll risk data loss in case of unclean shutdown (power failure and so on)

#11 lore raw
Quoted 9 lines · Gandalf Corvotempesta

2017-06-29 16:33 GMT+02:00 Wols Lists <[email protected]>:

Quoted 5 lines

In other words, a patrol check looks for a failing disk. A consistency check looks for corrupt data. (A consistency check does a patrol check as a side effect, but you might not want to do just that, as it is computationally much more expensive. You might want to do a patrol check every day, and a consistency check of a weekend.)

Ok, so, if resources are not a problem, someone could only run a consistency check and totally skip the patrol check. Right ?

Hardware raid and MD raid are not directly comparable. Based on your description, patrol read and consistency check are separate functions in your hardware raid. (I don't do hardware raid, myself.)

In MD raid, you have a "check" scrub which reads all member devices to find and rewrite any UREs (patrol read), while comparing mirrors/parity for mismatches. You end up with a "mismatch count" in sysfs when done.

You also have a "repair" scrub which also reads all data blocks in parity arrays and first mirrors and write all parity and other mirrors. This is only recommended when a "check" scrub finds mismatches, as this type of scrub can miss developing bad sectors on parity blocks and other mirrors. (Drives can only *detect* failing sectors on *read*, and can only relocate them on *write* *after* detection.)

Quoted 3 lines

What about md reliability? There are many detractors out there.

https://bugzilla.kernel.org/show_bug.cgi?id=99171

That's hardly a great case. Changing data in a chunk of memory in one thread while another thread is writing it out is undefined behavior and MD will give you back something that was there at the time of actual write. Do that with hardware raid and you will gain consistency, but you'll still have jumbled data. Real applications don't do this or they have much bigger problems than raid mirror mismatches.

Quoted 3 lines

One of the most common complaint is the absence of write-back cache, and if you force a "writeback" you'll risk data loss in case of unclean shutdown (power failure and so on)

The only good reason for hardware raid, in my opinion. Balanced against vendor lock-in, limited layout options, and a plethora of management interfaces.

Phil

#12 lore raw
Quoted 3 lines · Phil Turmel

The only good reason for hardware raid, in my opinion. Balanced against vendor lock-in, limited layout options, and a plethora of management interfaces.

And lost data when your controller quits, and you can't find another one that implements the same sort of raid ...

Cheers,
Wol

#13 lore raw
Quoted 9 lines · Anthony Youngman
Quoted 4 lines · Phil Turmel

The only good reason for hardware raid, in my opinion. Balanced against vendor lock-in, limited layout options, and a plethora of management interfaces.

And lost data when your controller quits, and you can't find another one that implements the same sort of raid ...

Back in the days of SCSI that was very true but ..

In the defense of the hw raid vendor I've worked with quite a bit (LSI), I've found you can migrate RAID arrays from controller to controller quite easily. So if your raid controller fails, you can always grab the current available controller that supports your required raid level. I've created arrays in the older 1068 controller (PCI-X card) and easily migrated it to a newer 2008 or 2108 based controller with no fuss. See's the older array as an 'external' array and imports just fine.

Signature · 1 line
Drew
#14 lore raw

2017-07-01 15:42 GMT+02:00 Drew <[email protected]>:

Quoted 8 lines

In the defense of the hw raid vendor I've worked with quite a bit (LSI), I've found you can migrate RAID arrays from controller to controller quite easily. So if your raid controller fails, you can always grab the current available controller that supports your required raid level. I've created arrays in the older 1068 controller (PCI-X card) and easily migrated it to a newer 2008 or 2108 based controller with no fuss. See's the older array as an 'external' array and imports just fine.

This is true for "real" LSI controllers.
But if you look at DELL specs, DELL is supporting only 1 generation to 1 generation migration.
DELL firmware is different from LSI, I'm unsure what could happen by migrating a raid array
between multiple generations.

And in additiojn to this, DELL doesn't provide any kind of support to move disks skipping more than 1 generation.

#15 lore raw
Quoted 9 lines

This is true for "real" LSI controllers.
But if you look at DELL specs, DELL is supporting only 1 generation to 1 generation migration.
DELL firmware is different from LSI, I'm unsure what could happen by migrating a raid array
between multiple generations.

And in additiojn to this, DELL doesn't provide any kind of support to move disks skipping more than 1 generation.

There's your problem. :-)

I have nothing good to say about DELL, and what I could say, well it's nothing I can print in a public forum that wouldn't be expletive laced.

"Real" LSI, or IBM/Lenovo branded LSI raid cards don't restrict their users in such a fashion. I've taken IBM branded drives out of a failed IBM/LSI controller, imported them into a genuine LSI controller, and then ran it for years before the machine became too old and was replaced. It's telling when you take the IBM stickers off their LSI raid controllers and you see the original OEM markings still on the card. Add to that how easy it is to reflash 'genuine' LSI firmware on the IBM cards and the cards run slightly faster because all IBM apparently inserted into the controller BIOS was interface code for the BMC & IMM. :)

Try doing that with a PERC card. :P

Signature · 1 line
Drew
#16 lore raw
In reply to Gandalf Corvotempesta
Quoted 3 lines · On Thursday 29 of June 2017 11:52:01 Gandalf Corvotempesta wrote:

During a patrol read some bad sectors where found (probably in an unallocated part of the array, thus the OS doesn't know anything about that).

Also SMART long test should perform "read/verify scan of all of the user data area", so it is good idea to do it periodically and monitor results.

Signature · 4 lines
Mateusz Korniak
"(...) mam brata - poważny, domator, liczykrupa, hipokryta, pobożniś,
 	krótko mówiąc - podpora społeczeństwa."
				Nikos Kazantzakis - "Grek Zorba"
#17 lore raw

2017-06-29 12:20 GMT+02:00 Mateusz Korniak <[email protected]>:

Quoted 2 lines

Also SMART long test should perform "read/verify scan of all of the user data area", so it is good idea to do it periodically and monitor results.

I'm already using this, but is not very reliable.
I had some disks failed by hw raid controller due to unreadable sector (3/11) still passing the smart long test
and some failed smart long test still passing the hw raid check

#18 lore raw

Am 29.06.2017 um 12:25 schrieb Gandalf Corvotempesta:

Quoted 8 lines

2017-06-29 12:20 GMT+02:00 Mateusz Korniak <[email protected]>:

Quoted 2 lines

Also SMART long test should perform "read/verify scan of all of the user data area", so it is good idea to do it periodically and monitor results.

I'm already using this, but is not very reliable.
I had some disks failed by hw raid controller due to unreadable sector (3/11) still passing the smart long test
and some failed smart long test still passing the hw raid check

hence you do both - in any case, software-raid as well as hardware-raid

* scheduled smart check
* scheduled scrub

i had enough cases where while the scrub was running smartd alerted about a disk going bad - at the end of the day it don't matter which of both cries, the point is that you get (hopefully) a alert that you should replace a specific disk before a second one starts to go bad