hi there,

this is for the dying breed of fdisk gurus...
prepare some snacks, it's long.

i am about to install openbsd -current (feb 28) on a notebook
with a 320G hard drive in IDE mode, although it is AHCI really.
bsd.rd dmesg at the end.

my goal is to have the 2 ntfs partitions followed by a 32G
openbsd one and then the last partition will be an ext2.

i spent some quality reading time in the man page, and first
of all let me confess, that i think that the i386 fdisk man
page section sporting the title "TYPICAL LAYOUT" is more like
a page out from the history books...  i claim to be no fdisk
jockey but i have seen a couple in my time, and i say, that
even if we ignore the now exotic geometry (as most drives now
identify always with an n/255/63 geometry), this particular MBR
violates the CAVEATS section of the man page on two counts:

1. the ending boundary of the 0th partition does not "end at
        cylinder boundaries."
2. the openbsd partition does not "start on a cylinder boundary
        (head 0, sector 1), except when starting on track 0,
        (these should begin at head 1, sector 1)."

both these are cited as necessary for i386 machines...
as a quick refresher, here is the offending part:

      # fdisk wd0
      Disk: wd0       geometry: 5168/240/63 [78140160 Sectors]
      Offset: 0       Signature: 0xAA55
                Starting      Ending        LBA Info:
       #: id    C   H  S -    C   H  S [       start:      size   ]
      -------------------------------------------------------------------------
       0: 04    0   1  1 -  170   0 63 [          63:     2570462 ] DOS FAT-16
       1: 00    0   0  0 -    0   0  0 [           0:           0 ] unused
       2: 00    0   0  0 -    0   0  0 [           0:           0 ] unused
      *3: A6  170   1  1 - 5167 239 63 [     2570525:    75569697 ] OpenBSD

i am _not_ stating, that this example is a made up fantasy,
contrarywise, probably it has been copied from a live working
operating system.  i am merely pointing out, that it is far
from "typical" and more confusing than helping, and i make no
secret of that i'd like to see it being replaced with something
fresher and/or more relevant (or "typical")... (the faq has both
in section 4 and 14 newer layouts)


now on to my problems...
here is the fdisk session during the install with my comments.

Disk: wd0       geometry: 38913/255/63 [625142448 Sectors]
Offset: 0       Signature: 0xAA55
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
*0: 07      0   1   1 -   8354 254  63 [          63:   134223012 ] HPFS/QNX/AUX
 1: 07   8355   0   1 -  25063 254  63 [   134223075:   268430085 ] HPFS/QNX/AUX
 2: 00      0   0   0 -      0   0   0 [           0:           0 ] unused      
 3: 00      0   0   0 -      0   0   0 [           0:           0 ] unused      
Enter 'help' for information
fdisk: 1> e 2
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
 2: 00      0   0   0 -      0   0   0 [           0:           0 ] unused      
Partition id ('0' to disable)  [0 - FF]: [0] (? for help) a6
Do you wish to edit in CHS mode? [n]
offset: [0]
size: [0]
fdisk:*1> p
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
*0: 07      0   1   1 -   8354 254  63 [          63:   134223012 ] HPFS/QNX/AUX
 1: 07   8355   0   1 -  25063 254  63 [   134223075:   268430085 ] HPFS/QNX/AUX
 2: 00      0   0   1 - 267349  89   4 [           0:           0 ] OpenBSD     
 3: 00      0   0   0 -      0   0   0 [           0:           0 ] unused      
fdisk:*1>

let's go line by line.  i said i want to edit partition 2, and defined
its type as a6, openbsd.  then fdisk goes into lba editing mode and
offers me offset 0.  this is one of those moments where i dont know
if this is fdisk's expected behaviour, or a bug.  would it not make
sense if it offered me the first available lba sector with partition
type 0?  i mean even if it doesnt want to offer any "responsible"
value, 0 is wrong in any case on i386, as the first offset has to be
at least 63...

i got curious and wanted to see where this leads, so i hit enter.
fdisk then offered size 0, and again, i dont know if this is normal
fdisk behaviour, but it would maybe make sense if it offered the last
free lba sector (starting from offset) or up to the end of the disk,
if that being the case.  in any case, even if the offered size was
0, the result is obviously wrong, both the starting and ending C/H/S
values are bogus, although the lba size value is correct.

let's stop for a moment at the number in the prompt: 1.  the man page
says about the number in the prompt (0 being the particular example):

     0 is the disk offset of the currently selected boot block being edited.
     This number could be something other than zero when extended MBR parti-
     tions are being edited (using the select subcommand).

no matter how many times i read this, i dont get it.  offset of what disk?
and in my case it's "other than zero" but i am not working with extended
MBR partitions at all.

so next i did the same, but opted for CHS mode:
BIOS Starting cylinder [0 - 38912]: [0] 25064
BIOS Starting head [0 - 254]: [0]
BIOS Starting sector [0 - 63]: [0] 1
BIOS Ending cylinder [0 - 38912]: [267349] 38912
BIOS Ending head [0 - 254]: [89] 254
BIOS Ending sector [0 - 63]: [4] 63
fdisk:*1> p
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
*0: 07      0   1   1 -   8354 254  63 [          63:   134223012 ] HPFS/QNX/AUX
 1: 07   8355   0   1 -  25063 254  63 [   134223075:   268430085 ] HPFS/QNX/AUX
 2: A6  25064   0   1 -  38912 254  63 [   402653160:   222484185 ] OpenBSD     
 3: 00      0   0   0 -      0   0   0 [           0:           0 ] unused      
fdisk:*1>

for the sake of simplicity i entered the whole remaining disk.

here, i would like to point out, that again, according to the CAVEATS
section in the man page, 0 as a default value makes no sense on i386
for the BIOS starting sector of any partition.  1 does.

now let's suppose i wanted to change the size of the partition to 32G:
fdisk:*1> e 2
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
 2: A6  25064   0   1 -  38912 254  63 [   402653160:   222484185 ] OpenBSD     
Partition id ('0' to disable)  [0 - FF]: [A6] (? for help)
Do you wish to edit in CHS mode? [n]
offset: [402653160]
size: [222484185] 32G
fdisk:*1> p m
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
*0: 07      0   1   1 -   8354 254  63 [          63:      65539M ] HPFS/QNX/AUX
 1: 07   8355   0   1 -  25063 254  63 [   134223075:     131069M ] HPFS/QNX/AUX
 2: A6  25064   0   1 -  29241  85   4 [   402653160:      32768M ] OpenBSD     
 3: 00      0   0   0 -      0   0   0 [           0:           0 ] unused      

please note the ending CHS for the openbsd partition. nothing
good can come out of these values...  why did not fdisk round
up these values up to the nearest cylinder boundary?

maybe i am expecting something from fdisk that is "not inside the
openbsd philosophy", i don't know.  now, faq 14 is quick to point
out that:

        Unlike the fdisk-like programs on some other operating systems,
        OpenBSD's fdisk assumes you know what you want to do, and for the most
        part, it will let you do what you need to do, making it a powerful tool
        to have on hand. It will also let you do things you shouldn't or didn't
        intend to do, so it must be used with care.

perhaps it is expected that the person doing the editing will enter
the correct values at every prompt.  but even if that is the case,
i still think offering values way out of range is a bug and should
be dealt with.  but i believe fdisk can be made better (i'd dare say
more openbsd like), it doesn't have to be "just" the raw byte editor
of the first 512 bytes of the disk or a tool capable of giving
intelligent, dependable results only if openbsd is used for the
whole disk...

any thoughts on these issues?

-f

OpenBSD 4.5 (RAMDISK_CD) #1112: Sat Feb 28 15:06:26 MST 2009
    dera...@i386.openbsd.org:/usr/src/sys/arch/i386/compile/RAMDISK_CD
cpu0: AMD Turion(tm) X2 Ultra Dual-Core Mobile ZM-80 ("AuthenticAMD" 686-class, 
1024KB L2 cache) 2.11 GHz
cpu0: 
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,CX16
real mem  = 3217108992 (3068MB)
avail mem = 3118845952 (2974MB)
mainbus0 at root
bios0 at mainbus0: AT/286+ BIOS, date 02/08/08, SMBIOS rev. 2.4 @ 0xbfb51018 
(53 entries)
bios0: vendor American Megatrends Inc. version "E1652NMS VER.106" date 
12/26/2008
bios0: Micro-Star International GX-630
acpi0 at bios0: rev 2
acpi0: tables DSDT FACP APIC SSDT MCFG SLIC
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: apic clock running at 200MHz
cpu at mainbus0: not configured
ioapic0 at mainbus0: apid 0 pa 0xfec00000, version 11, 24 pins
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 3 (BR12)
acpiprt2 at acpi0: bus 4 (BR13)
acpiprt3 at acpi0: bus 5 (BR14)
acpiprt4 at acpi0: bus 8 (BR16)
bios0: ROM list: 0xc0000/0xe200 0xce800/0x1800
pci0 at mainbus0 bus 0: configuration mode 1 (bios)
"NVIDIA MCP77 Memory" rev 0xa2 at pci0 dev 0 function 0 not configured
pcib0 at pci0 dev 1 function 0 vendor "NVIDIA", unknown product 0x075e rev 0xa2
"NVIDIA MCP77 SMBus" rev 0xa1 at pci0 dev 1 function 1 not configured
"NVIDIA MCP77 Co-processor" rev 0xa2 at pci0 dev 1 function 3 not configured
"NVIDIA MCP77 Memory" rev 0xa1 at pci0 dev 1 function 4 not configured
ohci0 at pci0 dev 2 function 0 "NVIDIA MCP77 USB" rev 0xa1: apic 0 int 7 (irq 
7), version 1.0, legacy support
ehci0 at pci0 dev 2 function 1 "NVIDIA MCP77 USB" rev 0xa1: apic 0 int 11 (irq 
11)
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 "NVIDIA EHCI root hub" rev 2.00/1.00 addr 1
ohci1 at pci0 dev 4 function 0 "NVIDIA MCP77 USB" rev 0xa1: apic 0 int 5 (irq 
5), version 1.0, legacy support
ehci1 at pci0 dev 4 function 1 "NVIDIA MCP77 USB" rev 0xa1: apic 0 int 7 (irq 7)
usb1 at ehci1: USB revision 2.0
uhub1 at usb1 "NVIDIA EHCI root hub" rev 2.00/1.00 addr 1
pciide0 at pci0 dev 6 function 0 "NVIDIA MCP77 IDE" rev 0xa1: DMA, channel 0 
configured to compatibility, channel 1 configured to compatibility
pciide0: channel 0 ignored (disabled)
pciide0: channel 1 ignored (disabled)
"NVIDIA MCP77 HD Audio" rev 0xa1 at pci0 dev 7 function 0 not configured
ppb0 at pci0 dev 8 function 0 "NVIDIA MCP77 PCI" rev 0xa1
pci1 at ppb0 bus 1
pciide1 at pci0 dev 9 function 0 "NVIDIA MCP77 AHCI" rev 0xa2: DMA 
(unsupported), channel 0 wired to native-PCI, channel 1 wired to native-PCI
pciide1: using apic 0 int 10 (irq 10) for native-PCI interrupt
wd0 at pciide1 channel 0 drive 0: <FUJITSU MHZ2320BH G2>
wd0: 16-sector PIO, LBA48, 305245MB, 625142448 sectors
atapiscsi0 at pciide1 channel 0 drive 1
scsibus0 at atapiscsi0: 2 targets
cd0 at scsibus0 targ 0 lun 0: <Optiarc, DVD RW AD-7560S, SX01> ATAPI 5/cdrom 
removable
pciide1: channel 1 ignored (not responding; disabled or no drives?)
nfe0 at pci0 dev 10 function 0 "NVIDIA MCP77 LAN" rev 0xa2: apic 0 int 5 (irq 
5), address 00:21:85:55:af:d3
eephy0 at nfe0 phy 1: 88E1116 Gigabit PHY, rev. 1
ppb1 at pci0 dev 16 function 0 "NVIDIA MCP77 PCIE" rev 0xa1: apic 0 int 7 (irq 
7)
pci2 at ppb1 bus 2
vga1 at pci2 dev 0 function 0 vendor "NVIDIA", unknown product 0x0649 rev 0xa1
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
ppb2 at pci0 dev 18 function 0 "NVIDIA MCP77 PCIE" rev 0xa1: apic 0 int 11 (irq 
11)
pci3 at ppb2 bus 3
ral0 at pci3 dev 0 function 0 "Ralink RT2790" rev 0x00: apic 0 int 11 (irq 11), 
address 00:21:85:b3:c4:ec
ral0: MAC/BBP RT2872 (rev 0x0200), RF RT2720 (MIMO 1T2R)
ppb3 at pci0 dev 19 function 0 "NVIDIA MCP77 PCI" rev 0xa1: apic 0 int 5 (irq 5)
pci4 at ppb3 bus 4
ppb4 at pci0 dev 20 function 0 "NVIDIA MCP77 PCI" rev 0xa1: apic 0 int 7 (irq 7)
pci5 at ppb4 bus 5
ppb5 at pci0 dev 22 function 0 "NVIDIA MCP77 PCI" rev 0xa1: apic 0 int 11 (irq 
11)
pci6 at ppb5 bus 8
vendor "JMicron", unknown product 0x2380 (class serial bus subclass Firewire, 
rev 0x00) at pci6 dev 0 function 0 not configured
"JMicron SD/MMC" rev 0x00 at pci6 dev 0 function 1 not configured
"JMicron SD Host Controller" rev 0x00 at pci6 dev 0 function 2 not configured
"JMicron Memory Stick" rev 0x00 at pci6 dev 0 function 3 not configured
"JMicron xD" rev 0x00 at pci6 dev 0 function 4 not configured
pchb0 at pci0 dev 24 function 0 "AMD AMD64 11h HyperTransport" rev 0x40
pci7 at pchb0 bus 128
pchb1 at pci0 dev 24 function 1 "AMD AMD64 11h Address Map" rev 0x00
pchb2 at pci0 dev 24 function 2 "AMD AMD64 11h DRAM Cfg" rev 0x00
pchb3 at pci0 dev 24 function 3 "AMD AMD64 11h Misc Cfg" rev 0x00
pchb4 at pci0 dev 24 function 4 "AMD AMD64 11h Link Cfg" rev 0x00
isa0 at pcib0
isadma0 at isa0
pckbc0 at isa0 port 0x60/5
pckbd0 at pckbc0 (kbd slot)
pckbc0: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard, using wsdisplay0
npx0 at isa0 port 0xf0/16: reported by CPUID; using exception 16
usb2 at ohci0: USB revision 1.0
uhub2 at usb2 "NVIDIA OHCI root hub" rev 1.00/1.00 addr 1
usb3 at ohci1: USB revision 1.0
uhub3 at usb3 "NVIDIA OHCI root hub" rev 1.00/1.00 addr 1
rd0: fixed, 3800 blocks
"Chicony Electronics Co., Ltd. CNF7231" rev 2.00/12.08 addr 2 at uhub0 port 3 
not configured
uhidev0 at uhub2 port 2 configuration 1 interface 0 "Areson Gaming II" rev 
2.00/10.00 addr 2
uhidev0: iclass 3/1
uhid at uhidev0 not configured
uhidev1 at uhub2 port 2 configuration 1 interface 1 "Areson Gaming II" rev 
2.00/10.00 addr 2
uhidev1: iclass 3/0, 4 report ids
uhid at uhidev1 reportid 1 not configured
uhid at uhidev1 reportid 2 not configured
ukbd0 at uhidev1 reportid 3
ukbd0: attach failed, too many key codes
uhid at uhidev1 reportid 4 not configured
"vendor 0x0db0 product 0xa97a" rev 2.00/31.64 addr 2 at uhub3 port 4 not 
configured
softraid0 at root
root on rd0a swap on rd0b dump on rd0b
-- 
a nuclear war can ruin your whole day.

Reply via email to