Logical block addressing

quoted from

http://en.wikipedia.org/wiki/Logical_block_addressing

 

LBA is a particularly simple addressing scheme; blocks are located by an index, with the first block being LBA=0, the second LBA=1, and so on. The LBA scheme replaces earlier schemes which exposed the physical details of the storage device to the software of the operating system. Chief among these was the cylinder-head-sector (CHS) scheme, where blocks were addressed by means of a tuple which defined the cylinder, head, and sector at which they appeared on the hard disk. CHS didn't map well to devices other than hard disks (such as tapes and networked storage), and was generally not used for them. CHS was used in early MFM and RLL drives, and both it and its successor Extended Cylinder-Head-Sector (ECHS) were used in the first ATA drives.

SCSI introduced LBA as an abstraction. While the drive controller still addresses data blocks by their CHS address, this information is generally not used by the SCSI device driver, the OS, filesystem code, or any applications (such as databases) that access the "raw" disk. System calls requiring block-level I/O pass LBA definitions to the storage device driver; for simple cases (where one volume maps to one physical drive), this LBA is then passed directly to the drive controller.

 

CHS to LBA conversion

 

C-H-S tuples can be converted to LBA addresses using the following formula:

 

LBA to CHS mapping

LBA addresses can be mapped to C-H-S tuples using the following formulae:

(start by calculating 'S', as for simplicity it is used for calculating 'C' and 'H')

Where:

  • LBA is the logical block address
  • heads is the total number of logical heads
  • sectors_per_track is the number of logical sectors per track
  • mod is the modulo operator

Note: the total number of cylinders does not enter into any calculation.

 

Another formula:

LBA / spt = Result1 + Remainder1
        S = Remainder1 + 1
Result1 / heads = Result2 + Remainder2
        C = Result2
        H = Remainder2

Example:

CHS = (600, 10, 84). Finding CHS for LBA = 1234 would be:

1234 / 84 = 14 R 58
        S = 58 + 1 = 59
14 / 10 = 1 R 4
        C = 1
        H = 4
CHS = (1, 4, 59)

Test: ((1 * 10) + 4) * 84 + 59 - 1 = 14 * 84 + 58 = 1234

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值