針對與大於 4 KB 的系統磁碟扇區大小相關的錯誤進行疑難解答
本文提供在 Windows 上安裝或啟動 SQL Server 實例期間針對錯誤進行疑難解答的解決方案。 本文適用於所有發行的 SQL Server 版本。
本文所討論的錯誤與大於 4 KB 的系統磁碟扇區大小有關。
適用於:SQL Server 所有版本
徵狀
案例 #1: 您安裝任何版本的 SQL Server。 然後,您會看到類似 SQL Server 資料庫引擎 Services 元件的下列訊息:
Feature: Database Engine Services
Status: Failed
Reason for failure: An error occurred during the setup process of the feature.
Next Step: Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
Component name: SQL Server Database Engine Services Instance Features
Component error code: 0x851A001A
Error description: Wait on the Database Engine recovery handle failed. Check the SQL Server error log for potential causes.
或者,您會在 SQL Server 錯誤記錄檔中看到類似下列的錯誤:
2025-02-26 20:01:16.79 spid14s Starting up database 'master'.
2025-02-26 20:01:16.80 spid14s Error: 5178, Severity: 16, State: 1.
2025-02-26 20:01:16.80 spid14s Cannot use file 'C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\DATA\master.mdf' because it was originally formatted with sector size 4096 and is now on a volume with sector size 8192. Move the file to a volume with a sector size that is the same as or smaller than the original sector size.
案例 #2: 您可以在 Windows 10 裝置上安裝任何版本的 SQL Server。 然後,您會將裝置上的OS升級至 Windows 11。 當您嘗試在 Windows 11 裝置上啟動 SQL Server 時,服務無法啟動,而且在 SQL Server 錯誤記錄檔中,您會注意到類似下列專案:
2021-11-05 23:42:47.14 spid9s There have been 256 misaligned log IOs which required falling back to synchronous IO. The current IO is on file C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\master.mdf.
案例 #3: 您在 Windows 10 裝置上安裝任何版本的 SQL Server。 然後,您會將裝置上的OS升級至 Windows 11。 當您嘗試在 Windows 11 裝置上啟動 SQL Server 時,服務無法啟動。 在 SQL Server 錯誤記錄檔中,您會注意到類似下列專案:
Faulting application name: sqlservr.exe, version: 2019.150.2000.5, time stamp: 0x5d8a9215
Faulting module name: ntdll.dll, version: 10.0.22000.120, time stamp: 0x50702a8c
Exception code: 0xc0000005
Fault offset: 0x00000000000357ae
Faulting process id: 0x1124
Faulting application start time: 0x01d7bf67449d262c
Faulting application path: C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\Binn\sqlservr.exe
Faulting module path: C:\Windows\SYSTEM32\ntdll.dll
案例 #4: 您在 Windows 11 裝置上安裝 LocalDB。 安裝程式失敗,而且在 SQL Server 錯誤記錄檔中,您會注意到類似下列專案:
2021-12-15 23:25:04.28 spid5s Cannot use file 'C:\Users\Administrator\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\TestInstance\master.mdf' because it was originally formatted with sector size 4096 and is now on a volume with sector size 16384. Move the file to a volume with a sector size that is the same as or smaller than the original sector size.
在 Windows 11 應用程式事件記錄檔中,您會注意到類似下列專案:
Message : Windows API call WaitForMultipleObjects returned error code: 575. Windows system error message is: {Application Error}
The application was unable to start correctly (0x%lx). Click OK to close the application.
Reported at line: 3621.
Source : SQLLocalDB 11.0
注意事項
針對您手動安裝的 SQL Server 實例,或應用程式所安裝的 LocalDB 實例,您可能會遇到先前案例中所提及的失敗。
案例 #5: 如果您嘗試使用大於 4 KB 的扇區大小,您會看到下列錯誤訊息:
Error: 5179, Severity: 16, State: 1.
Cannot use file 'data file path', because it is on a volume with sector size 8192. SQL Server supports a maximum sector size of 4096 bytes. Move the file to a volume with a compatible sector size.
原因
在服務啟動期間,SQL Server 會開始資料庫復原程式,以確保資料庫一致性。 此資料庫復原程式的一部分牽涉到基礎文件系統上的一致性檢查,再嘗試開啟系統和使用者資料庫檔案。
某些新的儲存設備和設備驅動器會公開大於支援的 4 KB 扇區大小磁碟扇區大小。
發生此情況時,由於不支援的文件系統,SQL Server 目前支援 512 位元組和 4 KB 的磁區記憶體大小,因此無法啟動 SQL Server。
您可以執行 命令來確認您遇到此特定問題:
fsutil fsinfo sectorinfo <volume pathname>
例如,若要分析 E: 磁碟區,請執行下列命令:
fsutil fsinfo sectorinfo E:
尋找以位元組為單位傳回的值 PhysicalBytesPerSectorForAtomicity
和 PhysicalBytesPerSectorForPerformance
,如果值不同,請保留 最大的 值,以確定磁碟扇區大小。 值為 4096 表示磁區記憶體大小為 4 KB。
此外,請注意文件系統和記憶體扇區大小的 Windows 支持原則。 如需詳細資訊,請參閱 Windows 一文中 4 KB 扇區硬碟的Microsoft支持原則。
注意事項
沒有發行版本的 SQL Server 與大於 4 KB 的扇區大小相容。 如需詳細資訊,請參閱 SQL Server 中的硬碟扇區大小支援界限一文。
解決方法
目前,在使用 NVMe 等新式儲存平臺時,
ForcedPhysicalSectorSizeInBytes
需要登錄機碼才能成功安裝 SQL Server,以提供大於 4 KB 的扇區大小。 此 Windows作系統登錄機碼會強制扇區大小模擬為 4 KB。 若要新增ForcedPhysicalSectorSizeInBytes
登錄機碼,請使用註冊表編輯器或執行命令,如命令提示字元或 PowerShell 一節中所述。 您必須在新增登錄機碼之後重新啟動裝置,此變更才會生效。 此案例不需要新增追蹤旗標 1800。重要
本節包含的步驟會告訴您如何修改 Windows 登錄。 然而,不當修改登錄可能會發生嚴重的問題。 因此,請務必小心執行下列步驟。 為增加保護起見,請先備份登錄,再進行修改。 如此一來,您就可以在發生問題時還原登錄。 如需如何備份和還原登錄的詳細資訊,請參閱 如何在 Windows 中備份和還原登錄一文。
- 以系統管理員身分執行註冊表編輯器。
- 瀏覽至
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\stornvme\Parameters\Device
。 - 選取 [編輯>新的>多重字串] 值,並將其命名為 。
ForcedPhysicalSectorSizeInBytes
- 以滑鼠右鍵按下名稱,選取 [修改],然後在 [值資料] 字段中輸入
* 4095
。 - 選取 [ 確定 ],然後關閉 [註冊表編輯器]。
如果您未新增登錄機碼,而且在此系統上有多個磁碟驅動器,您可以在安裝 SQL Server 完成之後,為資料庫檔案指定不同的位置。 請確定磁碟驅動器會在查詢
fsutil
命令時反映支援的扇區大小。 SQL Server 目前支援 512 個字節和 4,096 個字節的扇區記憶體大小。
其他相關資訊
Windows 11 原生 NVMe 驅動程式已更新,以包含 NVMe 儲存裝置直接回報的實際扇區大小。 這是完成的,而不是依賴從文件系統驅動程式仿真的資訊。
Windows 10 驅動程式不會報告實體記憶體的來源扇區大小。
改良的 Windows 11 驅動程式會忽略通用 NVMe 儲存裝置所使用的模擬。 例如, fsutil
顯示扇區大小 8 KB 或 16 KB,而不是模擬 Windows 所需的 4 KB 扇區大小。
下表提供作系統所報告的扇區大小比較。 此範例說明使用相同儲存裝置的 Windows 10 與 Windows 11 之間的差異。 針對 和PhysicalBytesPerSectorForPerformance
的值PhysicalBytesPerSectorForAtomicity
,Windows 10 會顯示 4 KB,而 Windows 11 會顯示 16 KB。
的範例輸出 fsutil fsinfo sectorinfo <volume pathname>
Windows 10 | Windows 11 |
---|---|
LogicalBytesPerSector : 512 |
LogicalBytesPerSector : 512 |
PhysicalBytesPerSectorForAtomicity : 4096 |
PhysicalBytesPerSectorForAtomicity : 16384 |
PhysicalBytesPerSectorForPerformance : 4096 |
PhysicalBytesPerSectorForPerformance : 16384 |
FileSystemEffectivePhysicalBytesPerSectorForAtomicity : 4096 |
FileSystemEffectivePhysicalBytesPerSectorForAtomicity : 4096 |
Device Alignment : Aligned (0x000) |
Device Alignment : Aligned (0x000) |
Partition alignment on device : Aligned (0x000) |
Partition alignment on device : Aligned (0x000) |
No Seek Penalty |
No Seek Penalty |
Trim Supported |
Trim Supported |
Not DAX capable |
Not DAX capable |
Not Thinly-Provisioned |
Not Thinly-Provisioned |