From nobody Tue May 23 10:55:21 2023 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QQWSX6hkLz4CL1H for ; Tue, 23 May 2023 10:55:40 +0000 (UTC) (envelope-from jhs@berklix.com) Received: from land.berklix.org (land.berklix.org [144.76.10.75]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "land.berklix.org", Issuer "land.berklix.org" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QQWSW5rQXz3N3c for ; Tue, 23 May 2023 10:55:39 +0000 (UTC) (envelope-from jhs@berklix.com) Authentication-Results: mx1.freebsd.org; dkim=none; spf=none (mx1.freebsd.org: domain of jhs@berklix.com has no SPF policy when checking 144.76.10.75) smtp.mailfrom=jhs@berklix.com; dmarc=none Received: from dell.no.berklix.net (p4fe6de81.dip0.t-ipconnect.de [79.230.222.129]) (authenticated bits=128) by land.berklix.org (8.16.1/8.16.1) with ESMTPSA id 34NAtRNb050533 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=FAIL); Tue, 23 May 2023 10:55:28 GMT (envelope-from jhs@berklix.com) Received: from dell.no.berklix.net (localhost [127.0.0.1]) by dell.no.berklix.net (8.16.1/8.16.1) with ESMTPS id 34NAtMKf047128 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 23 May 2023 12:55:22 +0200 (CEST) (envelope-from jhs@dell.no.berklix.net) Received: (from jhs@localhost) by dell.no.berklix.net (8.16.1/8.16.1/Submit) id 34NAtLsE047127; Tue, 23 May 2023 12:55:21 +0200 (CEST) (envelope-from jhs) Message-Id: <202305231055.34NAtLsE047127@dell.no.berklix.net> To: sgk@troutmask.apl.washington.edu cc: Warner Losh , FreeBSD Hackers Subject: Re: gpart destroy efi partition? From: "Julian H. Stacey" Organization: http://berklix.com/jhs/ User-agent: EXMH on FreeBSD http://berklix.com/free/ X-From: http://www.berklix.org/~jhs/ In-reply-to: Your message "Mon, 22 May 2023 21:35:13 -0700." List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <47125.1684839321.1@dell.no.berklix.net> Content-Transfer-Encoding: quoted-printable Date: Tue, 23 May 2023 12:55:21 +0200 X-Spamd-Result: default: False [-1.10 / 15.00]; SUBJECT_ENDS_QUESTION(1.00)[]; AUTH_NA(1.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-0.999]; NEURAL_HAM_LONG(-1.00)[-0.998]; MIME_GOOD(-0.10)[text/plain]; BLOCKLISTDE_FAIL(0.00)[144.76.10.75:server fail,79.230.222.129:server fail]; RCVD_TLS_LAST(0.00)[]; R_SPF_NA(0.00)[no SPF record]; MLMMJ_DEST(0.00)[freebsd-hackers@freebsd.org]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; HAS_ORG_HEADER(0.00)[]; ASN(0.00)[asn:24940, ipnet:144.76.0.0/16, country:DE]; FROM_HAS_DN(0.00)[]; FREEFALL_USER(0.00)[jhs]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; RCPT_COUNT_THREE(0.00)[3]; DMARC_NA(0.00)[berklix.com]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; R_DKIM_NA(0.00)[] X-Rspamd-Queue-Id: 4QQWSW5rQXz3N3c X-Spamd-Bar: - X-ThisMailContainsUnwantedMimeParts: N Steve Kargl wrote: > On Mon, May 22, 2023 at 09:51:40PM -0600, Warner Losh wrote: > > On Mon, May 22, 2023, 9:45 PM Steve Kargl > > wrote: > > = > > > Is there a secret incantation for destroying an EFI > > > partition on a USB memstick? After installing FreeBSD, > > > I would like to re-use a memstick, but > > > > > > % gpart destroy da0 > > > gpart: geom 'da0': Read-only file system > > > % gpart destroy -F da0 > > > gpart: geom 'da0': Read-only file system > > > % gpart show da0 > > > =3D> 40 60063664 da0 GPT (29G) > > > 40 60063664 1 ms-basic-data (29G) > > > % gpart delete -i 1 da0 > > > gpart: geom 'da0': Read-only file system > > > % dd if=3D/dev/zero of=3D/dev/da0 bs=3D1m > > > dd: /dev/da0: Read-only file system > > > > > = > > What's mounted? > > = > > Nothing mounted other than the boot partition on > an internal hard drive. I plugged the memstick into > a usb port, and use gpart to list disk info. > > % df > Filesystem 1M-blocks Used Avail Capacity Mounted on > /dev/ada0p2 458231 62032 359539 15% / > devfs 0 0 0 0% /dev > > ada0p1 is the EFI boot partition on the internal drive. > ada0p3 is swap. > > % gpart list da0 > Geom name: da0 > modified: false > state: OK > fwheads: 255 > fwsectors: 63 > last: 60063703 > first: 40 > entries: 128 > scheme: GPT > Providers: > 1. Name: da0p1 > Mediasize: 30752595968 (29G) > Sectorsize: 512 > Stripesize: 0 > Stripeoffset: 20480 > Mode: r0w0e0 > efimedia: HD(1,GPT,a2e07858-a4b6-11ec-ac6a-fcaa142bc587,0x28,0x3947fb= 0) > rawuuid: a2e07858-a4b6-11ec-ac6a-fcaa142bc587 > rawtype: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 > label: (null) > length: 30752595968 > offset: 20480 > type: ms-basic-data > index: 1 > end: 60063703 > start: 40 > Consumers: > 1. Name: da0 > Mediasize: 30752636928 (29G) > Sectorsize: 512 > Mode: r0w0e0 > > I did find = > > % sysctl -a | grep da01 > kern.geom.disk.da0.flags: 1a8 > > So, I suppose the question is how to clear WRITEPROTECT. I dont use efi & gpart but some ideas: Why da01 not da0 ? What is da01 ? a typo, or pulling in some gpart kernel stuff ? Is an escalated security level catching you ? I stick to default, on 12.4-rel multi user thats: sysctl -a | grep level # kern.securelevel: -= 1 Try a fresh reboot, even staying single user, & before you touch it with any gpart invoking command, whack it with multiple dd if=3D/dev/zero of=3D/dev/zero count=3D5000 (multiple as sometimes Ive seen first attempt doesnt seem to clear my sticks, a 2nd reboot after dd will clear any false cached memories) If that doesnt work: Try an older BSD that does know about EFI & gpart ? Put it a Microsoft PC, or a USB to Go adapter on an android, that probbly will complain unknown & offer to bash it back to MBR ? Rumage around or ask friends, eg I have a tiny old match box size thing that clones sticks. Clone your stick from some other small stick, then repair the wrong sized MBR Cheers, -- = Julian Stacey www.StolenVotes.UK/jhs/ Arm Ukraine, Zap Putin. Brexit infl= ates http://berklix.org/ferries/#dover_solution