From owner-freebsd-geom@FreeBSD.ORG Mon Oct 1 10:29:06 2012 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DBEAE1065700 for ; Mon, 1 Oct 2012 10:29:05 +0000 (UTC) (envelope-from dark@rambler-co.ru) Received: from dark.park.rambler.ru (dark.park.rambler.ru [81.19.64.109]) by mx1.freebsd.org (Postfix) with ESMTP id 68A0C8FC14 for ; Mon, 1 Oct 2012 10:29:04 +0000 (UTC) Received: from dark.park.rambler.ru (localhost [127.0.0.1]) by dark.park.rambler.ru (8.14.5/8.14.5) with ESMTP id q91AAelL030840; Mon, 1 Oct 2012 14:10:40 +0400 (MSK) (envelope-from dark@rambler-co.ru) Message-ID: <50696C20.3020704@rambler-co.ru> Date: Mon, 01 Oct 2012 14:10:40 +0400 From: Konstantin Kukushkin User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:15.0) Gecko/20120919 Thunderbird/15.0.1 MIME-Version: 1.0 To: Warren Block References: <50663866.9070001@delphij.net> In-Reply-To: Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Mon, 01 Oct 2012 11:50:30 +0000 Cc: d@delphij.net, freebsd-geom@freebsd.org Subject: Re: Simple way to clear arbitrary drive metadata? X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Oct 2012 10:29:06 -0000 29.09.2012 21:27, Warren Block пишет: > On Fri, 28 Sep 2012, Xin Li wrote: > >> On 09/28/12 15:21, Warren Block wrote: >>> Last night, I found that the remnants of a GPT backup table on an >>> MBR drive prevented it from booting. When reusing drives from old >>> mirrors, old mirror metadata can be a problem also. And there may >>> be old hardware RAID metadata at the end of the drive. >>> >>> It would be great if dd understood negative seek values. This >>> would get most of that old metadata: >>> >>> dd if=/dev/zero of=/dev/ada8 seek=-34 >>> >>> ...but dd does not understand negative seek values. (Been on my >>> list for a while to look at that.) >>> >>> Which leaves things like >>> >>> diskinfo ada8 | cut -f4 (subtract 34) dd if=/dev/zero of=/dev/ada8 >>> seek=(calculated value) >>> >>> That can be done in one command line with bc and backticks, but >>> it's not clear or elegant. gpart can clear secondary GPT tables, >>> but I'm pretty sure it won't wipe out that space unless it actually >>> is a GPT table. Likewise with glabel and gmirror, they're safe >>> because they only touch data they understand. >>> >>> Is there something simpler and more blunt? >> >> I think you can do: >> >> gpart destroy -F ada8 >> gpart create -s gpt ada8 >> gpart destroy -F ada8 >> >> The second 'create' will write an empty partition table to the >> secondary table. > > Nice! It works perfectly for GPT and glabel metadata. > > gmirror is a problem. If the gmirror kernel module is loaded, drives > with gmirror metadata create a mirror. GEOM prevents writes to the > drive then. sysctl kern.geom.debugflags=16 allows writes, but the > mirror is still in memory and running. 'gmirror stop' (which the system > also does on shutdown) helpfully writes the whole metadata block back to > the drive. After reboot, it's right back where it was. > > Seems like the only way to deal with gmirror is to have the user check > for it directly, and stop the mirror if the attached drive is a member. You may use 'geom clear' command to clear metadata from disk/partition/other GEOM provider. This will work only on stopped mirrors or while geom_mirror not loaded, of course. For gmirror you can 'remove' component from running mirror (even if the component is last). Metadata will cleared after removing, so gmirror remove ' is very usable. You can determine what GEOMs metadata living on disk $disk using command 'geom dump', like this: for class in mirror stripe concat raid3; do geom $class dump $disk done > Probably the same for graid, but I don't know if I have a system where I > can test that. > _______________________________________________ > freebsd-geom@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-geom > To unsubscribe, send any mail to "freebsd-geom-unsubscribe@freebsd.org" -- С уважением, Константин Кукушкин, Rambler Internet Holding mailto:dark@rambler-co.ru тел.: 8 (495) 785-17-00#2129