Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Mar 2009 09:35:31 -0800 (PST)
From:      Peter Steele <psteele@maxiscale.com>
To:        freebsd-questions@freebsd.org
Subject:   What's the best way to destroy a geom mirror?
Message-ID:  <12446074.821236274528605.JavaMail.HALO$@halo>
In-Reply-To: <27757053.721236272524668.JavaMail.HALO$@halo>

next in thread | previous in thread | raw e-mail | index | archive | help

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? 




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?12446074.821236274528605.JavaMail.HALO$>