Hello.

From the experiment below it seems that the kernel modifies its knowledge
of a sector size of a disk hardware according to what can be found in the disk label sector. It does so even if the value found does not make sense hardware-wise and in spite of a sector size the hardware device driver works with. It can make the device completly inaccessible. The disklabel(8) command doesn't allow to set/change the sector size value even if it were accessible.

Such situation also occurs if the disk label is read from a sector where a disk label is not expected - this was already a subject of my previous report.

It effectively means that if there is wrong data on the drive, you don't have a chance to analyze the situation or fix it. You can't even view the fdisk (MBR) partition table.

In the following example I copied an image of a 512-byte sector USB drive (sd5) to a clean 4k-sector USB drive (sd4). The source drive contained an OpenBSD fdisk partition with a disklabel partition and a functional filesystem. After that, kernel can't read any data from that 4k-sector drive, causing errors at umass(4) driver level. Please note the output of "disklabel sd4" before and after copying the image and the difference in sector size there.

My guess is that this issue could be related to this one about a year ago:
http://marc.info/?l=openbsd-misc&m=134027998905971&w=2

Regards,
David


Connected
OpenBSD/i386 BOOT 3.21
boot> kernel/i386/bsd.rd
booting hd0a:kernel/i386/bsd.rd: 
/-\|/-\|/6043500-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-+433856
 
[52+235056\|/-\|/-\|/-\|/+223307-\|/-\|/-\|/-]=0x69d650
entry point at 0x200120

Copyright (c) 1982, 1986, 1989, 1991, 1993
        The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2013 OpenBSD. All rights reserved.  http://www.OpenBSD.org

OpenBSD 5.4 (RAMDISK_CD) #28: Sun Jul 21 19:26:53 MDT 2013
    dera...@i386.openbsd.org:/usr/src/sys/arch/i386/compile/RAMDISK_CD
cpu0: Intel(R) Core(TM)2 CPU 4300 @ 1.80GHz ("GenuineIntel" 686-class) 1.80 GHz
cpu0: 
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,NXE,LONG,SSE3,DTES64,MWAIT,DS-CPL,EST,TM2,SSSE3,CX16,xTPR,PDCM,LAHF,PERF
real mem  = 526839808 (502MB)
avail mem = 510959616 (487MB)
mainbus0 at root
bios0 at mainbus0: AT/286+ BIOS, date 11/24/08, BIOS32 rev. 0 @ 0xfa080, SMBIOS 
rev. 2.4 @ 0xf0000 (34 entries)
bios0: vendor Phoenix Technologies, LTD version "MS7336 1.14" date 11/24/2008
bios0: Hewlett-Packard HP Compaq dx2300 Microtower
acpi0 at bios0: rev 0
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP SLIC HPET MCFG APIC SSDT SSDT
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: apic clock running at 199MHz
cpu at mainbus0: not configured
ioapic0 at mainbus0: apid 4 pa 0xfec00000, version 20, 24 pins
ioapic0: misconfigured as apic 0, remapped to apid 4
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus -1 (PEX0)
acpiprt2 at acpi0: bus -1 (PEX1)
acpiprt3 at acpi0: bus -1 (PEX2)
acpiprt4 at acpi0: bus -1 (PEX3)
acpiprt5 at acpi0: bus -1 (PEX4)
acpiprt6 at acpi0: bus -1 (PEX5)
acpiprt7 at acpi0: bus 2 (HUB0)
bios0: ROM list: 0xc0000/0xb000! 0xcc000/0x1800
pci0 at mainbus0 bus 0: configuration mode 1 (bios)
pchb0 at pci0 dev 0 function 0 "Intel 82946GZ Host" rev 0x02
ppb0 at pci0 dev 1 function 0 "Intel 82946GZ PCIE" rev 0x02: apic 4 int 16
pci1 at ppb0 bus 1
vga1 at pci0 dev 2 function 0 "Intel 82946GZ Video" rev 0x02
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
"Intel 82801GB HD Audio" rev 0x01 at pci0 dev 27 function 0 not configured
uhci0 at pci0 dev 29 function 0 "Intel 82801GB USB" rev 0x01: apic 4 int 23
uhci1 at pci0 dev 29 function 1 "Intel 82801GB USB" rev 0x01: apic 4 int 19
uhci2 at pci0 dev 29 function 2 "Intel 82801GB USB" rev 0x01: apic 4 int 18
uhci3 at pci0 dev 29 function 3 "Intel 82801GB USB" rev 0x01: apic 4 int 16
ehci0 at pci0 dev 29 function 7 "Intel 82801GB USB" rev 0x01: apic 4 int 23
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 "Intel EHCI root hub" rev 2.00/1.00 addr 1
ppb1 at pci0 dev 30 function 0 "Intel 82801BA Hub-to-PCI" rev 0xe1
pci2 at ppb1 bus 2
fxp0 at pci2 dev 8 function 0 "Intel 82801GB LAN" rev 0x01, i82562: apic 4 int 
20, address xx:xx:xx:xx:xx:xx
inphy0 at fxp0 phy 1: i82562ET 10/100 PHY, rev. 0
pcib0 at pci0 dev 31 function 0 "Intel 82801GB LPC" rev 0x01
pciide0 at pci0 dev 31 function 2 "Intel 82801GB SATA" rev 0x01: DMA, channel 0 
configured to native-PCI, channel 1 configured to native-PCI
pciide0: using apic 4 int 19 for native-PCI interrupt
wd0 at pciide0 channel 0 drive 0: <ST3250318AS>
wd0: 16-sector PIO, LBA48, 238475MB, 488397168 sectors
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 6
atapiscsi0 at pciide0 channel 1 drive 0
scsibus0 at atapiscsi0: 2 targets
cd0 at scsibus0 targ 0 lun 0: <HL-DT-ST, DVD+-RW GSA-H31L, W618> ATAPI 5/cdrom 
removable
cd0(pciide0:1:0): using PIO mode 4, Ultra-DMA mode 5
"Intel 82801GB SMBus" rev 0x01 at pci0 dev 31 function 3 not configured
usb1 at uhci0: USB revision 1.0
uhub1 at usb1 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb2 at uhci1: USB revision 1.0
uhub2 at usb2 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb3 at uhci2: USB revision 1.0
uhub3 at usb3 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb4 at uhci3: USB revision 1.0
uhub4 at usb4 "Intel UHCI root hub" rev 1.00/1.00 addr 1
isa0 at pcib0
isadma0 at isa0
com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
com0: console
com1 at isa0 port 0x2f8/8 irq 3: ns16550a, 16 byte fifo
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
umass0 at uhub0 port 2 configuration 1 interface 0 "Generic USB2.0-CRW" rev 
2.00/11.22 addr 2
umass0: using SCSI over Bulk-Only
scsibus1 at umass0: 2 targets, initiator 0
sd0 at scsibus1 targ 1 lun 0: <Generic-, Compact Flash, 1.00> SCSI0 0/direct 
removable
sd1 at scsibus1 targ 1 lun 1: <Generic-, SM/xD-Picture, 1.00> SCSI0 0/direct 
removable
sd2 at scsibus1 targ 1 lun 2: <Generic-, SD/MMC, 1.00> SCSI0 0/direct removable
sd3 at scsibus1 targ 1 lun 3: <Generic-, MS/MS-Pro, 1.00> SCSI0 0/direct 
removable
umass1 at uhub0 port 5 configuration 1 interface 0 "HGST Touro Desk 3.0" rev 
2.10/0.00 addr 3
umass1: using SCSI over Bulk-Only
scsibus2 at umass1: 2 targets, initiator 0
sd4 at scsibus2 targ 1 lun 0: <HGST, , 0000> SCSI4 0/direct fixed 
serial.xxxxxxxxxxxxxxxxxxxx
sd4: 3815446MB, 4096 bytes/sector, 976754431 sectors
softraid0 at root
scsibus3 at softraid0: 256 targets
root on rd0a swap on rd0b dump on rd0b
erase ^?, werase ^W, kill ^U, intr ^C, status ^T

Welcome to the OpenBSD/i386 5.4 installation program.
(I)nstall, (U)pgrade or (S)hell? s
# export TERM=vt220
# umass2 at uhub0 port 4 configuration 1 interface 0 "Kingston DT 101 G2" rev 
2.00/1.00 addr 4
umass2: using SCSI over Bulk-Only
scsibus4 at umass2: 2 targets, initiator 0
sd5 at scsibus4 targ 1 lun 0: <Kingston, DT 101 G2, PMAP> SCSI0 0/direct 
removable serial.xxxxxxxxxxxxxxxxxxxx
sd5: 15280MB, 512 bytes/sector, 31293440 sectors

# cd /dev/ 
# . ./MAKEDEV sd4 sd5
# cd /
# fdisk sd5
Disk: sd5       geometry: 1947/255/63 [31293440 Sectors]
Offset: 0       Signature: 0xAA55
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
 0: 00      0   0   0 -      0   0   0 [           0:           0 ] unused
 1: 00      0   0   0 -      0   0   0 [           0:           0 ] unused
2: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused *3: A6 0 1 2 - 19 32 13 [ 64: 307200 ] OpenBSD # disklabel sd5
# /dev/rsd5c:
type: SCSI
disk: SCSI disk
label: DT 101 G2 duid: 22e020ee169584f9
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 1947
total sectors: 31293440
boundstart: 64
boundend: 307264
drivedata: 0

16 partitions:
#                size           offset  fstype [fsize bsize  cpg]
  a:           208768               64  4.2BSD   2048 16384    1
c: 31293440 0 unused # fsck -nf /dev/rsd5a
** /dev/rsd5a (NO WRITE)
** File system is already clean
** Last Mounted on /mnt
** Phase 1 - Check Blocks and Sizes
** Phase 2 - Check Pathnames
** Phase 3 - Check Connectivity
** Phase 4 - Check Reference Counts
** Phase 5 - Check Cyl groups
3 files, 42330 used, 8957 free (13 frags, 1118 blocks, 0.0% fragmentation)
# mount -r /dev/sd5a /mnt
# ls -la /mnt
total 169321
drwxr-xr-x   2 root  wheel       512 Jul 22 09:58 .
drwxr-xr-x  11 root  wheel       512 Jul 22 01:22 ..
-rw-r--r--   1 root  wheel        50 Jul 22 09:58 MD5
-rw-r--r--   1 1009  1009   86632448 May 17 14:54 file.dat
# umount /mnt
# fdisk sd4
Disk: sd4       geometry: 60800/255/63 [976754431 4096-byte Sectors]
Offset: 0       Signature: 0x0
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
 0: 00      0   0   0 -      0   0   0 [           0:           0 ] unused
 1: 00      0   0   0 -      0   0   0 [           0:           0 ] unused
 2: 00      0   0   0 -      0   0   0 [           0:           0 ] unused
3: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused # disklabel sd4
# /dev/rsd4c:
type: SCSI
disk: SCSI disk
label: HGST duid: 0000000000000000
flags:
bytes/sector: 4096
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 60800
total sectors: 976754431
boundstart: 0
boundend: 976754431
drivedata: 0

16 partitions:
#                size           offset  fstype [fsize bsize  cpg]
c: 976754431 0 unused # dd if=/dev/zero bs=1m count=1k of=/dev/rsd4c
1024+0 records in
1024+0 records out
1073741824 bytes transferred in 40.960 secs (26213770 bytes/sec)
# dd if=/dev/rsd5c bs=64k count=2500 of=/dev/rsd4c
2500+0 records in
2500+0 records out
163840000 bytes transferred in 15.085 secs (10860760 bytes/sec)
# fdisk sd4
umass1: Phase Error, residue = 0
umass1: Phase Error, residue = 0
umass1: Phase Error, residue = 0
Disk: sd4       umass1: Phase Error, residue = 0
geometry: 60800/255/63 [976754431 4096-byte Sectors]
# disklabel sd4
# /dev/rsd4c:
type: SCSI
disk: SCSI disk
label: DT 101 G2 duid: 22e020ee169584f9
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 1947
total sectors: 976754431
boundstart: 64
boundend: 307264
drivedata: 0

16 partitions:
#                size           offset  fstype [fsize bsize  cpg]
  a:           208768               64  4.2BSD   2048 16384    1
c: 976754431 0 unused # fdisk sd4
umass1: Phase Error, residue = 0
umass1: Phase Error, residue = 0
umass1: Phase Error, residue = 0
Disk: sd4       umass1: Phase Error, residue = 0
geometry: 60800/255/63 [976754431 4096-byte Sectors]
# dd if=/dev/rsd4c bs=4k of=/dev/null
umass1: Phase Error, residue = 0
dd: /dev/rsd4c: Input/output error
0+0 records in
0+0 records out
0 bytes transferred in 0.009 secs (0 bytes/sec)
# dd if=/dev/rsd4c bs=512 of=/dev/null
umass1: Phase Error, residue = 0
dd: /dev/rsd4c: Input/output error
0+0 records in
0+0 records out
0 bytes transferred in 0.009 secs (0 bytes/sec)
# dd if=/dev/rsd4c bs=64k of=/dev/null
umass1: Phase Error, residue = 0
dd: /dev/rsd4c: Input/output error
0+0 records in
0+0 records out
0 bytes transferred in 0.009 secs (0 bytes/sec)
# dd if=/dev/rsd4a bs=4k of=/dev/null
umass1: Phase Error, residue = 0
dd: /dev/rsd4a: Input/output error
0+0 records in
0+0 records out
0 bytes transferred in 0.009 secs (0 bytes/sec)
# dd if=/dev/rsd4c bs=4k |less








umass1: Phase Error, residue = 0















dd: /dev/rsd4c: Input/output error
0+0 records in
0+0 records out
0 bytes transferred in 0.020 secs (0 bytes/sec)
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
(END)# fdisk sd4
umass1: Phase Error, residue = 0
umass1: Phase Error, residue = 0
umass1: Phase Error, residue = 0
Disk: sd4       umass1: Phase Error, residue = 0
geometry: 60800/255/63 [976754431 4096-byte Sectors]
# reboot
syncing disks... done
rebooting...
~
[EOT]

Reply via email to