Okay, thanks everyone for their feedback. I think I have a workable solution 
now. 

Peter 

----- Original Message ----- 
From: "Oliver Fromme" <o...@lurza.secnetix.de> 
To: freebsd-hackers@FreeBSD.ORG, pste...@maxiscale.com 
Sent: Friday, March 6, 2009 11:15:11 AM GMT -08:00 US/Canada Pacific 
Subject: Re: How to tear down a geom mirror? 

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 
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"

Reply via email to