NetBSD Problem Report #43105

From www@NetBSD.org  Fri Apr  2 11:52:41 2010
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 4C24A63B86C
	for <gnats-bugs@gnats.NetBSD.org>; Fri,  2 Apr 2010 11:52:41 +0000 (UTC)
Message-Id: <20100402115240.D6E4863B11D@www.NetBSD.org>
Date: Fri,  2 Apr 2010 11:52:40 +0000 (UTC)
From: peter@kerwien.homeip.net
Reply-To: peter@kerwien.homeip.net
To: gnats-bugs@NetBSD.org
Subject: Destroying a GPT partition with dd will cause gpt destroy / create to fail
X-Send-Pr-Version: www-1.0

>Number:         43105
>Category:       port-amd64
>Synopsis:       Destroying a GPT partition with dd will cause gpt destroy / create to fail
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    port-amd64-maintainer
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 02 11:55:00 +0000 2010
>Closed-Date:    Mon Nov 22 04:44:57 +0000 2010
>Last-Modified:  Wed Nov 24 19:15:02 +0000 2010
>Originator:     Peter Kerwien
>Release:        NetBSD 5.0.2_PATCH
>Organization:
>Environment:
NetBSD server1 5.0.2_PATCH NetBSD 5.0.2_PATCH (GENERIC) #0: Sat Mar 27 17:55:16 UTC 2010 root@server1:/usr/obj/sys/arch/amd64/compile/GENERIC amd64
>Description:
When I created a large disk array, and tried to add a gpt partition it failed to destroy/create a GPT label:

server1# gpt -v destroy sd0
gpt: rsd0d: mediasize=4499999293440; sectorsize=512; blocks=8789061120
gpt: unable to open device 'rsd0d': Invalid argument

The reason for this (According to Christos Zoulas, thx for all help!) is that I destroyed a GPT partition with dd, the trailing GPT copy will not be able to get validated leading to inability to remove/add a new GPT label.

I had to zap it with the help of some small program:

#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <err.h>

int
main(void)
{
        static char buf[0x200];
        int fd = open("/dev/rsd0d", O_RDWR);

        if (fd == -1)
                err(1, "open");
        if (lseek(fd, 0x417bcdbfe00ULL, SEEK_SET) == (off_t)-1)
                err(1, "lseek");
        if (write(fd, buf, sizeof(buf)) == -1)
                err(1, "write");
        (void)close(fd);
        return 0;
}

Then I managed to execute gpt destroy / created on sd0 to create a new GPT partition again.

For more information, see the following thread:

http://mail-index.netbsd.org/netbsd-users/2010/03/30/msg005937.html
>How-To-Repeat:
1. Destroy a GPT partition with dd.
2. Try to destroy / create a new label with:

# gpt destroy sd0

or

# gpt create sd0. Will result in:

gpt: unable to open device 'rsd0d': Invalid argument

>Fix:
Zap the trailing EFI partition at the end of the disk.

>Release-Note:

>Audit-Trail:
From: Christos Zoulas <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/43105 CVS commit: src/sbin/gpt
Date: Fri, 2 Apr 2010 09:37:00 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Fri Apr  2 13:36:59 UTC 2010

 Modified Files:
 	src/sbin/gpt: gpt.c

 Log Message:
 PR/43105: Peter Kerwien: Destroying a GPT partition with dd will cause gpt
 destroy / create to fail. When reading the GPT label from the end of the disk
 ignore errors if the GPT label at the beginning of the disk was not found.


 To generate a diff of this commit:
 cvs rdiff -u -r1.10 -r1.11 src/sbin/gpt/gpt.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: PR/43105 CVS commit: src/sbin/gpt
Date: Mon, 25 Oct 2010 02:19:59 +0000

 On Fri, Apr 02, 2010 at 01:40:05PM +0000, Christos Zoulas wrote:
  > PR/43105: Peter Kerwien: Destroying a GPT partition with dd will
  > cause gpt destroy / create to fail. When reading the GPT label from
  > the end of the disk ignore errors if the GPT label at the beginning
  > of the disk was not found.

 Should this be pulled up to -5 (it won't make it into 5.1) or can this
 PR be closed?

 -- 
 David A. Holland
 dholland@netbsd.org

From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, port-amd64-maintainer@netbsd.org, 
	gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, 
	peter@kerwien.homeip.net
Cc: 
Subject: Re: PR/43105 CVS commit: src/sbin/gpt
Date: Sun, 24 Oct 2010 23:36:31 -0400

 On Oct 25,  2:20am, dholland-bugs@netbsd.org (David Holland) wrote:
 -- Subject: Re: PR/43105 CVS commit: src/sbin/gpt

 | The following reply was made to PR port-amd64/43105; it has been noted by GNATS.
 | 
 | From: David Holland <dholland-bugs@netbsd.org>
 | To: gnats-bugs@NetBSD.org
 | Cc: 
 | Subject: Re: PR/43105 CVS commit: src/sbin/gpt
 | Date: Mon, 25 Oct 2010 02:19:59 +0000
 | 
 |  On Fri, Apr 02, 2010 at 01:40:05PM +0000, Christos Zoulas wrote:
 |   > PR/43105: Peter Kerwien: Destroying a GPT partition with dd will
 |   > cause gpt destroy / create to fail. When reading the GPT label from
 |   > the end of the disk ignore errors if the GPT label at the beginning
 |   > of the disk was not found.
 |  
 |  Should this be pulled up to -5 (it won't make it into 5.1) or can this
 |  PR be closed?

 Not many people use gpt on 5, I suggest we close it. But it is really up to the
 submitter.

 christos

State-Changed-From-To: open->feedback
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Mon, 25 Oct 2010 03:40:56 +0000
State-Changed-Why:
ok, let's ask the submitter - do you need this in the 5.x branch (it won't
make it into 5.1) or is a fix in -current enough?


From: Peter Kerwien <peter@kerwien.homeip.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-amd64/43105 (Destroying a GPT partition with dd will cause
 gpt destroy / create to fail)
Date: Mon, 25 Oct 2010 05:58:19 +0200

 Fix in -current is enough for me. I can always use the erase-code I got
 from you (I hope I have saved the source code somewhere), if/when needed.

 /Peter

 On 10/25/2010 05:40 AM, dholland@NetBSD.org wrote:
 > Synopsis: Destroying a GPT partition with dd will cause gpt destroy / create to fail
 >
 > State-Changed-From-To: open->feedback
 > State-Changed-By: dholland@NetBSD.org
 > State-Changed-When: Mon, 25 Oct 2010 03:40:56 +0000
 > State-Changed-Why:
 > ok, let's ask the submitter - do you need this in the 5.x branch (it won't
 > make it into 5.1) or is a fix in -current enough?
 >
 >
 >

From: matthew green <mrg@eterna.com.au>
To: gnats-bugs@NetBSD.org
Cc: port-amd64-maintainer@netbsd.org, netbsd-bugs@netbsd.org,
    gnats-admin@netbsd.org, dholland@NetBSD.org,
    peter@kerwien.homeip.net
Subject: re: port-amd64/43105 (Destroying a GPT partition with dd will cause gpt destroy / create to fail)
Date: Tue, 26 Oct 2010 04:52:42 +1100

 > Synopsis: Destroying a GPT partition with dd will cause gpt destroy / create to fail
 > 
 > State-Changed-From-To: open->feedback
 > State-Changed-By: dholland@NetBSD.org
 > State-Changed-When: Mon, 25 Oct 2010 03:40:56 +0000
 > State-Changed-Why:
 > ok, let's ask the submitter - do you need this in the 5.x branch (it won't
 > make it into 5.1) or is a fix in -current enough?

 i think it should get into -5 if possible.


 .mrg.

From: christos@zoulas.com (Christos Zoulas)
To: matthew green <mrg@eterna.com.au>, gnats-bugs@NetBSD.org
Cc: port-amd64-maintainer@netbsd.org, netbsd-bugs@netbsd.org, 
	gnats-admin@netbsd.org, dholland@NetBSD.org, peter@kerwien.homeip.net
Subject: re: port-amd64/43105 (Destroying a GPT partition with dd will cause gpt destroy / create to fail)
Date: Mon, 25 Oct 2010 14:55:25 -0400

 On Oct 26,  4:52am, mrg@eterna.com.au (matthew green) wrote:
 -- Subject: re: port-amd64/43105 (Destroying a GPT partition with dd will cau

 | 
 | > Synopsis: Destroying a GPT partition with dd will cause gpt destroy / create to fail
 | > 
 | > State-Changed-From-To: open->feedback
 | > State-Changed-By: dholland@NetBSD.org
 | > State-Changed-When: Mon, 25 Oct 2010 03:40:56 +0000
 | > State-Changed-Why:
 | > ok, let's ask the submitter - do you need this in the 5.x branch (it won't
 | > make it into 5.1) or is a fix in -current enough?
 | 
 | i think it should get into -5 if possible.

 Issued pullup.

 christos

From: matthew green <mrg@eterna.com.au>
To: christos@zoulas.com (Christos Zoulas)
Cc: port-amd64-maintainer@netbsd.org, netbsd-bugs@netbsd.org,
    gnats-admin@netbsd.org, dholland@NetBSD.org,
    peter@kerwien.homeip.net, gnats-bugs@NetBSD.org
Subject: re: port-amd64/43105 (Destroying a GPT partition with dd will cause gpt destroy / create to fail)
Date: Tue, 26 Oct 2010 07:56:51 +1100

 > | i think it should get into -5 if possible.
 > 
 > Issued pullup.

 thanks!

State-Changed-From-To: feedback->pending-pullups
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Tue, 26 Oct 2010 09:20:39 +0000
State-Changed-Why:
pullup-5 #1464


From: "Jeff Rizzo" <riz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/43105 CVS commit: [netbsd-5] src/sbin/gpt
Date: Sun, 21 Nov 2010 21:59:38 +0000

 Module Name:	src
 Committed By:	riz
 Date:		Sun Nov 21 21:59:38 UTC 2010

 Modified Files:
 	src/sbin/gpt [netbsd-5]: gpt.c

 Log Message:
 Pull up following revision(s) (requested by christos in ticket #1464):
 	sbin/gpt/gpt.c: revision 1.11
 PR/43105: Peter Kerwien: Destroying a GPT partition with dd will cause gpt
 destroy / create to fail. When reading the GPT label from the end of the disk
 ignore errors if the GPT label at the beginning of the disk was not found.


 To generate a diff of this commit:
 cvs rdiff -u -r1.8 -r1.8.6.1 src/sbin/gpt/gpt.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: pending-pullups->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Mon, 22 Nov 2010 04:44:57 +0000
State-Changed-Why:
pullup to -5 completed.


From: "Jeff Rizzo" <riz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/43105 CVS commit: [netbsd-5] src/sbin/gpt
Date: Wed, 24 Nov 2010 19:12:45 +0000

 Module Name:	src
 Committed By:	riz
 Date:		Wed Nov 24 19:12:44 UTC 2010

 Modified Files:
 	src/sbin/gpt [netbsd-5]: gpt.c

 Log Message:
 Pull up following revision(s) (requested by christos in ticket #1464):
 	sbin/gpt/gpt.c: revision 1.11
 	sbin/gpt/gpt.c: revision 1.12
 PR/43105: Peter Kerwien: Destroying a GPT partition with dd will cause gpt
 destroy / create to fail. When reading the GPT label from the end of the disk
 ignore errors if the GPT label at the beginning of the disk was not found.
 fix printf format.


 To generate a diff of this commit:
 cvs rdiff -u -r1.8.6.1 -r1.8.6.2 src/sbin/gpt/gpt.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.