共用方式為


針對與大於 4 KB 的系統磁碟扇區大小相關的錯誤進行疑難解答

本文提供在 Windows 上安裝或啟動 SQL Server 實例期間針對錯誤進行疑難解答的解決方案。 本文適用於所有發行的 SQL Server 版本。

本文討論與大於 4 KB 的系統磁碟扇區大小相關的錯誤。 當您嘗試在系統磁碟扇區大小大於 4 KB 的電腦上安裝 SQL Server 實例時,可能會遇到下列情況:

適用於:SQL Server 所有版本

案例 1:將檔案移至具有相容扇區大小的磁碟區

如果您嘗試使用大於 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.

案例 2:找不到資料庫引擎啟動句柄

當您嘗試在執行 Windows 的 Azure 虛擬機 (VM) 上安裝 SQL Server 實例時,安裝會失敗,並在引擎嘗試在安裝期間啟動時,在 SQL Server 錯誤記錄檔中收到下列錯誤訊息:

無法使用檔案 『...\master.mdf』,因為它原本是以扇區大小 4096 格式化,現在位於扇區大小為 8192 的磁碟區上。 請將檔案移至與原來磁區大小相同或較小的磁碟區上。

此外,您可以在 SQL Server 安裝程式資料夾中Summary.txt記錄檔中看到下列資訊:

Detailed results:
  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:          0x851A0019
  Error description:             Could not find the Database Engine startup handle.

如需詳細資訊,請參閱 SQL Server 安裝失敗,並在 Windows Server 2022 Azure 虛擬機上發生扇區大小錯誤

案例 3:等待資料庫引擎復原控制碼失敗

當您安裝任何版本的 SQL Server 時,您會看到類似 SQL Server Database Engine 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.

案例 4:有 256 個未對齊的記錄 IO 需要回復到同步 IO

您可以在 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. 

案例 5

您可以在 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 

案例 6:將檔案移至扇區大小與原始扇區大小相同或小於原始扇區大小的磁碟區

您在 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 實例,您可能會遇到先前案例中所提及的失敗。

原因

在服務啟動期間,SQL Server 會開始資料庫復原程式,以確保資料庫一致性。 在嘗試開啟系統和使用者資料庫檔案之前,該資料庫復原過程的一部分涉及對底層檔案系統進行一致性檢查。

某些新的儲存設備和設備驅動器顯示的磁碟扇區大小大於支援的 4-KB 扇區大小。

發生此問題時,由於不支援的文件系統,SQL Server 無法啟動,因為 SQL Server 目前支援 512 位元組和 4 KB 的磁區記憶體大小。

您可以執行 命令來確認您遇到此特定問題:

fsutil fsinfo sectorinfo <volume pathname>

例如,若要分析 E: 磁碟區,請執行下列命令:

fsutil fsinfo sectorinfo E:

尋找以位元組為單位傳回的值 PhysicalBytesPerSectorForAtomicityPhysicalBytesPerSectorForPerformance,如果值不同,請保留 最大的 值,以確定磁碟扇區大小。 值為 4096 表示磁區記憶體大小為 4 KB。

此外,請注意文件系統和記憶體扇區大小的 Windows 支持原則。 如需詳細資訊,請參閱 Windows 一文中 4 KB 扇區硬碟的Microsoft支持原則。

備註

沒有發行版本的 SQL Server 與大於 4 KB 的扇區大小相容。 如需詳細資訊,請參閱 SQL Server 中的硬碟扇區大小支援界限一文。

決議

  • 目前,若使用提供大於 4 KB 扇區大小的新式儲存平台,例如 NVMe,需要 ForcedPhysicalSectorSizeInBytes 登錄機碼才能成功安裝 SQL Server。 此 Windows 作業系統的登錄機碼會將扇區大小強制模擬為 4 KB。

    若要新增ForcedPhysicalSectorSizeInBytes登錄機碼,請使用註冊表編輯器,或依照命令提示字元PowerShell 一節中的說明執行命令。 此案例不需要新增追蹤旗標 1800。

    重要

    本節包含的步驟會告訴您如何修改 Windows 登錄。 然而,不當修改登錄可能會發生嚴重的問題。 因此,請務必小心執行下列步驟。 為增加保護起見,請先備份登錄,再進行修改。 如此一來,您就可以在發生問題時還原登錄。 如需如何備份和還原登錄的詳細資訊,請參閱 如何在 Windows 中備份和還原登錄一文。

    1. 以系統管理員身分執行註冊表編輯器。
    2. 瀏覽至 Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\stornvme\Parameters\Device
    3. 選擇 編輯>新的>多重字串值,並將其命名為 ForcedPhysicalSectorSizeInBytes
    4. 以滑鼠右鍵按下名稱,選取 [修改],然後在 [* 4095] 字段中輸入
    5. 選取 [ 確定 ],然後關閉 [註冊表編輯器]。

    您必須在新增登錄機碼之後重新啟動裝置,此變更才會生效。

  • 如果您未新增登錄機碼,而且在此系統上有多個磁碟驅動器,您可以在安裝 SQL Server 完成之後,為資料庫檔案指定不同的位置。 請確定磁碟驅動器會在查詢 fsutil 命令時反映支援的扇區大小。 SQL Server 目前支援 512 個字節和 4,096 個字節的扇區記憶體大小。

謹慎

如果您已建立具有扇區大小大於 4 KB 的磁碟來裝載 SQL Server 檔案的存放集區,您必須先移除存放集區、套用本文所述的其中一個疑難解答方法,然後再嘗試在存放集區或集區上安裝 SQL Server 之前重建存放集區。

其他相關資訊

Windows 11 原生 NVMe 驅動程式已更新,以包含 NVMe 儲存裝置直接回報的實際扇區大小。 這樣做是為了而非依賴從文件系統驅動程式模擬的資訊。

Windows 10 驅動程式不會報告實體記憶體的來源扇區大小。

改良的 Windows 11 驅動程式會忽略通用 NVMe 儲存裝置所使用的模擬。 例如, fsutil 顯示扇區大小 8 KB 或 16 KB,而不是模擬 Windows 所需的 4 KB 扇區大小。

下表提供各作業系統所報告的扇區大小的比較。 此範例說明使用相同儲存裝置的 Windows 10 與 Windows 11 之間的差異。 針對PhysicalBytesPerSectorForAtomicityPhysicalBytesPerSectorForPerformance的值,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