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

Troubleshooting Guide: SQL Server Error 5010 – “Log File Name Cannot Be Generated from a Raw Device”

Why This Error Happens

This error occurs when a database attach, restore, or creation operation relies on legacy raw device naming conventions, which SQL Server 2025 no longer supports for automatically generating log file names. SQL Server requires an explicit, fully qualified file name and path for the transaction log (LDF) because it cannot infer one from a raw partition or unformatted device reference. This typically happens during CREATE DATABASE, RESTORE DATABASE, or sp_attach_db operations where the original log file path is missing, malformed, or pointing to a deprecated raw device.

Step-by-Step Resolution Guide

Step 1: Identify the Operation Triggering the Error

  • Check whether the error occurs during CREATE DATABASE, RESTORE DATABASE, ALTER DATABASE, or sp_attach_db.
  • Review the SQL Server Error Log (C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG) for the exact command context surrounding Error 5010.
  • Confirm if the command omitted a FOR ATTACH clause with explicit file paths or used a legacy raw partition reference (e.g., \\.\PhysicalDriveX).

Step 2: Explicitly Specify the Log File Name and Path

  • Rewrite the command to include a MOVE clause (for restores) or explicit FILENAME parameter (for creation/attach) pointing to a valid NTFS path.
  • Example for RESTORE DATABASE:
  RESTORE DATABASE [YourDB]
  FROM DISK = 'D:\Backups\YourDB.bak'
  WITH MOVE 'YourDB_Log' TO 'D:\SQLData\YourDB_Log.ldf',
  MOVE 'YourDB_Data' TO 'D:\SQLData\YourDB_Data.mdf';
  • Example for attaching a database:
  CREATE DATABASE [YourDB] ON
  (FILENAME = 'D:\SQLData\YourDB_Data.mdf'),
  (FILENAME = 'D:\SQLData\YourDB_Log.ldf')
  FOR ATTACH;

Step 3: Validate File System Paths and Permissions

  • Confirm the target directory (e.g., D:\SQLData\) exists and is not on a raw/unformatted volume.
  • Verify the SQL Server service account (check via services.msc on Windows Server 2025) has Read/Write permissions on the folder.
  • Run icacls "D:\SQLData" in an elevated Command Prompt to confirm NT SERVICE\MSSQLSERVER has full control.

Step 4: Remove Legacy Raw Device References

  • If the database was originally created on a raw partition (common in pre-2016 SQL versions), export the data using BCP or generate a new backup from a compatible intermediate server.
  • Re-import the data into a new database explicitly created with standard .mdf/.ldf file paths on formatted NTFS volumes.

Alternative or Verification Steps

  • After applying the fix, run RESTORE VERIFYONLY FROM DISK = 'D:\Backups\YourDB.bak' to confirm the backup integrity and path validity before a full restore.
  • If the issue persists, use RESTORE FILELISTONLY FROM DISK = 'YourBackupPath' to list the original logical file names and ensure your MOVE clause matches them exactly.