NetBSD Problem Report #51230
From hf@spg.tu-darmstadt.de Thu Jun 9 12:23:34 2016
Return-Path: <hf@spg.tu-darmstadt.de>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id 47E4B7A473
for <gnats-bugs@gnats.NetBSD.org>; Thu, 9 Jun 2016 12:23:34 +0000 (UTC)
Message-Id: <201606091223.u59CNTUm015843@Gstoder.nt.e-technik.tu-darmstadt.de>
Date: Thu, 9 Jun 2016 14:23:29 +0200 (CEST)
From: Hauke Fath <hf@spg.tu-darmstadt.de>
Reply-To: Hauke Fath <hf@spg.tu-darmstadt.de>
To: gnats-bugs@NetBSD.org
Cc: Hauke Fath <hf@spg.tu-darmstadt.de>
Subject: 'gpt biosboot' needs to mark protective mbr partition as 'active'
X-Send-Pr-Version: 3.95
>Number: 51230
>Category: bin
>Synopsis: 'gpt biosboot' needs to mark protective mbr partition as 'active'
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: jnemeth
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Jun 09 12:25:00 +0000 2016
>Closed-Date: Fri Apr 24 00:29:00 +0000 2020
>Last-Modified: Fri Apr 24 00:29:00 +0000 2020
>Originator: Hauke Fath
>Release: NetBSD 7.0_STABLE
>Organization:
Technische Universitaet Darmstadt
>Environment:
System: NetBSD Gstoder 7.0_STABLE NetBSD 7.0_STABLE (MONOLITHIC) #1: Fri Apr 1 14:41:59 CEST 2016 hf@Hochstuhl:/var/obj/netbsd-builds/7/i386/sys/arch/i386/compile/MONOLITHIC i386
Architecture: i386
Machine: i386
>Description:
Because of disklabel's size limitations, NetBSD on inteloid
hardware is migrating to the gpt partition format. Although
gpt is also used by UEFI, we don't support that, and require
machines to use the legacy mbr format. Our gpt-enabled mbr
will then know how to use the gpt partition table.
When gpt(8) creates a gpt table on a disk, it also writes a
protective mbr partition table, to keep legacy tools from
showing an empty disk.
When 'gpt biosboot' prepares a bootable disk, it will install
its custom mbr to block 0, and mark the indicated disk slice
as bootable, but it will not update the protective mbr table.
Some manufacturers
(<http://h30434.www3.hp.com/t5/Notebook-Hardware-and-Upgrade-Questions/GPT-drive-BootDevice-Not-found/td-p/5053274>. as
well as the HP Elitebook 2170p here) require all Ts crossed
and Is dotted before recognizing a legacy mbr as
bootable. They will especially not execute the mbr code unless
the mbr table has a partition marked 'active', and present you
with a terse "Boot Device Not Found" error.
'gpt biosboot' should mark the protective mbr's partition
'active', and does not.
>How-To-Repeat:
Get a newish laptop from HP, switch it to legacy boot,
partition the disk with gpt(8), and install NetBSD. You will
find the lapop boots with the disk on an external USB adapter,
but not as an internal disk.
>Fix:
Teach 'gpt biosboot' to set the 'active' flag on the
protective mbr table's (sole) partition.
Possible workarounds:
(a) punt, and disklabel(8) the disk
(b) 'gpt create <drive>', then 'fdisk -0 -a <drive>', then
'gpt create <drive>' again, bedause the fdisk run will have
stomped on the gpt. Interesting enough, the second 'gpt
create' will leave the protective mbr intact. Then partition
and make bootable with gpt(8), and install.
(c) running 'fdisk -0 -a <drive>' against the protective mbr
of an existing partition will trash the gpt. I tried this, and
'gpt recover' did not find a backup gpt (that's a bug in its
own right) - luckily I could re-create start and end of my
installation's one partition from memory. The installation was
bootable from internal disk afterwards.
>Release-Note:
>Audit-Trail:
From: Christos Zoulas <christos@zoulas.com>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: bin/51230: 'gpt biosboot' needs to mark protective mbr partition as 'active'
Date: Thu, 9 Jun 2016 08:30:47 -0400
can you try the gpt from head.
christos
>
From: Hauke Fath <hf@spg.tu-darmstadt.de>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@NetBSD.org
Subject: Re: bin/51230: 'gpt biosboot' needs to mark protective mbr
partition as 'active'
Date: Thu, 9 Jun 2016 16:00:39 +0200
On Thu, 9 Jun 2016 12:35:01 +0000 (UTC), Christos Zoulas wrote:
> can you try the gpt from head.
With gpt from -current source, as built on netbsd-7, 'gpt <disk>=20
biosboot'(*) does not set the protective mbr's 'active' flag either.
Nor did I see anything in the source that pretends to.
Cheerio,
hauke
(*) Thanks to whoever decided to change 'gpt <command> <disk>' to 'gpt=20
<disk> <command>', btw...
--=20
The ASCII Ribbon Campaign Hauke Fath
() No HTML/RTF in email Institut f=FCr Nachrichtentechnik
/\ No Word docs in email TU Darmstadt
Respect for open standards Ruf +49-6151-16-21344
From: Hauke Fath <hf@spg.tu-darmstadt.de>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@NetBSD.org
Subject: Re: bin/51230: 'gpt biosboot' needs to mark protective mbr
partition as 'active'
Date: Thu, 9 Jun 2016 16:44:16 +0200
On Thu, 9 Jun 2016 12:25:00 +0000 (UTC), Hauke Fath wrote:
> Some manufacturers
>
(<http://h30434.www3.hp.com/t5/Notebook-Hardware-and-Upgrade-Questions/GPT-drive-BootDevice-Not-found/td-p/5053274>.
> as well as the HP Elitebook 2170p here) require all Ts crossed
> and Is dotted before recognizing a legacy mbr as bootable.
See also <http://www.rodsbooks.com/gdisk/bios.html>.
From: Hauke Fath <hf@spg.tu-darmstadt.de>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@NetBSD.org
Subject: Re: bin/51230: 'gpt biosboot' needs to mark protective mbr
partition as 'active'
Date: Thu, 9 Jun 2016 16:06:01 +0200
On Thu, 9 Jun 2016 12:35:01 +0000 (UTC), Christos Zoulas wrote:
> can you try the gpt from head.
... and 'gpt-current <disk> recover' after a previous 'fdisk 0 a=20
<disk>' doesn't either.
Cheerio,
hauke
--=20
The ASCII Ribbon Campaign Hauke Fath
() No HTML/RTF in email Institut f=FCr Nachrichtentechnik
/\ No Word docs in email TU Darmstadt
Respect for open standards Ruf +49-6151-16-21344
From: christos@zoulas.com (Christos Zoulas)
To: Hauke Fath <hf@spg.tu-darmstadt.de>, gnats-bugs@NetBSD.org
Cc: gnats-admin@NetBSD.org
Subject: Re: bin/51230: 'gpt biosboot' needs to mark protective mbr partition as 'active'
Date: Thu, 9 Jun 2016 10:51:47 -0400
On Jun 9, 4:00pm, hf@spg.tu-darmstadt.de (Hauke Fath) wrote:
-- Subject: Re: bin/51230: 'gpt biosboot' needs to mark protective mbr partit
| On Thu, 9 Jun 2016 12:35:01 +0000 (UTC), Christos Zoulas wrote:
| > can you try the gpt from head.
|
| With gpt from -current source, as built on netbsd-7, 'gpt <disk>=20
| biosboot'(*) does not set the protective mbr's 'active' flag either.
|
| Nor did I see anything in the source that pretends to.
|
| (*) Thanks to whoever decided to change 'gpt <command> <disk>' to 'gpt=20
| <disk> <command>', btw...
|
Well, now it takes both :-) I will fix it.
christos
From: Hauke Fath <hf@spg.tu-darmstadt.de>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org
Subject: Re: bin/51230: 'gpt biosboot' needs to mark protective mbr
partition as 'active'
Date: Thu, 9 Jun 2016 16:58:34 +0200
On Thu, 9 Jun 2016 14:50:01 +0000 (UTC), Hauke Fath wrote:
> ... and 'gpt-current <disk> recover' after a previous 'fdisk 0 a=20
> <disk>' doesn't either.
A 'gpt recover' after dd(1)ing over the start of the disk works, so
presumably, gpt and mbr formats store their backups at the same place
near the end of the disk?
Could gpt(8) maybe steer clear of the older brother's data when writing
its backup?
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/51230 CVS commit: src/sbin/gpt
Date: Thu, 9 Jun 2016 11:12:54 -0400
Module Name: src
Committed By: christos
Date: Thu Jun 9 15:12:54 UTC 2016
Modified Files:
src/sbin/gpt: biosboot.c create.c gpt.8 gpt.c gpt.h migrate.c show.c
Log Message:
PR/51230: Add the ability to set the active flag in the PMBR.
To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sbin/gpt/biosboot.c
cvs rdiff -u -r1.20 -r1.21 src/sbin/gpt/create.c
cvs rdiff -u -r1.45 -r1.46 src/sbin/gpt/gpt.8
cvs rdiff -u -r1.67 -r1.68 src/sbin/gpt/gpt.c
cvs rdiff -u -r1.32 -r1.33 src/sbin/gpt/gpt.h
cvs rdiff -u -r1.30 -r1.31 src/sbin/gpt/migrate.c
cvs rdiff -u -r1.36 -r1.37 src/sbin/gpt/show.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: Hauke Fath <hf@spg.tu-darmstadt.de>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org, Christos Zoulas <christos@netbsd.org>
Subject: Re: PR/51230 CVS commit: src/sbin/gpt
Date: Thu, 9 Jun 2016 17:32:06 +0200
On Thu, 9 Jun 2016 15:15:01 +0000 (UTC), Christos Zoulas wrote:
> PR/51230: Add the ability to set the active flag in the PMBR.
Thanks! But...
# bin/gpt-current sd0 biosboot -a -i1
gpt-current: unknown option -- a
Usage: gpt-current <device> biosboot [-c bootcode] [-i index] [-L label]
#
and gpt.8 renders to
gpt biosboot [-ac bootcode] [-i index] [-L label]
Cheerio,
hauke
From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: PR/51230 CVS commit: src/sbin/gpt
Date: Fri, 10 Jun 2016 00:24:06 +0700
Date: Thu, 9 Jun 2016 15:35:02 +0000 (UTC)
From: Hauke Fath <hf@spg.tu-darmstadt.de>
Message-ID: <20160609153502.4E35C7AAB7@mollari.NetBSD.org>
| Thanks! But...
|
| # bin/gpt-current sd0 biosboot -a -i1
| gpt-current: unknown option -- a
| Usage: gpt-current <device> biosboot [-c bootcode] [-i index] [-L label]
| #
Believe it or not, the correct usage is still "gpt biosboot [opts] device
The usage message prints it in the order you show whenver the command
name is not "gpt" (which it isn't for you). I have no idea why, I see
no code to support the devide first ordering (whatever the command name is)
I suspect it is an artifact of that you're seeing (though I get a
different message when I try it that way.)
| and gpt.8 renders to
|
| gpt biosboot [-ac bootcode] [-i index] [-L label]
Fixed.
ALso, thanks for tracking down this problem, I noticed it back in Dec 2013,
and worked out the fdisk (to put a regular MBR there) followed by gpt
create (to convert that to a PMBR) solved the problem, and had worked out
that gpt create on an uninit'd drive was not setting something properly,
but I never got as far as working out what that was.
I think though that Christos new -a flag should be changed (probably to -A)
(througout) to avoid clashes with the "-a alignment" option that is
used everywhere else (even the biosboot usage has a "[-a alignment]"
option already in it .. just #ifdef'd out, the new -a would prevent that.)
kre
From: christos@zoulas.com (Christos Zoulas)
To: Hauke Fath <hf@spg.tu-darmstadt.de>, gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org
Subject: Re: PR/51230 CVS commit: src/sbin/gpt
Date: Thu, 9 Jun 2016 13:37:20 -0400
On Jun 9, 5:32pm, hf@spg.tu-darmstadt.de (Hauke Fath) wrote:
-- Subject: Re: PR/51230 CVS commit: src/sbin/gpt
| On Thu, 9 Jun 2016 15:15:01 +0000 (UTC), Christos Zoulas wrote:
| > PR/51230: Add the ability to set the active flag in the PMBR.
|
| Thanks! But...
|
| # bin/gpt-current sd0 biosboot -a -i1
| gpt-current: unknown option -- a
| Usage: gpt-current <device> biosboot [-c bootcode] [-i index] [-L label]
| #
|
| and gpt.8 renders to
|
| gpt biosboot [-ac bootcode] [-i index] [-L label]
Let me try again :-)
christos
From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: bin/51230: 'gpt biosboot' needs to mark protective mbr partition as 'active'
Date: Fri, 10 Jun 2016 00:47:53 +0700
Date: Thu, 9 Jun 2016 15:00:01 +0000 (UTC)
From: Hauke Fath <hf@spg.tu-darmstadt.de>
Message-ID: <20160609150001.B8DF27AAA6@mollari.NetBSD.org>
| A 'gpt recover' after dd(1)ing over the start of the disk works, so
| presumably, gpt and mbr formats store their backups at the same place
| near the end of the disk?
No, that's not the problem, "gpt recover" expressly refuses to do
anything at all if the device contains a regular MBR (attempting to
avoid accidentally wiping out valid filesystems I presume). Since
zapping the MBR followed by a recover works, I think it probably advisable
to leave that protection as it is.
kre
From: christos@zoulas.com (Christos Zoulas)
To: Hauke Fath <hf@spg.tu-darmstadt.de>, gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org
Subject: Re: PR/51230 CVS commit: src/sbin/gpt
Date: Thu, 9 Jun 2016 13:51:02 -0400
On Jun 9, 5:32pm, hf@spg.tu-darmstadt.de (Hauke Fath) wrote:
-- Subject: Re: PR/51230 CVS commit: src/sbin/gpt
| On Thu, 9 Jun 2016 15:15:01 +0000 (UTC), Christos Zoulas wrote:
| > PR/51230: Add the ability to set the active flag in the PMBR.
|
| Thanks! But...
|
| # bin/gpt-current sd0 biosboot -a -i1
| gpt-current: unknown option -- a
| Usage: gpt-current <device> biosboot [-c bootcode] [-i index] [-L label]
| #
|
| and gpt.8 renders to
|
| gpt biosboot [-ac bootcode] [-i index] [-L label]
Hmm...
[1:49pm] 106#dd if=/dev/zero of=foo count=10000
10000+0 records in
10000+0 records out
5120000 bytes transferred in 0.361 secs (14182825 bytes/sec)
[1:49pm] 107#obj.amd64/gpt create foo
[1:49pm] 108#obj.amd64/gpt add -l test foo
foo: Partition 1 added: 49f48d5a-b10e-11dc-b99b-0019d1879648 34 9933
[1:49pm] 109#obj.amd64/gpt biosboot -a -i 1 foo
foo: Partition 1 marked as bootable
[1:49pm] 110#fdisk foo
Disk: foo
NetBSD disklabel disk geometry:
cylinders: 1, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
total sectors: 10000, bytes/sector: 512
BIOS disk geometry:
cylinders: 1, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
total sectors: 10000
Partitions aligned to 16065 sector boundaries, offset 63
Partition table:
0: GPT Protective MBR (sysid 238)
start 1, size 9999 (5 MB, Cyls 0/0/2-0/158/46), Active
PBR is not bootable: Bad magic number (0x0000)
1: <UNUSED>
2: <UNUSED>
3: <UNUSED>
First active partition: 0
Drive serial number: 0 (0x00000000)
christos
From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@NetBSD.org
Cc: christos@zoulas.com (Christos Zoulas), Hauke Fath <hf@spg.tu-darmstadt.de>
Subject: Re: PR/51230 CVS commit: src/sbin/gpt
Date: Fri, 10 Jun 2016 01:13:37 +0700
christos@zoulas.com said:
| On Jun 9, 5:32pm, hf@spg.tu-darmstadt.de (Hauke Fath) wrote:
| -- Subject: Re: PR/51230 CVS commit: src/sbin/gpt
| | On Thu, 9 Jun 2016 15:15:01 +0000 (UTC), Christos Zoulas wrote:
| | > PR/51230: Add the ability to set the active flag in the PMBR.
| |
| | Thanks! But...
| |
| | # bin/gpt-current sd0 biosboot -a -i1
| | gpt-current: unknown option -- a
| | Usage: gpt-current <device> biosboot [-c bootcode] [-i index] [-L label]
| | #
| Hmm...
Yes, it works for me too, just the same as it does for you (though I
used /tmp/V instead of foo ...) I suspect that Hauk somehow used a
different version of gpt than the one he intended to use, as the only
way to get getopt() to display the
gpt-current: unknown option -- a
is if 'a' isn't in the getopt option string (for biosboot in this case)
which it clearly was.
Also, since the version he used appears to support "gpt device command"
whereas as best I can tell, the standard version only supports
"gpt command device", that also strongly hints that his test was using
the wrong gpt binary.
I would suggest changing the -a's that you added to -A though, the
biosboot help message is currently...
static const char *biosboothelp[] = {
"[-a] [-c bootcode] [-i index] [-L label]",
#if notyet
"[-a alignment] [-b blocknr] [-i index] [-l label]",
"[-s size] [-t type]",
#endif
};
If that "notyet" #if goes away, and biosboot supports some of those
options, there could be something of a mess (though why biosboot would
ever want an alignment, or size or type, option, I cannot fathom.)
But s/a/A/ is a cheap change to make now before the new -a usage becomes
known.
kre
From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
Hauke Fath <hf@spg.tu-darmstadt.de>
Cc:
Subject: Re: PR/51230 CVS commit: src/sbin/gpt
Date: Thu, 9 Jun 2016 14:45:21 -0400
On Jun 9, 5:25pm, kre@munnari.OZ.AU (Robert Elz) wrote:
-- Subject: Re: PR/51230 CVS commit: src/sbin/gpt
| The following reply was made to PR bin/51230; it has been noted by GNATS.
|
| From: Robert Elz <kre@munnari.OZ.AU>
| To: gnats-bugs@NetBSD.org
| Cc:
| Subject: Re: PR/51230 CVS commit: src/sbin/gpt
| Date: Fri, 10 Jun 2016 00:24:06 +0700
|
| Date: Thu, 9 Jun 2016 15:35:02 +0000 (UTC)
| From: Hauke Fath <hf@spg.tu-darmstadt.de>
| Message-ID: <20160609153502.4E35C7AAB7@mollari.NetBSD.org>
|
| | Thanks! But...
| |
| | # bin/gpt-current sd0 biosboot -a -i1
| | gpt-current: unknown option -- a
| | Usage: gpt-current <device> biosboot [-c bootcode] [-i index] [-L label]
| | #
|
| Believe it or not, the correct usage is still "gpt biosboot [opts] device
| The usage message prints it in the order you show whenver the command
| name is not "gpt" (which it isn't for you). I have no idea why, I see
| no code to support the devide first ordering (whatever the command name is)
|
| I suspect it is an artifact of that you're seeing (though I get a
| different message when I try it that way.)
|
| | and gpt.8 renders to
| |
| | gpt biosboot [-ac bootcode] [-i index] [-L label]
|
| Fixed.
|
| ALso, thanks for tracking down this problem, I noticed it back in Dec 2013,
| and worked out the fdisk (to put a regular MBR there) followed by gpt
| create (to convert that to a PMBR) solved the problem, and had worked out
| that gpt create on an uninit'd drive was not setting something properly,
| but I never got as far as working out what that was.
|
| I think though that Christos new -a flag should be changed (probably to -A)
| (througout) to avoid clashes with the "-a alignment" option that is
| used everywhere else (even the biosboot usage has a "[-a alignment]"
| option already in it .. just #ifdef'd out, the new -a would prevent that.)
Good idea.
christos
From: Hauke Fath <hf@spg.tu-darmstadt.de>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@NetBSD.org
Subject: Re: PR/51230 CVS commit: src/sbin/gpt
Date: Thu, 9 Jun 2016 20:50:06 +0200
On Thu, 9 Jun 2016 17:40:01 +0000 (UTC), Christos Zoulas wrote:
> | # bin/gpt-current sd0 biosboot -a -i1
> | gpt-current: unknown option -- a
> | Usage: gpt-current <device> biosboot [-c bootcode] [-i index] [-L label]
> | #
>
> Let me try again :-)
[hauke@Anscharte] ~/bin # ./gpt-current sd0 biosboot -a -i1
/dev/rsd0d: Partition 1 marked as bootable
[hauke@Anscharte] ~/bin # fdisk sd0 | grep active
fdisk: Cannot determine the number of heads
First active partition: 0
[hauke@Anscharte] ~/bin #
:)
hauke
From: John Nemeth <jnemeth@cue.bc.ca>
To: gnats-bugs@NetBSD.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
Hauke Fath <hf@spg.tu-darmstadt.de>
Cc:
Subject: Re: bin/51230: 'gpt biosboot' needs to mark protective mbr partition as 'active'
Date: Thu, 9 Jun 2016 12:51:34 -0700
On Jun 9, 3:00pm, Hauke Fath wrote:
}
} The following reply was made to PR bin/51230; it has been noted by GNATS.
}
} From: Hauke Fath <hf@spg.tu-darmstadt.de>
} Date: Thu, 9 Jun 2016 16:58:34 +0200
}
} On Thu, 9 Jun 2016 14:50:01 +0000 (UTC), Hauke Fath wrote:
} > ... and 'gpt-current <disk> recover' after a previous 'fdisk 0 a
} > <disk>' doesn't either.
}
} A 'gpt recover' after dd(1)ing over the start of the disk works, so
} presumably, gpt and mbr formats store their backups at the same place
} near the end of the disk?
There is no such thing as an mbr backup. The location of the
GPT backup is specified in the UEFI spec and is thus non-negotiable.
} Could gpt(8) maybe steer clear of the older brother's data when writing
} its backup?
The issue has nothing to do with gpt(8). The problem is that
fdisk(8) explicitly blows away both the primary and backup GPTs
any time it writes to the disk, including when simply updating the
"active" flag. gpt(8)'s "recover" command simply copies an existing
GPT over a missing GPT. After fdisk(8) has written to the disk,
there are no existing GPTs to be copied.
}-- End of excerpt from Hauke Fath
From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: PR/51230 CVS commit: src/sbin/gpt
Date: Fri, 10 Jun 2016 04:12:14 +0700
Date: Thu, 9 Jun 2016 17:25:01 +0000 (UTC)
From: Robert Elz <kre@munnari.OZ.AU>
Message-ID: <20160609172501.A4DC17AAA2@mollari.NetBSD.org>
| I see no code to support the device first ordering
Actually, when I really read the code, instead of just guessing, I do
see how that works ... if the command name is "gpt" the old syntax applies
(gpt [globalopts] sub-cmd [cmd-opts] device) and if the name is anything
else (the makefile looks as if it is intended to be gptlabel - one day)
then the device moves forward (gptlabel [globalopts] device sub-cmd [cmd-opts])
kre
From: Hauke Fath <hf@spg.tu-darmstadt.de>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@NetBSD.org
Subject: Re: bin/51230: 'gpt biosboot' needs to mark protective mbr
partition as 'active'
Date: Fri, 10 Jun 2016 10:25:02 +0200
On Thu, 9 Jun 2016 19:40:01 +0000 (UTC), John Nemeth wrote:
> There is no such thing as an mbr backup.
Yes, I'd learned that in the meantime.
> The location of the
> GPT backup is specified in the UEFI spec and is thus non-negotiable.
> =20
> } Could gpt(8) maybe steer clear of the older brother's data when writi=
ng=20
> } its backup?
> =20
> The issue has nothing to do with gpt(8). The problem is that
> fdisk(8) explicitly blows away both the primary and backup GPTs
> any time it writes to the disk, including when simply updating the
> "active" flag.
... which feels a bit radical, but I ca see there are situations where=20
you want this. Plus, the fdisk(8) man page is clear about it.
> gpt(8)'s "recover" command simply copies an existing
> GPT over a missing GPT. After fdisk(8) has written to the disk,
> there are no existing GPTs to be copied.
Understood.
I noted, btw, that 'gpt restore' will restore the gpt from a backup,=20
but it will not restore the protecting mbr. Since that can lead to=20
nasty surprises later, it probably should.
Cheerio,
hauke
--=20
The ASCII Ribbon Campaign Hauke Fath
() No HTML/RTF in email Institut f=FCr Nachrichtentechnik
/\ No Word docs in email TU Darmstadt
Respect for open standards Ruf +49-6151-16-21344
From: Hauke Fath <hf@spg.tu-darmstadt.de>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org
Subject: Re: PR/51230 CVS commit: src/sbin/gpt
Date: Fri, 10 Jun 2016 10:28:23 +0200
On Thu, 9 Jun 2016 21:15:00 +0000 (UTC), Robert Elz wrote:
> Actually, when I really read the code, instead of just guessing, I do
> see how that works ... if the command name is "gpt" the old syntax appli=
es
> (gpt [globalopts] sub-cmd [cmd-opts] device) and if the name is anything
> else (the makefile looks as if it is intended to be gptlabel - one day)
> then the device moves forward (gptlabel [globalopts] device sub-cmd=20
> [cmd-opts])
... sneaky!=20
I've always found the 'gpt <cmd> <disk>' vs. 'dkctl <disk> <cmd>'=20
annoying, and always have to look up which is which. The two tools'=20
interfaces should be synced better.
Cheerio,
Hauke
--=20
The ASCII Ribbon Campaign Hauke Fath
() No HTML/RTF in email Institut f=FCr Nachrichtentechnik
/\ No Word docs in email TU Darmstadt
Respect for open standards Ruf +49-6151-16-21344
From: John Nemeth <jnemeth@cue.bc.ca>
To: gnats-bugs@NetBSD.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
Hauke Fath <hf@spg.tu-darmstadt.de>
Cc:
Subject: Re: bin/51230: 'gpt biosboot' needs to mark protective mbr partition as 'active'
Date: Fri, 10 Jun 2016 02:59:01 -0700
On Jun 10, 8:30am, Hauke Fath wrote:
} The following reply was made to PR bin/51230; it has been noted by GNATS.
}
} From: Hauke Fath <hf@spg.tu-darmstadt.de>
} Date: Fri, 10 Jun 2016 10:25:02 +0200
}
} I noted, btw, that 'gpt restore' will restore the gpt from a backup,=20
} but it will not restore the protecting mbr. Since that can lead to=20
} nasty surprises later, it probably should.
Actually, it will restore the "protecting mbr", and it will
automatically adjust it if you are restoring to a disk of a different
size. 'gpt backup' produces a text file, so you can look at it to
see what is saved. However, you should not edit it.
}-- End of excerpt from Hauke Fath
From: Hauke Fath <hf@spg.tu-darmstadt.de>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org
Subject: Re: bin/51230: 'gpt biosboot' needs to mark protective mbr
partition as 'active'
Date: Fri, 10 Jun 2016 11:55:38 +0200
On Fri, 10 Jun 2016 09:50:00 +0000 (UTC), John Nemeth wrote:
> } I noted, btw, that 'gpt restore' will restore the gpt from a backup,=
=3D20
> } but it will not restore the protecting mbr. Since that can lead to=3D=
20
> } nasty surprises later, it probably should.
> =20
> Actually, it will restore the "protecting mbr", and it will
> automatically adjust it if you are restoring to a disk of a different
> size. 'gpt backup' produces a text file, so you can look at it to
> see what is saved. However, you should not edit it.
Sorry, the above was meant to say "gpt recover".
I just retried with -current gpt, and while it will restore a=20
dd(8)ed-over primary gpt from the secondary copy, it will not restore=20
the PMBR.
Cheerio,
hauke
--=20
The ASCII Ribbon Campaign Hauke Fath
() No HTML/RTF in email Institut f=FCr Nachrichtentechnik
/\ No Word docs in email TU Darmstadt
Respect for open standards Ruf +49-6151-16-21344
From: John Nemeth <jnemeth@cue.bc.ca>
To: gnats-bugs@NetBSD.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
Hauke Fath <hf@spg.tu-darmstadt.de>
Cc:
Subject: Re: PR/51230 CVS commit: src/sbin/gpt
Date: Fri, 10 Jun 2016 03:39:56 -0700
On Jun 10, 8:30am, Hauke Fath wrote:
} The following reply was made to PR bin/51230; it has been noted by GNATS.
}
} From: Hauke Fath <hf@spg.tu-darmstadt.de>
} Date: Fri, 10 Jun 2016 10:28:23 +0200
}
} On Thu, 9 Jun 2016 21:15:00 +0000 (UTC), Robert Elz wrote:
} > Actually, when I really read the code, instead of just guessing, I do
} > see how that works ... if the command name is "gpt" the old syntax applies
} > (gpt [globalopts] sub-cmd [cmd-opts] device) and if the name is anything
} > else (the makefile looks as if it is intended to be gptlabel - one day)
} > then the device moves forward (gptlabel [globalopts] device sub-cmd
} > [cmd-opts])
}
} ... sneaky!
}
} I've always found the 'gpt <cmd> <disk>' vs. 'dkctl <disk> <cmd>'
} annoying, and always have to look up which is which. The two tools'
} interfaces should be synced better.
It was originally 'gpt <cmd> <disk>...', i.e. you could supply
multiple <disk> and it would perform <cmd> on all of them. This
functionaliy was of limited use and was eliminated when Christos
did a major rework of the way gpt(8) parses its options.
gpt(8) was originally imported from FreeBSD with very minimal
change ('gpt migrate' wasn't even capable of handling NetBSD disks
for the first seven years it was in NetBSD). In the mean time,
FreeBSD ditched it and replaced it with 'gpart' which is just a
thin wrapper around syscalls (i.e. in FreeBSD the kernel does all
the work of making changes to all types of disk partitioning schemes
now). However, in NetBSD, gpt(8) has seen several overhauls,
including adding all the functionality that FreeBSD's gpart has
and then some.
Unfortunately, it is too late to make gpt(8) work like dkctl,
etc., since gpt(8) has been a part of NetBSD for almost ten years
(it was imported on Oct. 15th, 2006). One option, which Robert
noted, would be to have a link, called 'gptlabel' which would behave
similiar to how 'dkctl' does.
}-- End of excerpt from Hauke Fath
From: Hauke Fath <hf@spg.tu-darmstadt.de>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org
Subject: Re: PR/51230 CVS commit: src/sbin/gpt
Date: Fri, 10 Jun 2016 12:52:05 +0200
On Fri, 10 Jun 2016 10:30:01 +0000 (UTC), John Nemeth wrote:
Thanks for the lengthy explanation.
> Unfortunately, it is too late to make gpt(8) work like dkctl,
> etc., since gpt(8) has been a part of NetBSD for almost ten years
> (it was imported on Oct. 15th, 2006).
While one could say that it was slow in the coming, and probably still=20
isn't widely being used...
> One option, which Robert
> noted, would be to have a link, called 'gptlabel' which would behave
> similiar to how 'dkctl' does.
... this might well be the best solution.
Cheerio,
hauke
--=20
The ASCII Ribbon Campaign Hauke Fath
() No HTML/RTF in email Institut f=FCr Nachrichtentechnik
/\ No Word docs in email TU Darmstadt
Respect for open standards Ruf +49-6151-16-21344
From: "John Nemeth" <jnemeth@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/51230 CVS commit: src/sbin/gpt
Date: Sun, 12 Jun 2016 12:48:33 +0000
Module Name: src
Committed By: jnemeth
Date: Sun Jun 12 12:48:33 UTC 2016
Modified Files:
src/sbin/gpt: recover.c
Log Message:
- fix setting of hdr_lba_alt which was broken in revision 1.10 on 2015/12/2
- switch to using gpt_last
- PR/51230 -- recreate the PMBR if it was lost
To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sbin/gpt/recover.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: John Nemeth <jnemeth@cue.bc.ca>
To: gnats-bugs@NetBSD.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
Hauke Fath <hf@spg.tu-darmstadt.de>
Cc:
Subject: Re: bin/51230: 'gpt biosboot' needs to mark protective mbr partition as 'active'
Date: Sun, 12 Jun 2016 06:16:40 -0700
On Jun 10, 10:00am, Hauke Fath wrote:
}
} The following reply was made to PR bin/51230; it has been noted by GNATS.
}
} From: Hauke Fath <hf@spg.tu-darmstadt.de>
} Date: Fri, 10 Jun 2016 11:55:38 +0200
}
} On Fri, 10 Jun 2016 09:50:00 +0000 (UTC), John Nemeth wrote:
} > } I noted, btw, that 'gpt restore' will restore the gpt from a backup,
} > } but it will not restore the protecting mbr. Since that can lead to
} > } nasty surprises later, it probably should.
} >
} > Actually, it will restore the "protecting mbr", and it will
} > automatically adjust it if you are restoring to a disk of a different
} > size. 'gpt backup' produces a text file, so you can look at it to
} > see what is saved. However, you should not edit it.
}
} Sorry, the above was meant to say "gpt recover".
}
} I just retried with -current gpt, and while it will restore a
} dd(8)ed-over primary gpt from the secondary copy, it will not restore
} the PMBR.
Good catch. I just fixed that. Along with a rather serious
bug from Dec. 2nd, 2015, which I just discovered. It was noticable
if you ran "gpt recover" twice in a row. The second time, it would
complain that the disk size had changed when it obviously had not.
It simply should have exited with nothing happening. The issue
was that the pointer in the "recovered" GPT which pointed to the
other GPT was being set incorrectly.
Anyways, I think we can probably close the PR now. Normally,
I would say to leave it open for pullups. But, there is quite a
bit of gpt(8) that should be pulled up to both 6.x and 7.x (especially
6.x).
}-- End of excerpt from Hauke Fath
Responsible-Changed-From-To: bin-bug-people->jnemeth
Responsible-Changed-By: jnemeth@NetBSD.org
Responsible-Changed-When: Sun, 19 Jun 2016 07:14:21 +0000
Responsible-Changed-Why:
I was the last one to work on mentioned problems.
State-Changed-From-To: open->feedback
State-Changed-By: jnemeth@NetBSD.org
State-Changed-When: Sun, 19 Jun 2016 07:14:21 +0000
State-Changed-Why:
All problems have been fixed. Awaiting response from originator about closing.
From: Hauke Fath <hf@spg.tu-darmstadt.de>
To: gnats-bugs@NetBSD.org
Cc: jnemeth@NetBSD.org, gnats-admin@NetBSD.org
Subject: Re: bin/51230 ('gpt biosboot' needs to mark protective mbr
partition as 'active')
Date: Sun, 19 Jun 2016 12:24:48 +0200
On Sun, 19 Jun 2016 07:14:22 +0000 (UTC), jnemeth@NetBSD.org wrote:
> All problems have been fixed. Awaiting response from originator
> about closing.
Well, I guess, this is a case for dholland's 'needs-pullup' gnats
state...
Building -current gpt on -7 works for me, but I think the chnage should
be on the release branches.
Cheerio,
hauke
State-Changed-From-To: feedback->open
State-Changed-By: hauke@NetBSD.org
State-Changed-When: Mon, 20 Jun 2016 08:17:48 +0000
State-Changed-Why:
I provided feedback.
State-Changed-From-To: open->needs-pullups
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Mon, 20 Jun 2016 17:19:33 +0000
State-Changed-Why:
should be in -7
From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/51230 CVS commit: [netbsd-7] src/sbin/gpt
Date: Mon, 13 Aug 2018 16:12:12 +0000
Module Name: src
Committed By: martin
Date: Mon Aug 13 16:12:12 UTC 2018
Modified Files:
src/sbin/gpt [netbsd-7]: Makefile add.c backup.c biosboot.c create.c
destroy.c gpt.8 gpt.c gpt.h gpt_uuid.c gpt_uuid.h label.c map.c
map.h migrate.c recover.c remove.c resize.c resizedisk.c restore.c
set.c show.c type.c unset.c
Added Files:
src/sbin/gpt [netbsd-7]: gpt_private.h header.c main.c
Removed Files:
src/sbin/gpt [netbsd-7]: drvctl.c
Log Message:
Catch up to current for the following, requested by sborrill in ticket #1629:
sbin/gpt/gpt_private.h up to 1.2
sbin/gpt/header.c up to 1.9
sbin/gpt/main.c up to 1.11
sbin/gpt/drvctl.c delete
sbin/gpt/Makefile up to 1.18
sbin/gpt/add.c up to 1.44
sbin/gpt/backup.c up to 1.18
sbin/gpt/biosboot.c up to 1.30
sbin/gpt/create.c up to 1.23
sbin/gpt/destroy.c up to 1.10
sbin/gpt/gpt.8 up to 1.63
sbin/gpt/gpt.c up to 1.75
sbin/gpt/gpt.h up to 1.38
sbin/gpt/gpt_uuid.c up to 1.15
sbin/gpt/gpt_uuid.h up to 1.7
sbin/gpt/label.c up to 1.29
sbin/gpt/map.c up to 1.14
sbin/gpt/map.h up to 1.6
sbin/gpt/migrate.c up to 1.33
sbin/gpt/recover.c up to 1.18
sbin/gpt/remove.c up to 1.22
sbin/gpt/resize.c up to 1.23
sbin/gpt/resizedisk.c up to 1.17
sbin/gpt/restore.c up to 1.18
sbin/gpt/set.c up to 1.14
sbin/gpt/show.c up to 1.41
sbin/gpt/type.c up to 1.15
sbin/gpt/unset.c up to 1.14
Many changes including:
- Significant refactoring
- PR/51230: Add the ability to set the active flag in the PMBR
- Let individual commands decide if ioctl(DIOCMWEDGES) should be done
- Add a "header" subcommand that displays information about the size of
the disk along with information from the GPT header if it exists
- Add listing commands for type, set and unset
- Add help and formatting for set and unset
- Change show to print all the attribute info in one line.
- Improve documentation, including booting and exit status
- Check device parameter to avoid segfaults
To generate a diff of this commit:
cvs rdiff -u -r1.8.2.1 -r1.8.2.2 src/sbin/gpt/Makefile
cvs rdiff -u -r1.24.4.1 -r1.24.4.2 src/sbin/gpt/add.c
cvs rdiff -u -r1.1.6.1 -r1.1.6.2 src/sbin/gpt/backup.c
cvs rdiff -u -r1.7.4.1 -r1.7.4.2 src/sbin/gpt/biosboot.c \
src/sbin/gpt/create.c
cvs rdiff -u -r1.4.20.1 -r1.4.20.2 src/sbin/gpt/destroy.c
cvs rdiff -u -r1.1.2.2 -r0 src/sbin/gpt/drvctl.c
cvs rdiff -u -r1.28.4.1 -r1.28.4.2 src/sbin/gpt/gpt.8
cvs rdiff -u -r1.28.2.1 -r1.28.2.2 src/sbin/gpt/gpt.c
cvs rdiff -u -r1.11.2.1 -r1.11.2.2 src/sbin/gpt/gpt.h
cvs rdiff -u -r0 -r1.2.14.2 src/sbin/gpt/gpt_private.h
cvs rdiff -u -r1.10.2.2 -r1.10.2.3 src/sbin/gpt/gpt_uuid.c
cvs rdiff -u -r1.3.2.3 -r1.3.2.4 src/sbin/gpt/gpt_uuid.h
cvs rdiff -u -r0 -r1.9.4.2 src/sbin/gpt/header.c
cvs rdiff -u -r1.14.4.1 -r1.14.4.2 src/sbin/gpt/label.c \
src/sbin/gpt/migrate.c
cvs rdiff -u -r0 -r1.11.4.2 src/sbin/gpt/main.c
cvs rdiff -u -r1.6.4.1 -r1.6.4.2 src/sbin/gpt/map.c
cvs rdiff -u -r1.3 -r1.3.4.1 src/sbin/gpt/map.h
cvs rdiff -u -r1.4.20.2 -r1.4.20.3 src/sbin/gpt/recover.c
cvs rdiff -u -r1.12.4.1 -r1.12.4.2 src/sbin/gpt/remove.c
cvs rdiff -u -r1.8.6.1 -r1.8.6.2 src/sbin/gpt/resize.c
cvs rdiff -u -r1.6.2.2 -r1.6.2.3 src/sbin/gpt/resizedisk.c \
src/sbin/gpt/type.c
cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sbin/gpt/restore.c
cvs rdiff -u -r1.2.6.1 -r1.2.6.2 src/sbin/gpt/set.c src/sbin/gpt/unset.c
cvs rdiff -u -r1.15.4.1 -r1.15.4.2 src/sbin/gpt/show.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: needs-pullups->closed
State-Changed-By: maya@NetBSD.org
State-Changed-When: Fri, 24 Apr 2020 00:29:00 +0000
State-Changed-Why:
It was pulled up to netbsd-7.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.