Rebuilding mirrored disks on FreeBSD

One morning, crimson (the FreeBSD backup server), would not boot. THe console indicated that the BIOS could not probe one of the two drives of the mirror (ada1 or ada2). The BIOS told me I could hit F1 to continue. I did that, to see that the boot process hung when gmirror tried to built the array.

I powered off the machine, reseated the SATA cables and rebooted. This time the disk was seen OK by the BIOS and FreeBSD booted normally. Well, normally apart from the degraded mirror:

  Name        Status    Components
  mirror/gm0  DEGRADED  ada1 (ACTIVE)

dmesg contained the clue:

  [mark@crimson:~]$ dmesg|grep ada2
  ada2 at ata6 bus 0 scbus4 target 0 lun 0
  ada2: <Maxtor 7L320S0 BANC1G10> ATA-7 SATA 1.x device
  ada2: Serial Number L6115AQH
  ada2: 150.000MB/s transfers (SATA 1.x, UDMA5, PIO 8192bytes)
  ada2: 308921MB (632672208 512 byte sectors)
  GEOM_MIRROR: Component ada2 (device gm0) broken, skipping.

I have a vague memory that this had happed once before, but I could not remember how to return the mirror to a fully working state. So, for future reference, this is how:

  [mark@crimson:~]$ doas gmirror forget gm0
  [mark@crimson:~]$ doas gmirror insert gm0 /dev/ada2
  [mark@crimson:~]$ gmirror status
  Name        Status    Components
  mirror/gm0  DEGRADED  ada1 (ACTIVE)
                        ada2 (SYNCHRONIZING, 0%)

It took several hours for the mirror to re-build.

  [mark@crimson:~]$ gmirror status
  Name        Status    Components
  mirror/gm0  COMPLETE  ada1 (ACTIVE)
                        ada2 (ACTIVE)