From owner-freebsd-current@freebsd.org Tue Oct 4 17:43:02 2016 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A7DDCAF5ACF for ; Tue, 4 Oct 2016 17:43:02 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 86C91C44 for ; Tue, 4 Oct 2016 17:43:02 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id 631B710AF88; Tue, 4 Oct 2016 13:43:01 -0400 (EDT) From: John Baldwin To: Warren Block Cc: freebsd-current@freebsd.org, Ngie Cooper , Ernie Luzar , "Hartmann, O." Subject: Re: Destroy GPT partition scheme absolutely, how? Date: Tue, 04 Oct 2016 10:24:39 -0700 Message-ID: <16661613.eI4FiDRTSB@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.0-PRERELEASE; KDE/4.14.10; amd64; ; ) In-Reply-To: References: <20160926150109.0d0d793e@hermann> <1785064.lgVzRW13Wf@ralph.baldwin.cx> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Tue, 04 Oct 2016 13:43:01 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Oct 2016 17:43:02 -0000 On Tuesday, October 04, 2016 06:23:26 AM Warren Block wrote: > On Mon, 26 Sep 2016, John Baldwin wrote: > > > On Tuesday, September 27, 2016 12:36:22 AM Ngie Cooper wrote: > >> > >>> On Sep 26, 2016, at 22:48, Ernie Luzar wrote: > >> > >> ... > >> > >>> This little script has been posted before. Maybe it will be what your looking for. Called gpart.nuke > >>> > >>> #! /bin/sh > >>> echo "What disk do you want" > >>> echo "to wipe? For example - da1 :" > >>> read disk > >>> echo "OK, in 10 seconds I will destroy all data on $disk!" > >>> echo "Press CTRL+C to abort!" > >>> sleep 10 > >>> diskinfo ${disk} | while read disk sectorsize size sectors other > >>> do > >>> # Delete MBR and partition table. > >>> dd if=/dev/zero of=/dev/${disk} bs=${sectorsize} count=1 > >>> # Delete GEOM metadata. > >>> dd if=/dev/zero of=/dev/${disk} bs=${sectorsize} oseek=`expr $sectors - 2` count=2 > >>> done > >> > >> Why not just use "gpart destroy -F provider"? > > > > That doesn't always work. In particular, if a disk was partitioned with GPT > > and then you use normal MBR on it afterwards, the 'gpart destroy -F' of the > > MBR will leave most of the GPT intact and the disk will come up with the old > > GPT partitions, not as a raw disk. > > Right. So do a gpart destroy -F of whatever is on there, ignoring > errors, then a gpart create -s gpt. Now there is definitely a secondary > GPT, and a final gpart destroy -F removes it cleanly. It is usually simpler to just dd zeroes over the first N and last N sectors. The only fool-proof way to ensure you don't have dangling tables in the middle of the disk is to zero the entire disk, but that takes too long. -- John Baldwin