Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Mar 2009 22:27:50 -0800 (PST)
From:      Peter Steele <psteele@maxiscale.com>
To:        freebsd-hackers@FreeBSD.ORG
Subject:   How to tear down a geom mirror?
Message-ID:  <17349951.141236320867093.JavaMail.HALO$@halo>
In-Reply-To: <17738942.121236320716364.JavaMail.HALO$@halo>

next in thread | previous in thread | raw e-mail | index | archive | help
I posed this question in the questions list but didn't get any traction. Hopefully someone here will have an answer. 

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 don't want to make any assumptions about what mirrors might exist already and I definitely don't want to do "gmirror load" before I get a chance to destroy any existing mirrors. 

What I am doing is to clean the drive using dd. For example, assume my target system has two drives ad1 and ad2. I issue the following commands: 

dd if=/dev/zero of=/dev/ad1 bs=512 count=79 
dd if=/dev/zero of=/dev/ad2 bs=512 count=79 

I'm assuming this is enough to destroy any existing mirrors on the target drives, and I do this before the geom driver is loaded. After this, I partition the drives as I want them, and then create the mirrored pair: 

gmirror load 
gmirror label -v -n -b round-robin gm0 ad1s1 
gmirror insert gm0 ad2s1 

This process works exactly as I want it if the system that is being reimaged has existing mirrors. However, if the drives were previously participating in a mirror, the label command fails, reporting the following error: 

gmirror: Can't store metadata on ad1s1: Operation not permitted. 

If I make sure the existing mirrors are torn down first doing an "remove" operation instead of using the dd method, this can solve the problem, but in some cases the mirror on the target system 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?17349951.141236320867093.JavaMail.HALO$>