Bug 23380

Summary: newfs_msdos breaks the DOS partition table (and BSD label sector)
Product: Base System Reporter: didier.poirot <didier.poirot>
Component: i386Assignee: rnordier
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description didier.poirot 2000-12-08 16:00:04 UTC
Installing a MSDOS filesystem with the newfs_msdos(1) utility in the
first partition of the first slice (e.g /dev/ad0s1a) of a disk breaks 
the DOS partition table contained in the sector 0 of the disk (the MBR). 

Note: the partition 'a' must start at the beginning of the slice, e.g
the oa# field of the disktab entry must be set to 0.

The newfs_msdos utility writes to 'absolute' sector 0 of the disk, 
instead of writing to 'relative' sector 0 (relative to beginning of the
slice, not of the disk). It also tries to write to 'absolute' sector
1 (which contain the BSD label), must access is denied by the system.

Fix: 

The disktab entry used must not start at offset 0 in the slice, but say
at 16.
How-To-Repeat: 1. Using fdisk(1) create 1 slice( e.g ad0s1), starting at 0, type 165
2. Using disklabel, write a label to the disk slice mentionned above.
   This label should contain a partition starting at 0.
3. Use newfs_msdos on this partition (e.g /dev/ad0s1a).
4. Try to re-read the DOS partition table with fdisk.
Comment 1 rnordier freebsd_committer freebsd_triage 2000-12-08 18:40:44 UTC
Responsible Changed
From-To: freebsd-bugs->rnordier

newfs_msdos is mine.
Comment 2 rnordier 2000-12-08 19:04:44 UTC
didier.poirot@sun.com wrote:
 
> >Number:         23380
> >Category:       i386
> >Synopsis:       newfs_msdos breaks the DOS partition table (and BSD label sector)
> >Confidential:   no
> >Severity:       serious
> >Priority:       medium
> >Responsible:    freebsd-bugs

> >Description:
> Installing a MSDOS filesystem with the newfs_msdos(1) utility in the
> first partition of the first slice (e.g /dev/ad0s1a) of a disk breaks 
> the DOS partition table contained in the sector 0 of the disk (the MBR). 
> 
> Note: the partition 'a' must start at the beginning of the slice, e.g
> the oa# field of the disktab entry must be set to 0.
> 
> The newfs_msdos utility writes to 'absolute' sector 0 of the disk, 
> instead of writing to 'relative' sector 0 (relative to beginning of the
> slice, not of the disk). It also tries to write to 'absolute' sector
> 1 (which contain the BSD label), must access is denied by the system.
> 
> 
> >How-To-Repeat:
> 1. Using fdisk(1) create 1 slice( e.g ad0s1), starting at 0, type 165
> 2. Using disklabel, write a label to the disk slice mentionned above.
>    This label should contain a partition starting at 0.
> 3. Use newfs_msdos on this partition (e.g /dev/ad0s1a).
> 4. Try to re-read the DOS partition table with fdisk.
> 
> >Fix:
> The disktab entry used must not start at offset 0 in the slice, but say
> at 16.

The problems you are experiencing appear to be due to pilot error.

You should not create a DOS filesystem inside a BSD partition.  Most
typically, you would create one or more slices on your hard drive
(using fdisk or sysinstall) and then (without using disklabel) create
a DOS filesystem on one of the slices, for instance on /dev/ad0s1.

Your slices should also not begin at sector 0 of the disk.  Typically, 
they would begin at sector 63 on a modern IDE disk.

-- 
Robert Nordier

rnordier@nordier.com
rnordier@FreeBSD.org
Comment 3 rnordier freebsd_committer freebsd_triage 2000-12-08 19:15:51 UTC
State Changed
From-To: open->closed

The problem appears to be due to slice/partition layout rather 
than to newfs_msdos.