Bug 121124 - sysinstall(8): FreeBSD 6.3 installation deletes MBR partition
Summary: sysinstall(8): FreeBSD 6.3 installation deletes MBR partition
Status: Closed Overcome By Events
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 6.3-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-sysinstall (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-26 17:40 UTC by Dan Strick
Modified: 2015-11-10 09:12 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Strick 2008-02-26 17:40:00 UTC
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.

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.
	:-)
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.
Comment 1 Volker 2008-02-28 21:22:15 UTC
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.
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2008-02-28 21:42:44 UTC
State Changed
From-To: open->analyzed

It sounds as though the problem is a lack of error-checking robustness.
Comment 3 Dan Strick 2008-02-29 01:42:26 UTC
> 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
Comment 4 Mark Linimon 2008-02-29 02:26:23 UTC
----- 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 -----
Comment 5 Mark Linimon freebsd_committer freebsd_triage 2008-03-03 06:28:35 UTC
Responsible Changed
From-To: freebsd-i386->freebsd-bugs

This does not sound i386-specific.
Comment 6 Bruce Cran freebsd_committer freebsd_triage 2010-03-13 11:55:49 UTC
Responsible Changed
From-To: freebsd-bugs->brucec

Take.
Comment 7 Bruce Cran freebsd_committer freebsd_triage 2011-01-23 21:01:27 UTC
Responsible Changed
From-To: brucec->freebsd-sysinstall

Back to the pool.
Comment 8 Enji Cooper freebsd_committer freebsd_triage 2015-11-10 09:08:15 UTC
sysinstall has been replaced by bsdinstall in FreeBSD 9.x. Closing.
Comment 9 Enji Cooper freebsd_committer freebsd_triage 2015-11-10 09:12:27 UTC
sysinstall has been replaced by bsdinstall in FreeBSD 9.x. Closing.