邏輯區塊位址 (LBA):扇區編號的運作原理

Logical block addressing (LBA) is a method of identifying storage blocks with sequential numbers instead of cylinder, head, and sector coordinates. LBA 0 identifies the first logical block, LBA 1 identifies the second, and so on. However, an LBA number alone does not determine a byte offset: you also need the logical block size and the address-space origin. Understanding this relationship helps explain disk layouts, partition boundaries, and the differences between logical and physical sectors.
目錄
LBA Explained: How Logical Block Addresses Work
LBA treats a storage device’s addressable blocks as a linear sequence. Instead of describing a location using three coordinates, as Cylinder-Head-Sector (CHS) addressing does, it assigns each logical block an integer index.
For example, the first four logical blocks are:
LBA | 意義 |
0 | 第一個邏輯區塊 |
1 | Second logical block |
2 | Third logical block |
3 | Fourth logical block |
實例
Imagine a USB drive that exposes 512-byte logical blocks. A disk tool requests one block by its LBA number. Select an example to see which block the number refers to.
The request
“Read LBA 3.” The drive is being asked for the block numbered 3—not the third block.
In plain English
LBA 3 = the 4th block
Three blocks come before it: LBA 0, LBA 1, and LBA 2. Because counting starts at zero, address 3 points to position four.
重要的區別: LBA 3 means “logical block number 3,” not “file number 3” and not “physical location 3.” The byte range above follows from the example’s 512-byte logical block size. A file system’s metadata is needed to determine which file, if any, uses that block.
This numbering is zero-based. If a device exposes (N) logical blocks, its last valid LBA is N − 1, assuming the address space begins at LBA 0 and contains no gaps in its numbering.
For example, a device exposing 2,000,000 logical blocks has a last LBA of 1,999,999. The number of blocks is therefore one greater than the last LBA.
LBA is an addressing convention, not a file system. It does not describe filenames, directories, or file allocation. Partition tables use logical block addresses to describe where partitions begin and end, while file systems use their own metadata to organize files within those partitions.
The address-space origin also matters. A disk-relative LBA and a volume-relative block number may refer to different locations even when their numeric values are identical. Always establish whether a tool reports addresses relative to the entire device or to a partition before combining its results with partition-table information.
How to Calculate an LBA Sector Number's Byte Offset
顏色 LBA sector number identifies a logical block, but converting that number into a byte position requires the logical block size.
The starting byte offset is calculated as:
Starting byte offset = LBA × Logical block size
If the logical block size is represented by (B), the inclusive byte range of an LBA is:
Start offset = LBA × B
End offset = (LBA + 1) × B − 1
The subtraction of one is necessary because byte offsets are zero-based and the end offset is inclusive.
Example: LBA 50 with different logical block sizes
Consider LBA 50 under two common logical block sizes.
Calculation | 512-byte logical block | 4,096-byte logical block |
Starting offset | 25,600 bytes | 204,800 bytes |
Starting offset in hexadecimal |
|
|
Last byte offset | 26,111 bytes | 208,895 bytes |
Last offset in hexadecimal |
|
|
Total bytes addressed | 512 | 4,096 |
For a 512-byte logical block, LBA 50 starts at byte offset 25,600 and covers bytes 25,600–26,111. That inclusive range contains exactly 512 bytes.
For a 4,096-byte logical block, the same LBA starts at byte offset 204,800 and covers bytes 204,800–208,895, a total of 4,096 bytes.
These are illustrative calculations, not measurements from a physical disk.
The important result is that the same LBA can correspond to different byte offsets when the logical block size changes. You cannot assume that multiplying every LBA by 512 will produce the correct byte offset for every device.
The calculation also assumes that the LBA and logical block size refer to the same address space. If a tool reports a partition-relative block number but you need a disk-relative address, you must account for the partition’s starting LBA and confirm that both values use the same logical block unit.
LBA-to-Byte-Offset Explorer
Change the LBA number to compare the byte range it identifies under two common logical block sizes.
With a 512-byte logical block
Starting byte offset
Inclusive byte range
Last byte offset
With a 4,096-byte logical block
Starting byte offset
Inclusive byte range
Last byte offset
Calculation: start offset = LBA × logical block size
Inclusive end: end offset = (LBA + 1) × logical block size − 1
Teaching example only. This calculator does not read a disk. The calculation assumes the LBA and block size refer to the same logical device, with byte offsets measured from that device's beginning.
LBA vs. CHS Addressing
LBA vs. CHS is primarily a comparison between two ways of expressing a storage address.
CHS stands for Cylinder, Head, and Sector. It represents a location using three coordinates, while LBA assigns the location a single sequential number.
特點 | LBA | CHS |
Address representation | One linear block number | Cylinder, head, and sector coordinates |
Numbering | LBA starts at 0 | Traditional sector numbers start at 1 |
Address calculation | Multiply the LBA by the logical block size to obtain a byte offset | Requires geometry parameters to translate the coordinates |
Modern disk interpretation | Logical address exposed by the storage interface | May represent translated geometry rather than actual physical geometry |
Partition-table use | Explicit LBA fields are used by modern partitioning structures | Legacy fields remain in MBR entries for compatibility |
How CHS coordinates map to LBA
A traditional CHS-to-LBA conversion requires the number of heads per cylinder and the number of sectors per track.
Using zero-based cylinder and head numbers and a one-based sector number:
LBA = ((Cylinder × Heads per cylinder) + Head) × Sectors per track + (Sector − 1)
For example, suppose a hypothetical geometry has 16 heads per cylinder and 63 sectors per track. The CHS address (1, 2, 3) converts to:
LBA = ((1 × 16) + 2) × 63 + (3 − 1)
LBA = 18 × 63 + 2
LBA = 1,136
This example demonstrates the conversion formula; it does not describe the physical layout of a particular drive.
Modern drives do not necessarily expose a CHS geometry that corresponds to their actual physical tracks and heads. Legacy software may use translated CHS values for compatibility, so those values should not automatically be interpreted as physical locations.
的 UEFI specification’s MBR partition-record definition explicitly distinguishes the CHS fields from the LBA fields used by UEFI firmware to determine partition locations.
LBA is simpler to use as a linear addressing scheme, but its addressable capacity still depends on the width of the address field and the storage interface. The term LBA alone does not specify a universal address width.
Logical Block Size vs. Physical Sector Size
An LBA identifies a logical block exposed by the storage device or interface. That logical block is not necessarily the same size as a physical sector on the underlying medium.
Three common hard-drive formats illustrate the distinction:
格式 | 邏輯扇區大小 | 實體部門規模 |
512n | 512 位元組 | 512 位元組 |
512e | 512 位元組 | 4,096 位元組 |
4Kn | 4,096 位元組 | 4,096 位元組 |
These are common formats, not an exhaustive list of every block size that a storage interface may report.
In a 512e drive, eight 512-byte logical sectors fit within one 4,096-byte physical sector. The operating system addresses the logical sectors, while the device manages the relationship between those sectors and the physical storage layout.
This difference matters for two reasons:
- Address calculation: Use the logical block size associated with the LBA address space to calculate the byte offset.
- Alignment and performance: Physical sector boundaries can affect how efficiently the device performs writes. If the device’s logical address zero is aligned to a physical boundary, an LBA that is a multiple of eight aligns to a 4,096-byte boundary on a 512e layout. Actual alignment can also depend on device-reported offsets and transfer-granularity requirements.
Microsoft’s documentation on Advanced Format disk compatibility explains why Windows and storage applications need to account for differences between logical and physical sector sizes.
Do not use the physical sector size as a substitute for the logical block size in the basic LBA-to-byte-offset formula. They describe different aspects of the storage layout.
How LBA Is Used in MBR and GPT
LBA becomes especially useful when examining partition tables because these structures use block addresses to describe disk layout.
LBA fields in MBR
The Master Boot Record (MBR) occupies LBA 0 on an MBR-partitioned disk. Its partition table contains four 16-byte partition entries.
Each entry includes two important 32-bit fields:
StartingLBA, at byte offset 8 relative to the beginning of the partition entry, identifies the partition’s starting logical block.SizeInLBA, at byte offset 12 relative to the beginning of the partition entry, specifies the number of logical blocks in the partition.
If the partition size is nonzero, its ending LBA can be calculated as:
Ending LBA = StartingLBA + SizeInLBA − 1
For example, a partition beginning at LBA 2,048 and containing 1,000,000 logical blocks ends at LBA 1,002,047. .......。 Amagicsoft MBR partition table guide explains the partition-entry layout and how the starting address and block count determine partition boundaries.
LBA fields in GPT
The GUID Partition Table (GPT) uses LBA to locate its metadata and define partition ranges.
On a conventional GPT-partitioned disk, the layout includes:
地點 | 結構 |
LBA 0 | 保護性 MBR |
LBA 1 | Primary GPT header |
遵循 LBA | Primary partition-entry array |
可用 LBA 範圍 | 可用於隔間的空間 |
Near the end of the device | Backup partition-entry array |
最後一個 LBA | Backup GPT header |

The exact usable range depends on the disk layout, logical block size, and the locations reserved for GPT metadata.
GPT partition entries contain 64-bit StartingLBA 和 EndingLBA fields. Both boundaries are inclusive, so the number of logical blocks in a partition is:
Partition size in blocks = EndingLBA − StartingLBA + 1
The GPT header also includes PartitionEntryLBA, which identifies the starting LBA of the associated partition-entry array.
For a field-level explanation of these addresses and the primary and backup headers, see Amagicsoft’s GPT Header guide.
該官員 UEFI specification, Section 5, defines the GPT layout and its address fields. It specifies 64-bit LBAs for GPT, whereas MBR partition entries use 32-bit starting-LBA and size fields.
Why MBR and GPT have different addressing limits
With 32-bit sector-address fields, MBR has a commonly encountered capacity boundary of approximately 2 TiB when logical sectors are 512 bytes.
The arithmetic is:
2³² logical blocks × 512 bytes = 2 TiB
This is approximately 2.2 trillion bytes in decimal units. The limit comes from the address-field width and the assumed logical sector size; it is not a universal limit for every device or every possible logical block size.
GPT’s 64-bit LBA fields provide a much larger theoretical address space. Actual usable capacity still depends on the operating system, firmware, drivers, device interface, and partitioning implementation.
Microsoft’s documentation on Windows support for disks exceeding 2 TB explains the relationship between the MBR addressing limitation and GPT.
How to Check Logical and Physical Sector Information in Windows
Windows provides a command for querying sector information reported by the storage device and its driver.
- 開啟 Command Prompt。.
- 運行
fsutil fsinfo sectorinfo D:, replacingD:使用適當的磁碟機代號。. - Examine the reported logical and physical sector information.
Microsoft documents this command in Fsutil fsinfo. Its example output includes fields such as 每扇區邏輯位元組數 和 每扇區的物理位元組數(用於原子性).
For example, if the system reports LogicalBytesPerSector : 4096, a 4,096-byte logical block size is appropriate for the corresponding LBA-to-byte-offset calculation.
Compare the logical sector size with the reported physical-sector information to understand the device’s addressing and alignment characteristics. The available fields and values may vary with the Windows version, storage device, and driver.
This command queries sector information; it does not read a particular LBA’s raw contents or identify the physical location of a file. It is a useful way to verify an input needed for the calculation, not a complete disk-structure analysis.
LBA Limitations and Common Misconceptions
LBA provides a logical address, but several conclusions cannot be drawn from the address alone.
- An LBA does not identify a file. The file system’s metadata is needed to map files and their allocated clusters to the corresponding storage regions.
- An LBA is not a physical media address. On an SSD, for example, the device’s flash translation layer manages the mapping between host-visible logical addresses and internal flash storage.
- An LBA does not establish whether data is intact. A readable address, an I/O error, or a partition-table inconsistency does not by itself prove that a file is recoverable or that a drive has physical damage.
- A byte offset depends on the correct logical block size. Using an assumed 512-byte size on a device exposing 4,096-byte logical blocks produces an incorrect result.
- Address origins must match. A partition-relative address cannot be treated as a disk-relative address without accounting for the partition’s starting position and confirming the tool’s addressing convention.
These distinctions are important when diagnosing partition layouts, interpreting disk utilities, or studying file-system structures. LBA supplies the address; additional metadata and device information are needed to interpret what is stored there.
總結
Logical block addressing provides a linear way to identify logical storage blocks, but interpreting an LBA requires the correct logical block size and address-space origin. The distinction between logical and physical sectors, the differences between MBR and GPT fields, and the limitations of CHS compatibility values all affect how disk addresses should be understood. For reliable analysis, calculate offsets from verified parameters and interpret them alongside the relevant partition and file-system metadata.
常見問題
LBA 和扇區編號是一樣的嗎?
LBA 的編號是否從零開始?
N − 1, 而非 N.該如何計算 LBA 的位元組偏移量?
位元組偏移量 = LBA × 邏輯區塊大小. 例如,在邏輯區塊大小為 512 位元組的裝置上,LBA 50 始於位元組偏移量 25,600。在使用此結果之前,請先確認邏輯區塊大小。.為什麼相同的 LBA 會擁有不同的位元組偏移量?
LBA 與 CHS 之間有什麼區別?
LBA 會標示檔案的實體位置嗎?
為什麼 MBR 會有 2 TiB 的容量限制?
Windows 能否顯示特定檔案的 LBA?
fsutil fsinfo sectorinfo command reports sector information, not the LBA of a file. Locating file data requires interpreting the partition layout and file-system metadata, and the result may depend on fragmentation and the tool's address convention.Vasilii 是一位在該領域擁有約 10 年實務經驗的資料復原專家。在他的職業生涯中,他已成功解決數千個複雜的個案,包括刪除的檔案、格式化的硬碟機、遺失的磁碟分割和 RAW 檔案系統。他的專業知識涵蓋使用十六進位編輯器等專業工具的手動復原方法,以及使用復原軟體的進階自動解決方案。Vasilii 的使命是讓 IT 專業人士和一般使用者都能獲得可靠的資料復原知識,協助他們保護寶貴的數位資產。.
