From 2c15bc8dc2910bf311d15787a482125e2babc4b0a7b928cd52791d124f7ffc56 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Tue, 16 Sep 2014 01:06:21 +0000 Subject: [PATCH] - Add cron job to run 'mdcheck' regularly to verify all md arrays. (bnc#869261) OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=120 --- cron.d.mdadm | 9 +++++++++ mdadm.changes | 6 ++++++ mdadm.spec | 24 ++++++++++++++++++++++-- sysconfig.mdadm | 12 ++++++++++++ 4 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 cron.d.mdadm diff --git a/cron.d.mdadm b/cron.d.mdadm new file mode 100644 index 0000000..4bd2c30 --- /dev/null +++ b/cron.d.mdadm @@ -0,0 +1,9 @@ +# +# cron.d/mdadm - regular redundancy checks +# + +# Start checking each month early in the morning. +# Continue each day until all done + +0 1 * * 0 root source /etc/sysconfig/mdadm; [ -n "$MDADM_CHECK_DURATION" -a -x /usr/share/mdadm/mdcheck -a $(date +\%d) -le 7 ] && /usr/share/mdadm/mdcheck --duration "$MDADM_CHECK_DURATION" +0 1 * * 1-6 root source /etc/sysconfig/mdadm; [ -n "$MDADM_CHECK_DURATION" -a -x /usr/share/mdadm/mdcheck ] && /usr/share/mdadm/mdcheck --continue --duration "$MDADM_CHECK_DURATION" diff --git a/mdadm.changes b/mdadm.changes index 50f03ca..c017d9c 100644 --- a/mdadm.changes +++ b/mdadm.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue Sep 16 01:04:36 UTC 2014 - nfbrown@suse.com + +- Add cron job to run 'mdcheck' regularly to + verify all md arrays. (bnc#869261) + ------------------------------------------------------------------- Fri Jul 25 11:48:12 UTC 2014 - p.drouand@gmail.com diff --git a/mdadm.spec b/mdadm.spec index cd56c93..5a4fb28 100644 --- a/mdadm.spec +++ b/mdadm.spec @@ -28,7 +28,6 @@ BuildRequires: pkgconfig(systemd) PreReq: %fillup_prereq /sbin/mkinitrd Recommends: cron Recommends: smtp_daemon -Obsoletes: raidtools Url: http://www.kernel.org/pub/linux/utils/raid/mdadm/ Summary: Utility for Configuring MD Setup License: GPL-2.0 @@ -37,6 +36,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build Source: https://www.kernel.org/pub/linux/utils/raid/mdadm/%{name}-%{version}.tar.xz Source1: Software-RAID.HOWTO.tar.bz2 Source2: sysconfig.mdadm +Source3: cron.d.mdadm Source7: mdadm.cron # PATCH-FIX-UPSTREAM 0001-Makefile-install-mdadm-grow-continue-.service.patch nfbrown@suse.de Patch1: 0001-Makefile-install-mdadm-grow-continue-.service.patch @@ -66,17 +66,32 @@ sgml2txt Software-RAID.HOWTO.sgml make install install-systemd install-udev DESTDIR=%{buildroot} SYSTEMD_DIR=%{_unitdir} UDEVDIR=%{_udevdir} SUSE=yes rm -rf %{buildroot}/lib/udev install -d %{buildroot}%{_var}/adm/fillup-templates -install -d %{buildroot}{%{_sbindir} +install -d %{buildroot}/usr/share/mdadm +install -m 755 misc/mdcheck %{buildroot}/usr/share/mdadm/mdcheck install -d %{buildroot}/etc/cron.daily +install -d %{buildroot}/etc/cron.d install -m 755 %{S:7} %{buildroot}/etc/cron.daily/mdadm +install -m 644 %{S:3} %{buildroot}/etc/cron.d/mdadm install -m 644 %{S:2} %{buildroot}%{_var}/adm/fillup-templates/ install -d %{buildroot}%{_systemdshutdowndir} +install -d %{buildroot}%{_sbindir} +ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcmdmonitor + +%define services mdmonitor.service mdmon@.service mdadm-last-resort@.service mdadm-grow-continue@.service + +%pre +%service_add_pre %services %post +%service_add_post %services %{?regenerate_initrd_post} %fillup_only +%preun +%service_del_preun %services + %postun +%service_del_postun %services %{?regenerate_initrd_post} %posttrans @@ -88,11 +103,16 @@ install -d %{buildroot}%{_systemdshutdowndir} %doc Software-RAID.HOWTO/Software-RAID.HOWTO*{.txt,.html} %doc %{_mandir}/man?/* /sbin/* +%{_sbindir}/rcmdmonitor +%dir /usr/share/mdadm +/usr/share/mdadm/* %{_var}/adm/fillup-templates/sysconfig.mdadm %{_udevdir}/rules.d/63-md-raid-arrays.rules %{_udevdir}/rules.d/64-md-raid-assembly.rules %dir /etc/cron.daily /etc/cron.daily/mdadm +%dir /etc/cron.d +%config /etc/cron.d/mdadm %{_systemdshutdowndir}/mdadm.shutdown %{_unitdir}/mdmon@.service %{_unitdir}/mdmonitor.service diff --git a/sysconfig.mdadm b/sysconfig.mdadm index 7cdd682..b660c91 100644 --- a/sysconfig.mdadm +++ b/sysconfig.mdadm @@ -60,3 +60,15 @@ MDADM_SEND_MAIL_ON_START=no # increased. Setting this to '0' disables waiting for udev. # MDADM_DEVICE_TIMEOUT="60" + +## Type: string +## Default: 6 hours +# +# Amount of time to spend checking md arrays each morning. +# A check will start on the first Sunday of the month and run +# for this long. If it does not complete, then it will be +# continued each subsequent morning until all arrays have +# been checked. Any string understood by "date --date=" +# can be used. An empty string disables automatic checks. +# +MDADM_CHECK_DURATION="6 hours"