What's the best way to destroy a geom mirror?
Peter Steele
psteele at maxiscale.com
Thu Mar 5 09:35:54 PST 2009
I've created a USB boot disk that is used to clone itself onto the systems hard drives, setting up mirrored file systems in the process. The main difficulty I'm having is reimaging a system with an existing OS whose drives are already configured in a mirror. I want of course to destroy the mirror and create a complete new one, but I can't find the right process to accomplish this reliably. I am doing the following:
# Cycle through each /dev/adNN drive and clean it. This has to be
# done before the geom_mirror driver is loaded.
disks=(`ls /dev/ad* | grep -v "s" | sed -e "s|/dev/||" -e "s|ad||" | sort -g`)
for ((i = 0 ; i < ${#disks[@]} ; i++)); do
disk=ad${disks[i]}
dd if=/dev/zero of=/dev/${disk} bs=512 count=79
done
# Partition the drives as needed
...
# Create the mirror, starting with the first drive in the list
gmdisk=ad${disks[0]}
gmirror load
gmirror label -v -n -b round-robin gm0 ${gmdisk}s1
This is where the problem occurs. If there was already a mirrored file system previously active on the system being reimaged, the label operation complains that it can't store the metadata on the indicated drive:
gmirror: Can't store metadata on ad4s1: Operation not permitted.
If I make sure the existing mirrors are torn down first by iterating through the drives and doing a "remove" operation, this can solve the problem, but in some cases the mirror is in a suspect state and I've seen the "gmirror load" command hang idefiinitely. So I don't want to do a load command before I destroy the old mirrors, but I can't seem to find a way to reliably destroy the old mirrors. Can anyone suggest a way to do this?
More information about the freebsd-questions
mailing list