From owner-freebsd-current@freebsd.org Mon Sep 26 15:08:12 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 01BCFBE357E for ; Mon, 26 Sep 2016 15:08:12 +0000 (UTC) (envelope-from gljennjohn@gmail.com) Received: from mail-lf0-x22a.google.com (mail-lf0-x22a.google.com [IPv6:2a00:1450:4010:c07::22a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 80BD0227 for ; Mon, 26 Sep 2016 15:08:11 +0000 (UTC) (envelope-from gljennjohn@gmail.com) Received: by mail-lf0-x22a.google.com with SMTP id y6so145747041lff.1 for ; Mon, 26 Sep 2016 08:08:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=FxZRBKIrExiNcttG9mTi86PV32i/tR0HMhnWZBwvvIU=; b=Zbgulv8Edb+1Fc5wA6llv7BwY34Lly0dvX04PauZ4z+sFfQo5EBRCxiwqZsCs1uZbX R2Iy5naCNXY7PVrWTpRNjmlF/JAmC5hHeDAgNzuN6XPdSY/Ki+fmt6Nsg/xKVFoECayx DNpcNj7NiIQ2YpdFg7S0id8VC+cO7CkLYqinoEMnQ+jRoQ6tSo7VWn2//a4zLBlgiouj 4VEJL1qxeG2aKy8fUpEvTCUbf8pQJIyPYJn+x5mSGBs7+Ku9/y9UtdEDh6z8L4tKKhg6 wnp6bI+wEzqBbhVwuwzTDvNVkfchfUOY34knavngbxuY2bOuXmSZP4wWljkkSl8gIDS2 6zFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=FxZRBKIrExiNcttG9mTi86PV32i/tR0HMhnWZBwvvIU=; b=EXpCiSlD6yP5ibo0K+oYlVRhOidSxF3XM+tLUTF9kh3lNjUIqEwGY86NgAneCAbftC wqy53mavuxMJ+uvSEfr0Mycd9ZgqJx8yDgO6iqdr15k2xuL0OwfHJTI83BGhkv2gjNjH qlGrVvFQEQOMHKAc0r9WU+Un73cEwWbF9Vbq+mEnJNJ4r2NJfgTfWA4pglQZbLEpVMaG ukB8i7MbAJdYV8fAUlDspAz599RTCh/ki4Z2FZBPuO9AkxTHu1FvxFwgF6bbVITz/yaZ BcgKQ4HlSr3T82PlfgT1jqM2/LDqB7V4lPAumO5lOwIBfP41cnmlfBuvGJ6r0C9Tew5U OUvg== X-Gm-Message-State: AE9vXwNUFwsiqzFHk5wkNahNvxCPfsKU1YoNoBicAefpdK2lr8fmKZAvU4hTLMYzyodZ0A== X-Received: by 10.194.235.166 with SMTP id un6mr19024848wjc.169.1474902488509; Mon, 26 Sep 2016 08:08:08 -0700 (PDT) Received: from ernst.home ([87.142.12.252]) by smtp.gmail.com with ESMTPSA id c134sm11747228wme.5.2016.09.26.08.08.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Sep 2016 08:08:07 -0700 (PDT) Date: Mon, 26 Sep 2016 17:08:03 +0200 From: Gary Jennejohn To: Ernie Luzar Cc: "Hartmann, O." , FreeBSD CURRENT Subject: Re: Destroy GPT partition scheme absolutely, how? Message-ID: <20160926170803.698e5166@ernst.home> In-Reply-To: <57E92726.2020605@gmail.com> References: <20160926150109.0d0d793e@hermann> <57E92726.2020605@gmail.com> Reply-To: gljennjohn@gmail.com X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.29; amd64-portbld-freebsd12.0) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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: Mon, 26 Sep 2016 15:08:12 -0000 On Mon, 26 Sep 2016 09:48:22 -0400 Ernie Luzar wrote: > Hartmann, O. wrote: > > I ran into a very nasty and time consuming problem. Creating a NanoBSD > > image with a modified script framework creating GPT partitions, I put > > the imaes via "dd(1)" on USB flash or SD flash. Because the images are > > usually much smaller than the overall capacity of the USB or SD, the OS > > (FreeBSD CURRENT, recently built as of this morning) complains about > > the second GPT header isn't in the last LBA. Sometimes, my PCengines > > APU2 doesn't boot then, a relief is to issue the command > > gpart recover da1 > > > (in that case, the USB flash drive or SD flash is recognized > > as /dev/da1). > > > But I run into a nasty situation, if the image put to the flash is > > somehow corrupted. Then I tried to write a second, repaired image over > > the first one using dd(1) again and do a recovering as mentioned above > > - but this is fatal in two ways. First, the corrupted/broken GPT seems > > to be "recovered" and put in replacement of the correct one - so I > > guess. Performing no recover leaves the image on flash corrupted > > anyway. > > > Well, to be honest, I didn't exactly know what is going on here. The > > phenomenon is that I had a problem creating a NANO_DATASIZE= DATA > > partition with an empty NANO_DATASIZE which somehow corrupted the > > whole image. The image then never booted, complaining, > > that /foo/bar/_.mnt was unmounted unleanly. > > > This happened multiple times, even if I tried to overwrite the SD or > > USB flash with /dev/zero or /dev/random data, but I do stop such a dd > > after a couple f minutes, since the SD is 32GB in size and the USB > > flash drive is 32 GB, 64 GB and 128 GB - a pain in the ass if you want > > to write via USB 2.0. But even with overwriting with a good image then > > results in a corrupt image on flash drive, complaining about the GPT > > second header not in last LBA and the issue with the uncleanly > > unmount _.mnt (from the creation process of the NanoBSD image)! > > So I guess there is something magic happening. Some informations are > > not lost and I suspect the "recovery" moving those foul data into > > active places. > > > Using a fresh/new SD or USB resolves the problem. But the question > > remains: how can I destroy any relevant GPT information on a Flash > > drive (or even harddisk) to avoid unwanted remains of an foul image > > installation? > > First guess was to write the last couple of bytes on such a flash drive > > by letting dd(1) counting backwards, but I couldn't figure out how to > > let dd(1) do such a procedure. The nightmare didn't end, while trying, > > the SD flash card died :-( > > > thank you very much for your help and thoughts. > > > Kind regards, thanks in advance, > > > > 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 > I'm surprised that this script works without sysctl kern.geom.debugflags=16 -- Gary Jennejohn