Convert the CHS mode value to the LBA Value

Source: Internet
Author: User

Each disk has two sides, that is, the top and bottom sides of the disk, which are sequentially numbered from top to bottom from "0. The disk is divided into many concentric circles during formatting. These concentric circle tracks are called tracks ). The track starts from 0 in sequence. A cylinder is a cylinder consisting of the same track on all disks. The head on each cylinder starts from "0" from top to bottom. The operating system stores information on the hard disk in the form of a sector (sector). Each sector contains 512 bytes of data and other information.
These are usually used to represent the physical address of the hard disk. Now we use the logical address (LBA) as the disk capacity increases ). Therefore, we need to understand the conversion between CHS and LBA. Correspondence between C/h/s and LBA address: From CHS to LBA assume that C represents the current cylindrical number, H represents the current head number, and CS represents the start cylindrical number, HS indicates the start head number, SS indicates the start fan area number, PS indicates the number of sectors of each track, and ph indicates the number of tracks of each cylinder. the following relationship exists:
LBA = (c-CS) * Ph * PS + (H-HS) * PS + (S-SS)

Generally, cs = 0, HS = 0, Ss = 1, PS = 63, pH = 255

The following can be calculated based on the company:

C/h/S = 0/0/1. Then, use the above formula to obtain LBA = 0.

C/h/S = 0/0/63. In the above formula, LBA = 62 is obtained.

C/h/S = 1/0/1. In the above formula, LBA = 63 is obtained.

C/h/S = 220/156/18. In the above formula, we can get LBA = 3544145 from LBA to CHS. Here we first introduce two calculation operations: div and Mod. Div performs the division operation, that is, dividing the divisor by the integer part of the quotient obtained from the divisor. For example
Div 3 = 1, 33 Div 6 = 5.

MoD is the remainder operation, and mod operation is the remainder of the operator. For example, 5 mod 3 = mod 6 = 5.

Div and MoD are a pair of partners, one of which is an integer and a remainder. Each variable follows the preceding assumptions:

C = LBA Div (Ph * PS) + CS

H = (LBA Div PS) mod Ph + HS

S = LBA mod PS + SS if the above operation does not require mod, only the DIV operation can be used as follows:

C = LBA Div (Ph * PS) + CS

H = LBA Div PS-(C-CS) * PS + SS

S = LBA-(C-CS) * Ph * PS-(H-HS) * PS + SS according to this rule:

LBA = 0, corresponding C/h/S = 0/0/1

LBA = 62, corresponding to C/h/S = 0/0/63

LBA = 63, corresponding to C/h/S = 1/0/1

LBA = 62, corresponding to C/h/S = 0/0/63

LBA = 3544145, corresponding to C/h/S = 220/156/18. Through the above conversions, we have some knowledge about the conversions between CHS and LBA.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.