How to fix Error 9012 on Windows Server 2025 / Windows 11

Troubleshooting Guide: SQL Server Error 9012 – Misaligned Log IOs Requiring Synchronous Fallback

Why This Error Happens

This warning occurs when SQL Server’s transaction log writes are not aligned to the underlying storage sector boundaries, forcing the Database Engine to abandon faster asynchronous (unbuffered) I/O and fall back to slower synchronous I/O. It is typically caused by a mismatch between the disk’s physical/logical sector size (often 4K Advanced Format drives) and the NTFS allocation unit size used when the volume was formatted. This is also commonly seen on virtualized storage, SAN LUNs, or Storage Spaces Direct (S2D) volumes where the reported sector size changes after a firmware update, driver update, or storage migration.

Step-by-Step Resolution Guide

Step 1: Identify the Affected Volume and Current Sector Size

  • Open PowerShell as Administrator and run Get-Disk | Select Number, FriendlyName, LogicalSectorSize, PhysicalSectorSize to check sector sizes.
  • Cross-reference the file path reported in the Error 9012 message (the %ls placeholder) to determine which physical disk hosts the .ldf log file.
  • Check fsutil fsinfo ntfsinfo D:\ (replace D:\ with your log drive) to confirm the “Bytes Per Cluster” value.

Step 2: Reformat the Volume with the Correct NTFS Allocation Unit Size

  • Back up or move the database log files to temporary storage before proceeding, as reformatting is destructive.
  • In Disk Management or via PowerShell, reformat the target volume with a 64 KB allocation unit size, which is the Microsoft-recommended setting for SQL Server log and data files: Format-Volume -DriveLetter D -FileSystem NTFS -AllocationUnitSize 65536 -Confirm:$false
  • Ensure the allocation unit size is an even multiple of the disk’s physical sector size (commonly 4096 bytes) to guarantee write alignment.

Step 3: Move the Transaction Log File Back and Reattach

  • Detach the database or take it offline via SQL Server Management Studio (SSMS): ALTER DATABASE [YourDB] SET OFFLINE;
  • Copy the .ldf file back to the newly formatted volume and update the file path: ALTER DATABASE [YourDB] MODIFY FILE (NAME = YourDB_log, FILENAME = 'D:\Logs\YourDB_log.ldf');
  • Bring the database back online: ALTER DATABASE [YourDB] SET ONLINE;

Step 4: Update Storage Drivers and Firmware

  • Check Windows Update and the storage vendor’s site (e.g., Dell, HPE, or the SAN/virtualization platform vendor) for updated storage controller drivers, as mismatched firmware frequently causes reported sector-size changes mid-operation.
  • Restart the Windows Server 2025 host after driver updates and re-verify sector size reporting with Get-PhysicalDisk | Get-StorageReliabilityCounter.

Step 5: Adjust SQL Server I/O Configuration if Needed

  • If reformatting is not immediately possible, apply trace flag 1800 at SQL Server startup, which forces the log writer to align I/O to 4K boundaries regardless of underlying sector size.
  • Add -T1800 to the SQL Server service startup parameters via SQL Server Configuration Manager, then restart the SQL Server service.

Alternative or Verification Steps

  • Monitor the SQL Server Error Log and Windows Event Viewer (Application log) for a period of 24-48 hours to confirm Error 9012 no longer appears.
  • Run SELECT * FROM sys.dm_io_virtual_file_stats(DB_ID('YourDB'), NULL); to confirm I/O stall times have decreased, indicating the log writes are now using asynchronous I/O correctly.