From owner-freebsd-hackers@FreeBSD.ORG Fri Mar 6 06:54:07 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0F89A106566B for ; Fri, 6 Mar 2009 06:54:07 +0000 (UTC) (envelope-from psteele@maxiscale.com) Received: from exprod7og112.obsmtp.com (exprod7og112.obsmtp.com [64.18.2.177]) by mx1.freebsd.org (Postfix) with SMTP id A4A1D8FC0A for ; Fri, 6 Mar 2009 06:54:06 +0000 (UTC) (envelope-from psteele@maxiscale.com) Received: from source ([209.85.198.227]) by exprod7ob112.postini.com ([64.18.6.12]) with SMTP ID DSNKSbDIjgIftXnuRJ8HxL97c+aiRqbvaXjn@postini.com; Thu, 05 Mar 2009 22:54:06 PST Received: by rv-out-0506.google.com with SMTP id f6so334579rvb.11 for ; Thu, 05 Mar 2009 22:54:06 -0800 (PST) Received: by 10.140.163.12 with SMTP id l12mr1105664rve.41.1236320888896; Thu, 05 Mar 2009 22:28:08 -0800 (PST) Received: from localhost ([76.231.178.131]) by mx.google.com with ESMTPS id g22sm1334329rvb.0.2009.03.05.22.28.08 (version=SSLv3 cipher=RC4-MD5); Thu, 05 Mar 2009 22:28:08 -0800 (PST) Date: Thu, 5 Mar 2009 22:27:50 -0800 (PST) From: Peter Steele To: freebsd-hackers@FreeBSD.ORG Message-ID: <17349951.141236320867093.JavaMail.HALO$@halo> In-Reply-To: <17738942.121236320716364.JavaMail.HALO$@halo> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Subject: How to tear down a geom mirror? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Mar 2009 06:54:07 -0000 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?