public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] Fun with mdadm (Software RAID)
@ 2024-12-20 10:47 Alan Mackenzie
  2024-12-20 14:50 ` karl
  0 siblings, 1 reply; 23+ messages in thread
From: Alan Mackenzie @ 2024-12-20 10:47 UTC (permalink / raw
  To: gentoo-user

Hello, Gentoo.

After having got the syslinux boot manager working well, I lost the root
partition on my newer machine.  I spent the entire evening yesterday
trying to get it back again, with various expedients for recovering ext4
partitions from backup superblocks, and so on.

It wasn't until the middle of the night that it dawned on me what had
happened, and I immediately got up and had it fixed within twenty
minutes.

The cause was me booting up the machine with a rescue disk.  This
assembled my RAID partitions /dev/md127 and /dev/md126 reversed, but
also wrote those wrong identifiers, 126 and 127, into the "preferred
minor" field of the partitions' super blocks.  In essence, they got
swapped.

Hence trying to boot up into my normal system, /dev/md126, the root
partition, was an unformatted empty space on the SSD.

I don't blame the rescue disk for this occurrence.  For some reason,
when the kernel assembles /dev/md devices, it only seems to pay
attention to the "preferred minor" fields when they are wrong.  :-(

mdadm appears to write the "preferred minor" fields at random when
assembling the RAID arrays.  I don't think it should, unless explicitly
asked.  There is an argument to mdadm which specifies the writing of
these fields.  In fact I used this to effect a repair, ironically
enough, from the rescue disk booted with the option to suppress the
automatic assembly of the arrays.

Just for the record, all my RAID arrays have metadata version 0.90, the
(old fashioned) one that allows auto-assembly by the kernel without the
need of an initramfs.

The moral of the story: if your system uses software RAID, be careful
indeed before you boot up with a rescue disk.

-- 
Alan Mackenzie (Nuremberg, Germany).


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2024-12-30  4:13 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-20 10:47 [gentoo-user] Fun with mdadm (Software RAID) Alan Mackenzie
2024-12-20 14:50 ` karl
2024-12-20 15:28   ` Alan Mackenzie
2024-12-20 17:44     ` karl
2024-12-20 20:19       ` Alan Mackenzie
2024-12-20 20:38         ` Hoël Bézier
2024-12-20 20:53           ` Alan Mackenzie
2024-12-20 22:02         ` karl
2024-12-30  4:08           ` Frank Steinmetzger
2024-12-20 22:02         ` karl
2024-12-21 12:43           ` Alan Mackenzie
2024-12-21 16:36             ` Alan Mackenzie
2024-12-21 16:45               ` karl
2024-12-21 16:58                 ` Alan Mackenzie
2024-12-22 13:08                   ` Alan Mackenzie
2024-12-22 12:16             ` Wols Lists
2024-12-22 12:08         ` Wols Lists
2024-12-22 12:02       ` Wols Lists
2024-12-22 13:43         ` Alan Mackenzie
2024-12-22 15:29           ` Peter Humphrey
2024-12-22 16:53             ` Wols Lists
2024-12-22 20:05               ` Alan Mackenzie
2024-12-25 21:16                 ` Steven Lembark

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox