From dan_strick@sbcglobal.net  Tue Feb 26 17:30:25 2008
Return-Path: <dan_strick@sbcglobal.net>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 7478B1065676
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 26 Feb 2008 17:30:25 +0000 (UTC)
	(envelope-from dan_strick@sbcglobal.net)
Received: from smtp118.sbc.mail.sp1.yahoo.com (smtp118.sbc.mail.sp1.yahoo.com [69.147.64.91])
	by mx1.freebsd.org (Postfix) with SMTP id 705AE13C4D1
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 26 Feb 2008 17:30:25 +0000 (UTC)
	(envelope-from dan_strick@sbcglobal.net)
Received: (qmail 25635 invoked from network); 26 Feb 2008 17:03:45 -0000
Received: from unknown (HELO mist.nodomain) (dan_strick@sbcglobal.net@69.228.211.117 with login)
  by smtp118.sbc.mail.sp1.yahoo.com with SMTP; 26 Feb 2008 17:03:45 -0000
Received: from mist.nodomain (localhost [127.0.0.1])
	by mist.nodomain (8.14.2/8.14.2) with ESMTP id m1QH3faX001356
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 26 Feb 2008 09:03:41 -0800 (PST)
	(envelope-from dan@mist.nodomain)
Received: (from dan@localhost)
	by mist.nodomain (8.14.2/8.14.2/Submit) id m1QH3fha001355;
	Tue, 26 Feb 2008 09:03:41 -0800 (PST)
	(envelope-from dan)
Message-Id: <200802261703.m1QH3fha001355@mist.nodomain>
Date: Tue, 26 Feb 2008 09:03:41 -0800 (PST)
From: Dan Strick <dan_strick@sbcglobal.net>
Reply-To: Dan Strick <dan_strick@sbcglobal.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: FreeBSD 6.3 installation deletes MBR partition
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         121124
>Category:       bin
>Synopsis:       sysinstall(8): FreeBSD 6.3 installation deletes MBR partition
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-sysinstall
>State:          analyzed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb 26 17:40:00 UTC 2008
>Closed-Date:    
>Last-Modified:  Sun Jan 23 21:01:46 UTC 2011
>Originator:     Dan Strick
>Release:        FreeBSD 6.3-RELEASE i386
>Organization:
none
>Environment:
System: FreeBSD mist.nodomain 6.3-RELEASE FreeBSD 6.3-RELEASE #0: Sun Feb 24 23:23:03 PST 2008 root@mist.nodomain:/usr/src/sys/i386/compile/MIST i386
>Description:
This was the MBR partition table for disk ad0 before I booted the
release 6.3 installation cd disk 1:

        The data for partition 1 is:
        sysid 11 (0x0b),(DOS or Windows 95 with 32 bit FAT)
            start 63, size 8209152 (4008 Meg), flag 0
                beg: cyl 0/ head 1/ sector 1;
                end: cyl 510/ head 254/ sector 63
        The data for partition 2 is:
        sysid 99 (0x63),(System V/386 (such as ISC UNIX), GNU HURD or Mach)
            start 8209214, size 1 (0 Meg), flag 0
                beg: cyl 510/ head 254/ sector 63;
                end: cyl 510/ head 254/ sector 63
        The data for partition 3 is:
        sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
            start 8209215, size 8225280 (4016 Meg), flag 80 (active)
                beg: cyl 511/ head 0/ sector 1;
                end: cyl 1022/ head 254/ sector 63
        The data for partition 4 is:
        sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
            start 16434495, size 143637165 (70135 Meg), flag 0
                beg: cyl 1023/ head 0/ sector 1;
                end: cyl 1023/ head 254/ sector 63

When I selected disk ad0 under the sysinstall partition menu it popped up
this warning message:

			Disk slicing warning:
	chunk 'ad0s2' [8209214..8209214] does not start on a track boundary

and showed this information when it entered the FDISK partition editor:

  Disk name:      ad0                                    FDISK Partition Editor
  DISK Geometry:  9964 cyls/255 heads/63 sectors = 160071660 sectors (78159MB)

  Offset       Size(ST)        End     Name  PType       Desc  Subtype    Flags

           0    8209214    8209213        -     12     unused        0          
     8209214          1    8209214    ad0s2      4    unknown       99
     8209215    8225280   16434494    ad0s3      8    freebsd      165
    16434495  143637165  160071659    ad0s4      8    freebsd      165
   160071660      12755  160084414        -     12     unused        0

I exited the partition editor without changing any partitions but I did
request installation of the usual FreeBSD boot manager (menu option BootMgr)
in the next menu.

After the installation was over I discovered that the first partition,
Windows XP, was now <UNUSED>.  The other partitions were unmodified.

>How-To-Repeat:

	Create a similar MBR partition table on some disk, run sysinstall
	and select that disk under the

		3 Partition      Allocate disk space for FreeBSD

	menu item in the "Choose Custom Installation Options" menu.
	This also works if you run sysinstall from inside FreeBSD.

>Fix:

	Work around:  manually edit the MBR partition table with fdisk
	from FreeBSD after the installation is complete.  Of course we
	saved a backup copy of the MBR before we began the FreeBSD
	installion.  Doesn't everybody?  :-)

	I used to think that only MS Windows installations callously
	destroyed competing OS partions.  Now FreeBSD joins the club.
	:-)
>Release-Note:
>Audit-Trail:

From: Volker <volker@vwsoft.com>
To: bug-followup@FreeBSD.org, dan_strick@sbcglobal.net
Cc:  
Subject: Re: i386/121124: FreeBSD 6.3 installation deletes MBR partition
Date: Thu, 28 Feb 2008 22:22:15 +0100

 Dan,
 
 unfortunately your partition table seems to be seriously broken if the
 information you've posted is correct.
 
 slice 1 starts at 63, has a size of 8209152
 slice 2 starts at 8209214, size 1
 slice 3 starts at 8209215, size 8225280
 slice 4 starts at 16434495, size 143637165
 
 If you're manually calculating the start sectors, you'll see there's an
 overlap, which is deadly while installing an OS.
 
 Your partition table should look similar like:
 slice 1 start at 63, size 8209152
 slice 2 start at 8209215, size 1
 slice 3 start at 8209216, size 8225280
 slice 4 start at 16434496
 
 That could have been the reason why the partition editor gave you a warning.
 
 I'm wondering if the maintainers can see if there's chance to complain
 clearly about a broken partition table before writing a new mbr?
 
 But I suggest to backup all your data, repartition your disk and install
 everything.
State-Changed-From-To: open->analyzed 
State-Changed-By: linimon 
State-Changed-When: Thu Feb 28 21:42:44 UTC 2008 
State-Changed-Why:  
It sounds as though the problem is a lack of error-checking robustness. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=121124 

From: Dan Strick <dan_strick@sbcglobal.net>
To: volker@vwsoft.com
Cc: bug-followup@FreeBSD.org, dan@mist.nodomain
Subject: Re: i386/121124: FreeBSD 6.3 installation deletes MBR partition
Date: Thu, 28 Feb 2008 17:42:26 -0800 (PST)

 > From volker@vwsoft.com Thu Feb 28 16:58:12 2008
 > To: bug-followup@FreeBSD.org, dan_strick@sbcglobal.net
 > Subject: Re: i386/121124: FreeBSD 6.3 installation deletes MBR partition
 >
 > Dan,
 >
 > unfortunately your partition table seems to be seriously broken if the
 > information you've posted is correct.
 >
 > slice 1 starts at 63, has a size of 8209152
 > slice 2 starts at 8209214, size 1
 > slice 3 starts at 8209215, size 8225280
 > slice 4 starts at 16434495, size 143637165
 >
 > If you're manually calculating the start sectors, you'll see there's an
 > overlap, which is deadly while installing an OS.
 >
 > Your partition table should look similar like:
 > slice 1 start at 63, size 8209152
 > slice 2 start at 8209215, size 1
 > slice 3 start at 8209216, size 8225280
 > slice 4 start at 16434496
 >
 > That could have been the reason why the partition editor gave you a warning.
 >
 > I'm wondering if the maintainers can see if there's chance to complain
 > clearly about a broken partition table before writing a new mbr?
 >
 > But I suggest to backup all your data, repartition your disk and install
 > everything.
 >
 
 Slice 2 is a dummy partition created for historical reasons.  Once upon
 a time there was a real slice 2.  I needed more space in slices 1 and 3
 so I reassigned the first half of slice 2 to slice 1 and the second half
 of slice 2 to slice 3.  I made slice 2 unused (partition table entry all
 zeros).  Then I reinstalled windows XP in slice 1.  Windows XP renumbered
 the slices, moving the unused slice to the end of the partition table.
 My bootable FreeBSD slice became slice 2 and of course would not boot
 that way and if it could have booted, it would not be able to find the
 important file systems that had been in slice 4 and were now in slice 3.
 So I booted the FreeBSD installation disk and fixed the partition table,
 this time defining a non-empty partition in slice 2.  There is nothing
 wrong with having slice 2 overlap slice one as long as you don't actually
 use slice 2.
 
 My best guess is that sysinstall checked the MBR partition table for
 sanity and decided to "fix" the overlap by arbitrarily deleting one of
 the overlapping partitions.  That was the wrong thing to do since none
 of the overlapping partitions was involved in the FreeBSD installation.
 What other operating systems do with their slices is their business.
 Generating a warning message was plausible.  Making gratuitous changes
 to the partition table was not.
 
 I believe it is common sense for an MBR partition table editor to change
 only those partitions that it is explicitly told to modify.  Sysinstall
 was not told to modify either of the overlapping slices and should have
 left them strictly alone.
 
 Dan Strick

From: linimon@lonesome.com (Mark Linimon)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: i386/121124: FreeBSD 6.3 installation deletes MBR partition
Date: Thu, 28 Feb 2008 20:26:23 -0600

 ----- Forwarded message from Dan Strick <dan_strick@sbcglobal.net> -----
 
 My best guess is that sysinstall checked the MBR partition table for
 sanity and decided to "fix" an overlap by arbitrarily deleting one of
 the overlapping partitions.  That was the wrong thing to do since none
 of the overlapping partitions was involved in the FreeBSD installation.
 What other operating systems do with their slices is their business.
 Generating a warning message was plausible.  Making gratuitous changes
 to the partition table was not.
 
 I believe it is common sense for an MBR partition table editor to change
 only those partitions that it is explicitly told to modify.  Sysinstall
 was not told to modify either of the overlapping slices and should have
 left them strictly alone.
 
 Dan Strick
 
 ----- End forwarded message -----
Responsible-Changed-From-To: freebsd-i386->freebsd-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Mon Mar 3 06:28:35 UTC 2008 
Responsible-Changed-Why:  
This does not sound i386-specific. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=121124 
Responsible-Changed-From-To: freebsd-bugs->brucec  
Responsible-Changed-By: brucec 
Responsible-Changed-When: Sat Mar 13 11:55:49 UTC 2010 
Responsible-Changed-Why:  
Take. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=121124 
Responsible-Changed-From-To: brucec->freebsd-sysinstall 
Responsible-Changed-By: brucec 
Responsible-Changed-When: Sun Jan 23 21:01:27 UTC 2011 
Responsible-Changed-Why:  
Back to the pool. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=121124 
>Unformatted:
