From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from v6.tansi.org (ns.km31936-01.keymachine.de [87.118.116.4]) by mail.server123.net (Postfix) with ESMTP for ; Wed, 26 Nov 2014 01:24:34 +0100 (CET) Received: from gatewagner.dyndns.org (77-57-44-24.dclient.hispeed.ch [77.57.44.24]) by v6.tansi.org (Postfix) with ESMTPA id B359E34FA001 for ; Wed, 26 Nov 2014 01:24:33 +0100 (CET) Date: Wed, 26 Nov 2014 01:24:33 +0100 From: Arno Wagner Message-ID: <20141126002433.GA31891@tansi.org> References: <2060884220.1886440.1416911327239.JavaMail.zimbra@grenzecho.be> <20141125142417.GB11425@tansi.org> <3c089a8c5f3b6e39ef0572d7411812ca.squirrel@ssl.verfeiert.org> <20141125161735.GA13580@tansi.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [dm-crypt] LUKS safety on RAID 1 mirror List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: dm-crypt@saout.de 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//md/mismatch_count is zero 2. write "check" to /sys/block//md/sync_action 3. wait until /sys/block//md/sync_action does not read back as "check\n" anymore 4. check whether /sys/block//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