SQL Server 2017 – The operating system returned the error 21

Recently, I was exploring SQL Server 2017 CTP 2.0 using SQL Server Management Studio V17. Till the time, I was restoring the databases using tsql script on the SQL Server 2017 instance, and I didn’t encounter any issue. But, When I tried to restore a database backup using GUI using SSMS V17, I encountered the below error.

The operating system returned the error ’21(The device is not ready.)’ while attempting ‘GetDiskFreeSpace’ on ‘A:\’.
The statement has been terminated. (Microsoft SQL Server, Error: 3634)

Cause

This issue happens because of SMO switched to using sys.dm_os_enumerate_fixed_drives instead of the old xp_fixeddrives to get free space information in this dialog box sequence.

Workaround

You can disable the virtual Floppy drive and CDROM drive from the Device Manager as shown below.

Once you disabled them successfully, let’s try to restore a SQL Server database backup using SSMS V17.

This time it didn’t throw any error 🙂 ! I am sure the issue will be addressed in the coming release.

Never late to explore and learn something new!

6 thoughts on “SQL Server 2017 – The operating system returned the error 21

  • Jamie Fisher

    Is this already reported to Microsoft? I’m seeing this using SSMS 17.1 and SQL 2017 CTP 2.1.

    Reply
    • Dharmendra Keshari

      Yes, it has been already reported to Microsoft. You are right. it also persists in SSMS 17.1 and SQL 2017 CTP 2.1. As per Microsoft, It will be fixed in next release.

      Reply
  • vinod

    Hi,
    I have only one option in device manager and that is DVD/CD-ROM Drives and not Floppy one.
    Without disabling SSMS gives error of free space for E:\ drive (which does not even exist) and after disabling DVD/CD option it gives error for F:\ drive, while there is no option for Floppy disk drives to disable, please tell me how do I resolve this.

    Thanks
    Vinod

    Reply
    • Dharmendra

      Vinod, pls confirm version of SSMS and SQL Server?

      Reply
      • Vinod

        Hi, Thanks for getting back.

        SSMS is 2017 and SQL Server 2017 CTP 2.1

        Reply
        • Dharmendra

          I tried to generate the scenario but didn’t encounter the issue. I would request you to use SQL Server 2017 RTM with CU4. It will fix your problem.

          Reply

Leave a comment

Your email address will not be published. Required fields are marked *