.Ubuntu 22.04 on Hetzner Servers: mdadm array checking happens at strange times - Chris Stretton

Chris Stretton

Jun 09, 2023

Ubuntu 22.04 on Hetzner Servers: mdadm array checking happens at strange times

By default in Ubuntu (and other Debian based distributions), mdadm RAID arrays are checked monthly using the mdcheck_start.service - initiated by the mdcheck_start.timer systemd timer.

The default Ubuntu schedule for this timer is:

1
2
OnCalendar=Sun *-*-1..7 1:00:00
RandomizedDelaySec=24h

This means it starts on the 1st Sunday of the month at a random time up to 24 hours after 1AM.

This is defined in /lib/systemd/system/mdcheck_start.timer (although you should never edit system units directly)

Hetzner’s version

Ubuntu as installed by Hetzner overrides this. They have an override in /etc/systemd/system/mdcheck_start.timer.d/override.conf which specifies a different calendar.

1
2
OnCalendar=
OnCalendar=*-*-09 01:32:00

This means that it starts on the 9th of the month at a random time up to 24 hours after 1:32AM. The 24 hours random delay is still in effect as Hetzner’s override does not change it.

Overriding the override

I find both of these cases inconvenient. I don’t want a random delay of up to 24 hours as I would rather array checking happen at quiet times, not when the system is busy. I also prefer the first Sunday approach that Ubuntu uses rather than Hetzner’s version, as Sunday is quieter and the 9th of the month may fall on any day of the week.

Removing the random 24 hour delay is simple.

1
$ sudo systemctl edit mdcheck_start.timer

This will open your default termianl editor (typically nano or vim but whatever you have configured) where you can then set your own timer.

1
2
[Timer]
RandomizedDelaySec=0

If you want to remove the Hetzner override first you can revert to the default system timer and then override it afterwards.

1
2
$ sudo systemctl revert mdcheck_start.timer
$ sudo systemctl edit mdcheck_start.timer
OLDER > < NEWER