Reputation: 137
I'm going to write a disk partition creator program for flash memory removable devices, mostly controlled by SCSI based I/O and accessed with LBA address.
For reference, I'm researching the partition table on the SD cards that were partitioned and formatted by the disk utility of Ubuntu.
I used the 'unit' command of 'parted' software in Linux to watch the parameters of the cards with CHS unit and byte unit.
The following is for a 8GB sd card with 15122432 sectors of LBA:
pi@raspberrypi:~ $ sudo parted /dev/sda
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit chs print
Model: Generic CRM01 SD Reader (scsi)
Disk /dev/sda: 1020,130,11
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 1020,239,62. Each cylinder is 7587kB.
Partition Table: msdos
Disk Flags:
Number Start End Type File system Flags
1 0,1,0 1019,238,61 primary ext3
(parted) unit b print
Model: Generic CRM01 SD Reader (scsi)
Disk /dev/sda: 7742685184B
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 31744B 7738552319B 7738520576B primary ext3
The following is for a 4GB sd card with 7585792 sectors of LBA:
(parted) unit chs print
Model: Generic CRM01 SD Reader (scsi)
Disk /dev/sda: 1019,71,29
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 1019,120,62. Each cylinder is 3809kB.
Partition Table: msdos
Disk Flags:
Number Start End Type File system Flags
1 0,1,0 1018,119,61 primary ext3
(parted) unit b print
Model: Generic CRM01 SD Reader (scsi)
Disk /dev/sda: 3883925504B
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 31744B 3881656319B 3881624576B primary ext3
From my observation, the disk geometry values (C/H/S) are different on different capacity SD card, and the geometry values are seem associated with the end CHS address of the end of the partition. It is seems like..
The card with the partition which end CHS tuple is (c, h, s), which disk geometry will be (c + 1 / h + 1 / s + 1). Are they related?
But how the values are determined? Does those depend on OS or file system?
Upvotes: -1
Views: 2518
Reputation: 3891
Disk geometry is located in the on-board device controller, and OS request it from controller through the driver. Request/answer format is specified in the protocol definition of such device.
Long time ago I wrote IDE driver for PDP-11, and remember something about IDE/ATA protocol. I do not know details about modern SATA or SCSI devices, so can answer about ATA/IDE only.
An IDE device has special operation "identify" (code 0xEC), which driver sends to device. Driver sends this opcode command to the control port, and thereafter, when device set flag DRDY (device ready), reads 512 bytes block, contains an answer. An answer contains disk info (manufacturer, serial, etc) and geometry.
See for example this code, where program sends request to ATA and parse answer, contains disk geometry.
What I can say additionally:
Upvotes: 0