Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
kernel gets wrong harddisk size with ata_piix [solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6780

PostPosted: Sat Jan 17, 2009 8:41 pm    Post subject: kernel gets wrong harddisk size with ata_piix [solved] Reply with quote

Hello,

after switching from ide_generic (for which no dma is available) to the sata/pata-driver of my board (CONFIG_ATA_PIIX=y), the kernel gets a wrong (total) number of sectors for one of my harddisks (a slave on ordinary ide). Since this number is much too low, half of my /dev/sdb* partitions are not visible, and the last partition (which is "cut off") does of course not mount correctly. Also fdisk/cfdisk/parted cannot help, since they use the disk size they get from the kernel - they do not even start but just claim that the disk goes beyond its limits (and analyzing the source, I checked that the reason is that they read the wrong count by a kernel call); of course, using these tools would not be the proper solution anyway, since I need the full harddisk space.

My board is an intel gigabyte 82801G (ICH7). The sector number reported by the kernel is that shown by the BIOS if I switch the disk to "LBA" mode. However, there is also "CHS"-mode (which is the default mode), but switching to that mode in the BIOS makes no change for linux. So is it a driver bug that the kernel uses the wrong mode to read the number of sectors?

Or maybe I am missing some config option which would the kernel allow to "switch" the mode correctly?

The strange thing is that everything works correctly with ide_generic.

If it is really a kernel or BIOS bug: Can I somehow "force" the kernel to take the correct number? (I would not mind if I would have to hardcode the correct sector number somewhere manually)?


Last edited by mv on Sun Jan 18, 2009 9:41 pm; edited 1 time in total
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54793
Location: 56N 3W

PostPosted: Sat Jan 17, 2009 11:39 pm    Post subject: Reply with quote

mv,

I'm guessing that your drive is bigger than 137G but you can only see the first 137G.
It would be useful to know the real size of the drive.

The BIOS should be set to LBA mode. C/H/S mode can address 8G maximum. The kernel doesn't care. There are two standards for LBA mode, LBA28 which can address 137438953472 Bytes (137G) and LBA48 which can address a lot more. The kernel checks the LBA48 drive ID first and if there is nothing there, tries the LBA28 ID, which is in a different location.

Drives bigger that 137G report 137Gb in the LBA28 ID location as its all the space allows. you don't have to do anything special, it just works.

What does
Code:
hdparm -iI /dev/...
report?
Also, what does
Code:
fdisk -l /dev/
... show
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6780

PostPosted: Sun Jan 18, 2009 8:35 am    Post subject: Reply with quote

NeddySeagoon, thanks for your reply.
NeddySeagoon wrote:
I'm guessing that your drive is bigger than 137G but you can only see the first 137G.

The first guess is correct (160 GB) but the second not: I see only the first 33 GB.
Quote:
The BIOS should be set to LBA mode.

As I mentioned, it makes no change. I can set the mode only after the autodetection anyway. It seems that the BIOS does not detect the harddisk correctly (but my other harddisk which is even larger is detected correctly; BTW they are master/slave). More precisely, in the BIOS I can only switch four modes:
BIOS screen wrote:
CHS: reports 33822 MB, 65531 Cylinders 16 Heads 63 Sectors
Large: reports 31703 MB, 4095 Cylinders, 240 Heads, 63 Sectors
LBA: 33816 MB, 4111 Cylinders, 255 Heads, 63 Sectors
Auto: looks like CHS
Unfortunately, it is not possible in the BIOS to change this information manually. The information which the kernel gets with the ata_piix driver is the one of LBA (no matter which mode I choose in the BIOS).

So I was actually rather surprised that there are no problems with the ide_generic driver: Somehow the kernel gets the correct size in this case anyway, I do not know from where.

NeddySeagoon wrote:
What does
Code:
hdparm -iI /dev/...
report?

The information depends of course whether the ide_generic or the ata_piix driver is use. In the following, I write both informations side by side (red is the [false] information of the ata_piix driver).
hdparm -iI /dev/... wrote:
/dev/hdb /dev/sdb

Model=SAMSUNG SP1614N [25 spaces], FwRev=TM100-24, SerialNo=(not made public here)
Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs }
RawCHS=16383/16/63, TrkSize=34902, SectSize=554, ECCbytes=4
BuffType=DualPortCache, BuffSize=8192kB, MaxMultSect=16, MultSect=off
CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=66055248
IORDY=on/off, tPIO={min:240,w/IORDY:120}, tDMA={min:120,rec:120}
PIO modes: pio0 pio1 pio2 pio3 pio4
DMA modes: mdma0 mdma1 mdma2
UDMA modes: udma0 udma1 udma2 udma3 udma4 *udma5
AdvancedPM=no WriteCache=enabled
Drive conforms to: ATA/ATAPI-7 T13 1532D revision 0: ATA/ATAPI-1,2,3,4,5,6,7

* signifies the current active mode

ATA device, with non-removable media
Model Number: SAMSUNG SP1614N
Serial Number: (not made public here)
Firmware Revision: TM100-24
Standards:
Used: ATA/ATAPI-7 T13 1532D revision 0
Supported: 7 6 5 4
Configuration:
Logical max current
cylinders 16383 16383
heads 16 16
sectors/track 63 63
--
CHS current addressable sectors: 16514064
LBA user addressable sectors: 268435455 66055248
LBA48 user addressable sectors: 312581808 66055248
device size with M = 1024*1024: 152627 MBytes 32253 MBytes
device size with M = 1000*1000: 160041 MBytes (160 GB) 33820 MBytes (33 GB)
cache/buffer size = 8192 KBytes (type=DualPortCache)
Capabilities:
LBA, IORDY(can be disabled)
Standby timer values: spec'd by Standard, no device specific minimum
R/W multiple sector transfer: Max = 16 Current = ?
Recommended acoustic management value: 254, current value: 254
DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 *udma5
Cycle time: min=120ns recommended=120ns
PIO: pio0 pio1 pio2 pio3 pio4
Cycle time: no flow control=240ns IORDY flow control=120ns
Commands/features:
Enabled Supported:
* SMART feature set
Security Mode feature set
* Power Management feature set
* Write cache
* Look-ahead
* Host Protected Area feature set

NeddySeagoon wrote:
Also, what does
Code:
fdisk -l /dev/
... show

With the ata_piix driver it shows nothing (since it probably exits immediately because a partition is beyond the end). However, by inserting some printf-s into the sourcecode I found that it gets from the kernel the same information as with the ide_generic driver except for the total number of sectors [which it calculates by ioctl(fd, BLKGETSIZE64, bytes)] (the heads/sectors of the kernel and on the partition table are the same):
patched fdisk /dev/sdb wrote:
heads: 255, sectors: 63, total sectors: 66055248

patched fdisk /dev/hdb wrote:
heads: 255, sectors: 63, total sectors: 312581808

(the second is of course with the ide_generic driver). With the ide_generic driver, fdisk -l /dev/hdb gives
Code:
Disk /dev/hdb: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: (not made public here)

   Device Boot      Start         End      Blocks   Id  System
/dev/hdb1               1          38      305203+  16  Hidden FAT16
/dev/hdb2              39         268     1847475   16  Hidden FAT16
/dev/hdb3   *         269         765     3992152+   b  W95 FAT32
/dev/hdb4             766       19457   150143490    f  W95 Ext'd (LBA)
/dev/hdb5             766         880      923674+   e  W95 FAT16 (LBA)
/dev/hdb6             881         992      899608+   e  W95 FAT16 (LBA)
/dev/hdb7             993         996       32098+  83  Linux
/dev/hdb8             997        1000       32098+  83  Linux
/dev/hdb9            1005        2248     9992398+  83  Linux
/dev/hdb10           2249        3492     9992398+  83  Linux
/dev/hdb11           3493        4736     9992398+  83  Linux
/dev/hdb12           4737        5980     9992398+  83  Linux
/dev/hdb13           5981        6602     4996183+  83  Linux
/dev/hdb14           6603       18844    98333833+  83  Linux
This is the way the disk actually was partitioned (on a different system).
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54793
Location: 56N 3W

PostPosted: Sun Jan 18, 2009 3:10 pm    Post subject: Reply with quote

mv,

This all helps. 33Gb was the previous BIOS limit, before 137Gb
Your BIOS will never see more than 33Gb of the drive but thats OK. The kernel should still see it all.

You still need to set LBA in the BIOS, not Auto.

Code:
RawCHS=16383/16/63, TrkSize=34902, SectSize=554, ECCbytes=4
IS not correct.
The drive should report 16383/255/63, which is the fake full field value that drives bigger than the can report for old standards are supposed to use.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6780

PostPosted: Sun Jan 18, 2009 6:49 pm    Post subject: Reply with quote

NeddySeagoon wrote:
You still need to set LBA in the BIOS, not Auto.

I retried this again, but still it doesn't change anything: hdparm -iI /dev/sdb still shows the same, and the kernel knows only /dev/sdb{1..11}, not /dev/sdb{12..14} (and attempting to mount /dev/sdb11 would probably again give errors - I do not try now).

Isn't there a "manual" way to tell the kernel the correct information? (Of course, it can be done by hacking the kernel source sufficiently, but I mean a less cumbersome way).
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54793
Location: 56N 3W

PostPosted: Sun Jan 18, 2009 7:48 pm    Post subject: Reply with quote

mv

The Large Drive HOWTO is worth a read.
Set the jumpers on the drive for 33Gb clipping. Go here and get version 1 of the user manual to see how.
This makes the drive lie to the BIOS about its size but thats OK, its only telling the BIOS what it wants to see.

Linux will still see all of the drive.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6780

PostPosted: Sun Jan 18, 2009 9:49 pm    Post subject: Reply with quote

NeddySeagoon,

thank you very much! Fortunately the jumper settings were printed on the harddisk (they were different than in the pdf).
I had never expected that this problem could have been caused by wrong jumper setting, but apparently this was the problem.
In fact, it appears that the setting was wrong (33GB clipping) from the very beginning! :oops: (I just did not realize this, because with my previous main board (and another ide driver) the problem was not visible). Now even the BIOS shows the correct size in all modes.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum