2

I've got two drives in RAID1 that serve as the root partition on my workstation. Sometimes (1 out of 10) one of the drives is not detected, and thus not included in the raid. As the drive is not detected at all I cannot reattach it that time (and I may not even notice it, at least not right away).

Once after such a time, I rebooted and the kernel used the previously undetected drive for md0. After that I ran mdadm --add and it just re-added the other half of the array, not reconstrucred it, thus I had an inconsistent array (I ran a check and mismatch_cnt came up with more than 300k blocks!). In the end, I failed one of the drives and then re-attached it, thus doing the reconstruction that should have been done in the first place.

To avoid such situations in the future, I want to detect such errors as early as possible: in GRUB or during boot, before the root file system is mounted. This is a desktop, so turning off and on again in such case is not that much of a problem. Also, I am willing to take manual measures (i.e. booting from a live CD to remove the boot block) if the disks really fail.

Is there a grub/kernel parameter that prevents boot in case of a raid disk's absence? Or the only way to do so is to modify the init scripts on the initramfs?

  • But why? The goal of raid1 is exactly to boot(continues to operate) when one device is failed. – Ipor Sircer Jan 12 '17 at 9:20
  • I think you're looking for LVM... it's a logical volume manager for the Linux kernel; it manages disk drives and similar mass-storage devices. ( wiki.archlinux.org/index.php/LVM ) – Michael D. Jan 12 '17 at 11:21
  • @MichaelD. I know and use LVM heavily, but do not see how it is relevant here. – P.Péter Jan 12 '17 at 11:42
  • @IporSircer This is a rare (but not very rare) temporary error I am speaking about. I do not want to boot if one drive is down, only if I am sure it is permanently down. Otherwise, I must do a reconstruction after every 10th boot. Instead, I would like to do a poweroff/poweron after every 10th boot. – P.Péter Jan 12 '17 at 11:43
  • @P.Péter The VG would not come up with a missing PV - i.e. a missing disk, so you would not able to access the logical volumes on the group. – Michael D. Jan 12 '17 at 11:49
1

I managed to solve half of the problem: I simply removed GRUB from the MBR of the drive that usually does not fail to be detected. Now, if that drive has a temporary error at bootup, I will still get a de-synchronised system, but (at least for now), this does not seem to occur often.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.