Subject: Re: newfs trashes MBR/disklabel?
To: Dieter <netbsd@sopwith.solgatos.com>
From: David Laight <david@l8s.co.uk>
List: port-amd64
Date: 08/28/2005 09:53:10
On Sat, Aug 27, 2005 at 07:02:01PM +0100, Dieter wrote:
> This is my first system that uses a "MBR" type partition table
> plus BSD disklabel rather than just a BSD disklabel.  Most likely
> I have made some MBR newbie error.
> 
> Install says:
> 
> We now have your BSD-disklabel partitions as:
>  This is your last chance to change them.
> 
>     Start sec   End sec  Size sec FS type    Newfs Mount Mount point
>     --------- --------- --------- ---------- ----- ----- -----------
>  a:        63    204862    204800 FFSv1            Yes   /

You will wish you made root bigger than that at some point....
If you intended this to be a partition for the kernel, this isn't
necessary - the netbsd mbr bootselect code can boot directly from
one of the extended partitions.

>  b: 477911408 488397167  10485760 swap
>  c:        63    204862    204800 NetBSD partition

It is more usual to make the NetBSD mbr partition be split into all
of the NetBSD partitions by the disklabel, rather than defining a lot
of mbr partitions.

>  d:         0 488397167 488397168 Whole disk
>  e:    204863  10690622  10485760 FFSv1            Yes
>  f:  10690623 344562094 333871472 Linux Ext2
>  g: 344562095 348756398   4194304 Linux Ext2
>  h: 363436463 363641262    204800 FFSv1            Yes
>  i: 363641263 367835566   4194304 FFSv1            Yes   /usr
>  j: 367835567 378321326  10485760 FFSv1            Yes   /var
> >k: 378321327 382515630   4194304 FFSv1            Yes   /home
>  l: 382515631 386709934   4194304 FFSv1            Yes
>  m: 386709935 397195694  10485760 FFSv1            Yes
>  n: 397195695 398219694   1024000 FFSv1            Yes
>  o: 398219695 414996910  16777216 FFSv1            Yes
>  p: 414996911 477911407  62914497 FFSv1            Yes
>  q: Change input units (sectors/cylinders/MB)
>  x: Partition sizes ok
> 
> There are (were?) two more Linux partitions between g & h in the
> MBR version, but disklabel would not allow more than 16 partitions
> and c & d get wasted.
> 
> It seemed happy with this.

It believed you....

> Then it said that fsck failed

sysinst will either run newfs or fsck

> so I went back to the shell and ran newfs on a, i, j, & k by hand.
> 
> Now it is unhappy.

Not surprising really.
The partition bases in the netbsd disklabel don't match the bases in the
mbr extended partition list.  So when you ran newfs you overwrote some
of the red tape that lets fdisk (and everything else) find the latter
extended partitions.

NetBSD itself won't care whether partitions wd1h to wd1p are allocated
to an mbr partition or not - it will just use the disk space anyway.

I suspect you failed to realise that each 'extended partition' is layed
out a little like an entire disk.  So there is a gap (usually one track,
63 sectors) between the start of the extended partition itself, and where
the data partition it contains starts.  The fdisk output you included
shows this (fdisk -vvv wd1 will give this output)

	David

> # fdisk wd1
> fdisk: extended partition table invalid, no magic in sector 363641515
> fdisk: Extended partition table is corrupt
> 
> Disk: /dev/rwd1d
> NetBSD disklabel disk geometry:
> cylinders: 484521, heads: 16, sectors/track: 63 (1008 sectors/cylinder)
> total sectors: 488397168
> 
> BIOS disk geometry:
> cylinders: 1023, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
> total sectors: 488397168
> 
> Partition table:
> 0: NetBSD (sysid 169)
>     bootmenu: netbsd
>     start 63, size 204800 (100 MB, Cyls 0-12/191/51), Active
> 1: Linux native (sysid 131)
>     bootmenu: spare
>     start 204863, size 10485760 (5120 MB, Cyls 12/191/51-665/117/28)
> 2: Linux native (sysid 131)
>     bootmenu: big
>     start 10690623, size 333871472 (163023 MB, Cyls 665/117/28-21447/254/39)
> 3: Ext. partition - LBA (sysid 15)
>     start 344562095, size 143835073 (70232 MB, Cyls 21447/254/39-30401/81/1)
>     Extended partition table:
>     0: Linux native (sysid 131)
>         bootmenu: linuxusr
>         start 344562158, size 4194304 (2048 MB, Cyls 21447/254/39-21709/21/55)
>     1: Extended partition (sysid 5)
>         start 348756462, size 10485823 (5120 MB, Cyls 21709/21/55-22361/203/32)
>         Extended partition table:
>         0: Linux native (sysid 131)
>             bootmenu: linuxvar
>             start 348756525, size 10485760 (5120 MB, Cyls 21709/21/55-22361/203/32)
>         1: Extended partition (sysid 5)
>             start 359242285, size 4194367 (2048 MB, Cyls 22361/203/32-22622/225/48)
>             Extended partition table:
>             0: Linux native (sysid 131)
>                 bootmenu: lin home
>                 start 359242348, size 4194304 (2048 MB, Cyls 22361/203/32-22622/225/48)
>             1: Extended partition (sysid 5)
>                 start 363436652, size 204863 (100 MB, Cyls 22622/225/48-22635/162/35)
>                 Extended partition table:
>                 0: NetBSD (sysid 169)
>                     bootmenu: bsd root
>                     start 363436715, size 204800 (100 MB, Cyls 22622/225/48-22635/162/35)
>                 1: Extended partition (sysid 5)
>                     start 363641515, size 4194367 (2048 MB, Cyls 22635/162/35-22896/184/51)
>                     Extended partition table:
> fdisk: extended partition table invalid, no magic in sector 363641515
>                 2: <UNUSED>
>                 3: <UNUSED>
>             2: <UNUSED>
>             3: <UNUSED>
>         2: <UNUSED>
>         3: <UNUSED>
>     2: <UNUSED>
>     3: <UNUSED>
> Extended partition table is corrupt
> Bootselector disabled.
> # 
> 
> What did I do wrong?

-- 
David Laight: david@l8s.co.uk