USB stick geometry question

2013-11-01 Thread Stefan Sperling
I have run into a small issue with an x130e thinkpad and a 4GB USB stick.

After running fdisk -i on the USB stick, having the stick inserted
at power-on prevents the laptop from booting. It gets stuck with a
black screen, before even showing the first 'Thinkpad' logo screen
where I can enter the BIOS by pressing F1. Eventually the system
resets automatically, but then hangs again as before.

When I remove the stick while the system hangs, the system instantly
resumes booting. I can reinsert the stick and 'reboot' from the boot
loader, and the system comes up properly. 'machine diskinfo' shows
this for the stick:

DiskBIOSTypeCylsHeads   SecsFlags   Checksum
hd1 0x81label   492 255 63  0x0 0xd1aa95e2

This is the partition table created by fdisk -i:

Disk: sd1   geometry: 491/255/63 [7892992 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 -490 254  63 [  64: 7887851 ] OpenBSD   

Disabling USB boot support in the BIOS fixes the issue but makes
it impossible to use the USB stick as keydisk since the stick
doesn't show up in 'machine diskinfo' anymore.

Zeroing the first MB of the stick also fixes the issue.
'machine diskinfo' now shows:

DiskBIOSTypeCylsHeads   SecsFlags   Checksum
hd1 0x81label   490 255 63  0x0 

The problem also goes away if I manually create a partition table with
'fdisk -e  -c 490 -h 255 -s 63 sd1' that looks as follows:

Disk: sd1   geometry: 490/255/63 [7871850 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: A6  0   1   2 -489 254  63 [  64: 7871786 ] OpenBSD 

'machine diskinfo' for that is:
DiskBIOSTypeCylsHeads   SecsFlags   Checksum
hd1 0x81label   490 255 63  0x0 0x2c0f040e

I bought 3 of these USB sticks and ran into this problem with 2 of them.
I then unwrapped the third one from the packaging and tested it unmodified.
The system boots fine and 'machine diskinfo' shows:

DiskBIOSTypeCylsHeads   SecsFlags   Checksum
hd1 0x81label   985 128 63  0x0 0xb919a6ea

The partition table looks like this in fdisk:

Disk: sd1   geometry: 491/255/63 [7892992 Sectors]
Offset: 0   Signature: 0xAA55
Starting Ending LBA Info:
 #: id  C   H   S -  C   H   S [   start:size ]
---
*0: 0C  0   1   1 -491  80  37 [  63: 7892929 ] Win95 FAT32L
 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   

Can anyone explain this problem?

Is it a BIOS/UEFI firmware bug?
Is it an incompability between OpenBSD's fdisk and the BIOS that can
happen due to diferences in disk geometry detection heuristics?
Is it a bug in OpenBSDs fdisk?



Re: USB stick geometry question

2013-11-01 Thread Kenneth R Westerback
I've had similar things happen on my current build-box, but just
wrote it off to a weird bios thing. Tweaking the MBR never occurred
to me that I can recall.

I'll see if it is still happening to me.

 Ken

On Fri, Nov 01, 2013 at 09:09:21PM +0100, Stefan Sperling wrote:
 I have run into a small issue with an x130e thinkpad and a 4GB USB stick.
 
 After running fdisk -i on the USB stick, having the stick inserted
 at power-on prevents the laptop from booting. It gets stuck with a
 black screen, before even showing the first 'Thinkpad' logo screen
 where I can enter the BIOS by pressing F1. Eventually the system
 resets automatically, but then hangs again as before.
 
 When I remove the stick while the system hangs, the system instantly
 resumes booting. I can reinsert the stick and 'reboot' from the boot
 loader, and the system comes up properly. 'machine diskinfo' shows
 this for the stick:
 
 Disk  BIOSTypeCylsHeads   SecsFlags   Checksum
 hd1   0x81label   492 255 63  0x0 0xd1aa95e2
 
 This is the partition table created by fdisk -i:
 
 Disk: sd1   geometry: 491/255/63 [7892992 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 -490 254  63 [  64: 7887851 ] OpenBSD   
 
 Disabling USB boot support in the BIOS fixes the issue but makes
 it impossible to use the USB stick as keydisk since the stick
 doesn't show up in 'machine diskinfo' anymore.
 
 Zeroing the first MB of the stick also fixes the issue.
 'machine diskinfo' now shows:
 
 Disk  BIOSTypeCylsHeads   SecsFlags   Checksum
 hd1   0x81label   490 255 63  0x0 
 
 The problem also goes away if I manually create a partition table with
 'fdisk -e  -c 490 -h 255 -s 63 sd1' that looks as follows:
 
 Disk: sd1   geometry: 490/255/63 [7871850 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: A6  0   1   2 -489 254  63 [  64: 7871786 ] OpenBSD 
 
 'machine diskinfo' for that is:
 Disk  BIOSTypeCylsHeads   SecsFlags   Checksum
 hd1   0x81label   490 255 63  0x0 0x2c0f040e
 
 I bought 3 of these USB sticks and ran into this problem with 2 of them.
 I then unwrapped the third one from the packaging and tested it unmodified.
 The system boots fine and 'machine diskinfo' shows:
 
 Disk  BIOSTypeCylsHeads   SecsFlags   Checksum
 hd1   0x81label   985 128 63  0x0 0xb919a6ea
 
 The partition table looks like this in fdisk:
 
 Disk: sd1   geometry: 491/255/63 [7892992 Sectors]
 Offset: 0   Signature: 0xAA55
 Starting Ending LBA Info:
  #: id  C   H   S -  C   H   S [   start:size ]
 ---
 *0: 0C  0   1   1 -491  80  37 [  63: 7892929 ] Win95 
 FAT32L
  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   
 
 Can anyone explain this problem?
 
 Is it a BIOS/UEFI firmware bug?
 Is it an incompability between OpenBSD's fdisk and the BIOS that can
 happen due to diferences in disk geometry detection heuristics?
 Is it a bug in OpenBSDs fdisk?