How to disable raid check in Ubuntu?

Pinguin

Today I decided to fix some annoying issue with my desktop. When I try to shutdown pc it doesn’t happen because of raid check run. Usually I used switching to console via Ctrl+Alt+F3, and then login via CLI and shutdown it via sudo. It was so annoying…

In my previous installations I fixed this by disabling /etc/cron.d/mdadm but this time it was not exists, probably after some tons of upgrades..

Yeah, I know that it better to keep these checks, but come on with 8 TB raid it takes 600+ minutes to finish, that is about 10 hours. It ridiculous if you start your pc for 10-15 minutes 1-2 times per week.

You can check this by running

$ cat /proc/mdstat
Personalities : [raid1] [raid0] [raid6] [raid5] [raid4] [raid10] 
md0 : active raid1 sda1[0] sdb1[1]
      7813499904 blocks super 1.2 [2/2] [UU]
      [>....................]  check =  0.0% (2536576/7813499904) finish=615.8min speed=211381K/sec
      bitmap: 0/59 pages [0KB], 65536KB chunk

unused devices: <none>

I found the configuration file here /etc/default/mdadm, and some options there that allows to disable:

# AUTOCHECK:
#   should mdadm run periodic redundancy checks over your arrays? See
#   /etc/cron.d/mdadm.
AUTOCHECK=true

# AUTOSCAN:
#   should mdadm check once a day for degraded arrays? See
#   /lib/systemd/system/mdmonitor-oneshot.service
AUTOSCAN=true

Pay attention that the manual edits of this file not always get the results, so the recommended way is to use dpkg-reconfigure, like this

# dpkg-reconfigure mdadm

The process looks like

That’s all.

Also in the /etc/default/mdadm configuration file I saw that the execution scripts moved from cron to systemd

ls -al /etc/systemd/system/mdmonitor.service.wants

mdcheck_continue.timer -> /lib/systemd/system/mdcheck_continue.timer
mdcheck_start.timer -> /lib/systemd/system/mdcheck_start.timer
mdmonitor-oneshot.timer -> /lib/systemd/system/mdmonitor-oneshot.timer

From here we can understand, that this folder contains the links to the scripts that running checks, so if you want to force remove these jobs instead of using configuration file (that is not recommended) you can probably remove the links to the scripts from this folder.

In some cases it makes sense to just align the schedule to start checking not the every Sunday, but once a month or year, you can do this by editing this file (don’t forget to make initial configuration backup)

cat /etc/systemd/system/mdmonitor.service.wants/mdcheck_start.timer 

#  This file is part of mdadm.
#
#  mdadm is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.

[Unit]
Description=MD array scrubbing

[Timer]
OnCalendar=Sun *-*-1..7 1:00:00
RandomizedDelaySec=24h
Persistent=true

[Install]
WantedBy=mdmonitor.service
Also=mdcheck_continue.timer

Other

If you need to just stop the current execution and the current operation is just regular check (not the sync of broken array) for example to reboot the system then you can use next command

$ sudo /usr/share/mdadm/checkarray -x --all

after this ou can make sure that the current operation is canceled

$ cat /proc/mdstat

you will see that the progress bar disappeared so you can safely proceed with the reboot or other things

You May Also Like

About the Author: vo