From: Arno Wagner <arno@wagner.name>
To: dm-crypt@saout.de
Subject: Re: [dm-crypt] LUKS safety on RAID 1 mirror
Date: Wed, 26 Nov 2014 01:24:33 +0100 [thread overview]
Message-ID: <20141126002433.GA31891@tansi.org> (raw)
In-Reply-To: <deb61b588f5d41197c2e61b39fde1279.squirrel@ssl.verfeiert.org>
On Wed, Nov 26, 2014 at 00:26:26 CET, Sven Eschenberg wrote:
[...]
> > Really, if you are concerned about disks dying (and you should be),
> > do the sane thing and have SMART monitoring and regular long SMART
> > selftests (I do them every 14 days) via smartmond. If you are concerned
> > about the RAID being inconsistent (and you should be), do RAID
> > consistency checks (I do them every 7 days) and RAID monitoring via
> > mdadm.
>
> I agree, if I may ask, do you run the consistency check via cron or some
> other way?
Sure. I basically reverse-engineered the Debian script doing it
and wrote a Python script for cron-usage on the basis of that.
The mechanics is as follows:
1. make sure /sys/block/<device>/md/mismatch_count is zero
2. write "check" to /sys/block/<device>/md/sync_action
3. wait until /sys/block/<device>/md/sync_action does not read
back as "check\n" anymore
4. check whether /sys/block/<device>/md/mismatch_count is non-zero.
Script attached below.
Gr"usse,
Arno
----
#!/usr/bin/python3.1
# (c) 2010 Arno Wagner arno@wagner.name
# Distributed under the GPLv2, see http://www.gnu.org/licenses/gpl-2.0.html
# Aim: Runs a consistency check on the md device given
# and checks mismatch count afterwards.
# Result: Silent on no error, output to stdout in case of error.
# Intended for cron-job usage.
import fileinput, re, sys, time
device = 'md0'
# check device exists and is "active"
flag = False
for l in fileinput.input('/proc/mdstat'):
l.rstrip('\n')
if re.search('^'+device+'\s\:\s',l):
flag = True
break
if not flag:
print('ERROR: Specified device '+device+' not found in /proc/mdstat')
sys.exit(1)
if not re.search('^'+device+'\s\:\sactive\s',l):
print('ERROR: Device '+device+' not active:')
print(' '+ l)
sys.exit(1)
# assemble paths for check
action_p = '/sys/block/'+device+'/md/sync_action'
mismatch_p = '/sys/block/'+device+'/md/mismatch_cnt'
# make sure no mismatches are present
f = open(mismatch_p, 'r')
mism = f.readline()
f.close()
mism = int(mism)
if mism != 0:
print('ERROR: Device '+device+' has mismatches before check: '+
repr(mism))
sys.exit(1)
# start the check
f = open(action_p, 'w')
f.write('check')
f.close
# wait for the check to complete
while(1):
f = open(action_p, 'r')
l = f.readline()
f.close()
time.sleep(1)
if l != 'check\n':
break
# check mismatches
f = open(mismatch_p, 'r')
mism = f.readline()
f.close()
mism = int(mism)
if mism != 0:
print('ERROR: Device '+device+' has mismatches: '+
repr(mism))
sys.exit(1)
else:
pass
# print(' Device '+device+' has no mismatches')
--
Arno Wagner, Dr. sc. techn., Dipl. Inform., Email: arno@wagner.name
GnuPG: ID: CB5D9718 FP: 12D6 C03B 1B30 33BB 13CF B774 E35C 5FA1 CB5D 9718
----
A good decision is based on knowledge and not on numbers. -- Plato
If it's in the news, don't worry about it. The very definition of
"news" is "something that hardly ever happens." -- Bruce Schneier
next prev parent reply other threads:[~2014-11-26 0:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-25 10:03 [dm-crypt] LUKS safety on RAID 1 mirror Mark Connor
[not found] ` <1460172830.1886432.1416911318568.JavaMail.zimbra@grenzecho.be>
2014-11-25 10:28 ` Fabrice Bongartz
2014-11-25 14:24 ` Arno Wagner
2014-11-25 15:27 ` Sven Eschenberg
2014-11-25 16:17 ` Arno Wagner
2014-11-25 23:26 ` Sven Eschenberg
2014-11-26 0:24 ` Arno Wagner [this message]
2014-11-27 15:24 ` Mark Connor
2014-11-27 16:47 ` Arno Wagner
2014-11-25 14:18 ` Arno Wagner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141126002433.GA31891@tansi.org \
--to=arno@wagner.name \
--cc=dm-crypt@saout.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox