Subject: Strange behaviour of NetBSD partitions
To: port i386 <port-i386@netbsd.org>
From: Uwe Lienig <Uwe.Lienig@fif.mw.htw-dresden.de>
List: port-i386
Date: 09/03/2002 15:00:36
Hi i386'er,

because of the bad implementation of nfs-server on the linux boxes I have I
decided to try NetBSD for that. To test things I installed NetBSD-i386 on a
Pentium-IIMMX 333 MHz. This is 

$ > dmesg
NetBSD 1.5.3 (GENERIC) #34: Mon Jul  1 21:36:06 CEST 2002
    he@hamster.urc.uninett.no:/usr/src/sys/arch/i386/compile/GENERIC
cpu0: Intel Pentium II/Celeron (Deschutes) (686-class), 334.11 MHz
total memory = 127 MB
avail memory = 112 MB
using 1659 buffers containing 6636 KB of memory
BIOS32 rev. 0 found at 0xfb1a0
mainbus0 (root)
pci0 at mainbus0 bus 0: configuration mode 1
pci0: i/o space, memory space enabled
pchb0 at pci0 dev 0 function 0
pchb0: Intel 82443BX Host Bridge/Controller (rev. 0x02)
ppb0 at pci0 dev 1 function 0: Intel 82443BX AGP Interface (rev. 0x02)
pci1 at ppb0 bus 1
pci1: i/o space, memory space enabled
vga1 at pci1 dev 0 function 0: S3 86C365 Trio3D (rev. 0x01)
wsdisplay0 at vga1: console (80x25, vt100 emulation)
pcib0 at pci0 dev 7 function 0
pcib0: Intel 82371AB PCI-to-ISA Bridge (PIIX4) (rev. 0x02)
pciide0 at pci0 dev 7 function 1: Intel 82371AB IDE controller (PIIX4) (rev.
0x01)
pciide0: bus-master DMA support present
pciide0: primary channel wired to compatibility mode
pciide0: disabling primary channel (no drives)
pciide0: secondary channel wired to compatibility mode
atapibus0 at pciide0 channel 1
cd0 at atapibus0 drive 0: <FX410A, , J05> type 5 cdrom removable
cd0: 32-bit data port
cd0: drive supports PIO mode 3
pciide0: secondary channel interrupting at irq 15
cd0(pciide0:1:0): using PIO mode 3
uhci0 at pci0 dev 7 function 2: Intel 82371AB USB Host Controller (PIIX4) (rev.
0x01)
pci_intr_map: no mapping for pin D
uhci0: couldn't map interrupt
Intel 82371AB Power Management Controller (PIIX4) (miscellaneous bridge,
revision 0x02) at pci0 dev 7 function 3 not configured
ahc1 at pci0 dev 8 function 0
ahc1: interrupting at irq 11
ahc1: Using left over BIOS settings
ahc1: aic7850 Single Channel A, SCSI Id=7, 3/255 SCBs
scsibus0 at ahc1 channel 0: 8 targets, 8 luns per target
vr0 at pci0 dev 9 function 0: VIA VT6102 (Rhine II) 10/100 Ethernet
vr0: interrupting at irq 10
vr0: Ethernet address: 00:05:5d:a3:d2:98
ukphy0 at vr0 phy 8: Generic IEEE 802.3u media interface
ukphy0: OUI 0x0005be, model 0x0008, rev. 0
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
isa0 at pcib0
com0 at isa0 port 0x3f8-0x3ff irq 4: ns16550a, working fifo
com1 at isa0 port 0x2f8-0x2ff irq 3: ns16550a, working fifo
pckbc0 at isa0 port 0x60-0x64
pckbd0 at pckbc0 (kbd slot)
pckbc0: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard, using wsdisplay0
lpt0 at isa0 port 0x378-0x37b irq 7
pcppi0 at isa0 port 0x61
midi0 at pcppi0: PC speaker
sysbeep0 at pcppi0
isapnp0 at isa0 port 0x279: ISA Plug 'n Play device support
npx0 at isa0 port 0xf0-0xff: using exception 16
fdc0 at isa0 port 0x3f0-0x3f7 irq 6 drq 2
fd0 at fdc0 drive 0: 1.44MB, 80 cyl, 2 head, 18 sec
isapnp0: no ISA Plug 'n Play devices found
biomask fb65 netmask ff65 ttymask ffe7
scsibus0: waiting 2 seconds for devices to settle...
ahc1: target 0 synchronous at 10.0MHz, offset = 0xf
ahc1: target 0 using tagged queuing
sd0 at scsibus0 target 0 lun 0: <SEAGATE, ST31200N, 8648> SCSI2 0/direct fixed
sd0: 1006 MB, 2700 cyl, 9 head, 84 sec, 512 bytes/sect x 2061108 sectors
ahc1: target 4 synchronous at 10.0MHz, offset = 0xf
ahc1: target 4 using tagged queuing
sd1 at scsibus0 target 4 lun 0: <SEAGATE, ST15150N, 0023> SCSI2 0/direct fixed
sd1: 4095 MB, 3712 cyl, 21 head, 107 sec, 512 bytes/sect x 8388315 sectors
boot device: sd0
root on sd0a dumps on sd0b
root file system type: ffs

up to now I didn't compile my own kernel. Instead I use the kernel that is
installed during fresh install.

As you may see I do have 2 SCSI disks

---> sd0
ahc1: target 0 synchronous at 10.0MHz, offset = 0xf
ahc1: target 0 using tagged queuing
sd0 at scsibus0 target 0 lun 0: <SEAGATE, ST31200N, 8648> SCSI2 0/direct fixed
sd0: 1006 MB, 2700 cyl, 9 head, 84 sec, 512 bytes/sect x 2061108 sectors

---> sd1
ahc1: target 4 synchronous at 10.0MHz, offset = 0xf
ahc1: target 4 using tagged queuing
sd1 at scsibus0 target 4 lun 0: <SEAGATE, ST15150N, 0023> SCSI2 0/direct fixed
sd1: 4095 MB, 3712 cyl, 21 head, 107 sec, 512 bytes/sect x 8388315 sectors

The installation went fine and used sd0 as the disk to install netbsd to.

Disk 0 (sd0) does have the following layout:

$ > fdisk /dev/rsd0a
NetBSD disklabel disk geometry:
cylinders: 2700 heads: 9 sectors/track: 84 (756 sectors/cylinder)

BIOS disk geometry:
cylinders: 1006 heads: 64 sectors/track: 32 (2048 sectors/cylinder)

Partition table:
0: <UNUSED>
1: <UNUSED>
2: <UNUSED>
3: sysid 169 (NetBSD)
    start 0, size 16 (0 MB), flag 0x80
        beg: cylinder    0, head   0, sector  1
        end: cylinder    0, head   0, sector 16

I wondered why the partition 3 only takes 16 blocks. The disklabel has the
following layout:

$ > disklabel -r /dev/rsd0a
# /dev/rsd0a:
type: unknown
disk: netbsd-boot
label: 
flags:
bytes/sector: 512
sectors/track: 84
tracks/cylinder: 9
sectors/cylinder: 756
cylinders: 2700
total sectors: 2061108
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0           # microseconds
track-to-track seek: 0  # microseconds
drivedata: 0 

8 partitions:
#        size   offset     fstype   [fsize bsize cpg/sgs]
  a:   131512       32     4.2BSD     1024  8192    16   # (Cyl.    0*- 173)
  b:   523908   131544       swap                        # (Cyl.  174 - 866)
  c:  2061076       32     unused        0     0         # (Cyl.    0*- 2726*)
  d:  2061108        0     unused        0     0         # (Cyl.    0 - 2726*)
  e:  1048572   655452     4.2BSD     1024  8192    16   # (Cyl.  867 - 2253)
  f:   262332  1704024     4.2BSD     1024  8192    16   # (Cyl. 2254 - 2600)
  g:    94752  1966356     4.2BSD     1024  8192    16   # (Cyl. 2601 - 2726*)

Well, may be netbsd does not care of the partition size given in the partition
table?!

Since this disk does not have any OS installed on it that does not matter.

After having a running system I wanted to use the 4GB disk (sd1, that is
actually target 4 on the scsi-bus). First I fdisk'ed the disk. Now I have the
following partition table:

$ > fdisk /dev/rsd1a
NetBSD disklabel disk geometry:
cylinders: 3712 heads: 21 sectors/track: 107 (2247 sectors/cylinder)

BIOS disk geometry:
cylinders: 522 heads: 255 sectors/track: 63 (16065 sectors/cylinder)

Partition table:
0: sysid 169 (NetBSD)
    start 0, size 8388315 (4095 MB), flag 0x0
        beg: cylinder    0, head   0, sector  1
        end: cylinder  521, head 254, sector 63
1: <UNUSED>
2: <UNUSED>
3: <UNUSED>

The first partition covers the whole disk. I wanted to use the whole disk! o.k.

Lets disklabel the disk. After disklabel'ing the disk I have:

$ > disklabel -r /dev/rsd1a
# /dev/rsd1a:
type: SCSI
disk: ST15150N
label: fictitious
flags:
bytes/sector: 512
sectors/track: 107
tracks/cylinder: 21
sectors/cylinder: 2247
cylinders: 3712
total sectors: 8388315
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0           # microseconds
track-to-track seek: 0  # microseconds
drivedata: 0 

8 partitions:
#        size   offset     fstype   [fsize bsize cpg/sgs]
  a:   262144        0     4.2BSD     1024  8192    16   # (Cyl.    0 - 116*)
  b:   524288   262144       swap                        # (Cyl.  116*- 349*)
  c:  8388315        0     unused        0     0         # (Cyl.    0 - 3733*)
  d:  7601883   786432     4.2BSD     1024  8192    16   # (Cyl.  349*- 3733*)

Up to now everything is fine! But after creating new file systems

$ > newfs /dev/rsd1a
 ... and
$ > newfs /dev/rsd1d

I get the following error when trying to mount the second file system:

mount -t ffs /dev/rsd1a /mnt1
mount -t ffs /dev/rsd1d /mnt2

right after the mount of /mnt2 the console shows the message:

Sep  3 05:02:56 myhost /netbsd: /dev/sd1d: file system not clean (fs_clean=4);
please fsck(8)

If I mount the file systems in reverse order the other file system complains.

Then I tried to fsck a newfs'ed /dev/rsd1a after the file systems on both
netbsd-partitions have been created. The fsck bombs with:

$ > fsck /dev/rsd1a
** /dev/rsd1a

CANNOT READ: BLK 7588032
CONTINUE? [yn] 

If I only create the /dev/rsd1a everything is ok. But that's a __NO GO__ !

Hey, this will drive me crazy !

After the first attempt making the file systems I didn't realize that there are
some errors with these file systems. So I mounted both (/dev/rsd1a and
/dev/rsd1d). But during a find I was wondering that find complains for i-nodes
not correct. I found, that all dir's created in the the root of /mnt1 appear as
well in /mnt2 - I was astonished!

I do have netbsd-pmax and netbsd-sparc running, I have some Linux boxes and
Tru64 boxes as well. I'm not new to UNIX and the different flavours - but please
tell what I'm doing wrong here!!!

TIA

-- 
Uwe Lienig  | fon: (+49 351) 462 2780 | mailto:uwe.lienig@fif.mw.htw-dresden.de
            | fax: (+49 351) 462 3476 | http://www.fif.mw.htw-dresden.de
HTW Dresden | parcels: Gutzkowstr. 22 | letters: PF 12 07 01       
   -FiF-    |          01069 Dresden  |          01008 Dresden