I use gvinum under FreeBSD to perform simple mirroring of the drives on my servers. This has served me well, and in fact just last Friday saved me from a monumental headache as one of my drives crashed. Very hard crash, so bad that the computer was unable to see either drive if that one was just plugged in to the controller.
I set my drives up using the instructions at this web site and it's worked well, but the disaster recovery presented didn't work for me. So I did a little testing.
The problem involves bring back the missing drive - the kernel (this is 6.1) will panic if the drive is created again. The problem can be alleviated by removing the plexes and subdisks that were bound to the missing drive before bringing it back. In abbreviated form, here are the steps involved:
- Physically replace the drive.
- Boot off the good drive into single-user mode. Technically, you don't have to do this, but it just seems like a good idea, right?
- Use "gvinum rm" to remove the subdisks and plexes for the missing drive. Typically, you can grep for ".p0" or ".p1", whichever is the missing drive. Be really careful, of course.
- Use bsdlabel to "copy" the label from the good drive to the new drive.
- Add the drive back in. Remember that if you have any subdisks still pointing to it, the kernel will panic.
- Add the plexes and subdisks back.
- Start the plexes one by one, allowing time for it to rebuild the mirrors.
Now, if you have a setup like mine where everything is simply mirrored and the drives are identical (or setup identically), there's a very easy shortcut to bringing back the missing plexes and subdisks. When you run "gvinum create", it drops you into an editor with the current configuration commented out. Uncomment the plexes and subdisks, and change them to match the other drive, then save. As an "ed" script:
% s/^# plex/plex/
% s/^# sd/sd/
% s/p0/p1/g
% s/drive main/drive secondary/g
Of course, you might be replacing your "main" drive in which case you would reverse the drive names and "p0" and "p1". But that's it. After this, make sure your plexes and subdisks look correct, then use "gvinum start" one at a time to bring up the mirrors.
To test, you can either boot to the FixIt disk, or boot into single-user mode with geom_vinum.ko unloaded and your rootdev set to the proper bsdlabel device. Then, use:
dd if=/dev/zero of=/dev/da3 bs=65536 count=256000000
To clear out the first 15GB or so of the drive. At that point, you should reboot and start testing with your now blank drive.
I have a perl script that will "translate" the bsdlabel into gvinum setups, I will post it when I get a chance.
Leave a Reply