Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Mar 2009 20:15:11 +0100 (CET)
From:      Oliver Fromme <olli@lurza.secnetix.de>
To:        freebsd-hackers@FreeBSD.ORG, psteele@maxiscale.com
Subject:   Re: How to tear down a geom mirror?
Message-ID:  <200903061915.n26JFBre071274@lurza.secnetix.de>
In-Reply-To: <x61538x1236353208x@lurza.secnetix.de>

next in thread | previous in thread | raw e-mail | index | archive | help
Peter Steele wrote:
 > > Yes. The "clear" commands usually just zero-out the last sector of the 
 > > underlying provider (doesn't matter if it's a drive, slice or something 
 > > altogether different) so you don't have to do it manually. 
 > 
 > So, as a generic solution then I could just iterate through all
 > slices of all drives and run "gmirror clear" on each, and run dd
 > to clear the first sectors. What btw is in these first sectors? I
 > use this command because I saw it being done in one of the gmirror
 > tutorials. I understand what the gmirror clear command does, but what
 > is the dd command clearing?

It clears the MBR (slice table) and GPT or disklabel
(partition table), if any.  Depending on how many
sectors you clear, it will also destroy the beginning
the file system, e.g. the first UFS superblock.

By the way, if you cannot use "gmirror clear" for any
reason, you can also easily clear the last sector on
any devices using the information from diskinfo.
For example:

   DEV=/dev/ad0s1a
   set -- $(diskinfo $DEV)
   BLOCKSIZE=$2
   MEDIASIZE=$4
   LASTSEC=$(( $MEDIASIZE - 1 ))
   dd if=/dev/zero of=$DEV bs=$BLOCKSIZE seek=$(( $MEDIASIZE - 1 )) count=1

That's pretty much what "gmirror clear /dev/ad0s1a" does.

Best regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

"One of the main causes of the fall of the Roman Empire was that,
lacking zero, they had no way to indicate successful termination
of their C programs."
        -- Robert Firth



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903061915.n26JFBre071274>