Share via


The operating system returned error 21

Question

Saturday, August 15, 2020 7:02 AM

The operating system returned error 21(The device is not ready.) to SQL Server during a read at offset 0x00000000440000 in file 'T:\Trans\ReportServer.mdf'. Additional messages in the SQL Server error log and system event log may provide more detail. This is a severe system-level error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check (DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online.

How do I correct this issue?

USE

master;

SELECT

name'Logical Name',

physical_name

'File Location'

FROM

sys.master_files;

Logical Name File Location
ReportServer T:\Trans\ReportServer.mdf
ReportServer_log F:\Log\ReportServer_log.ldf

There is no  T:\Trans\ReportServer.mdf path in the database server

All replies (8)

Saturday, August 15, 2020 9:11 PM ✅Answered | 1 vote

The database server was comprised from ransomware and could not be restored. So we had to manually mount the databases to the server. In Older server  there was a T: drive. New server does not have that drive. How do I fix the older pointer? It is the only database it is complaining about from what I see is the report server database.

So why did you not tell us originally about the ransomware attack and what happened afterwards? When you ask a question, please always give background information. It you only tell us what you said in the first post, you cannot get any useful answer.

From what you say, it seems that you need to restore a backup. When you restore a backup, you can use the WITH MOVE clause to put the files where you want them. You may also have to use the REPLACE clause. That is:

RESTORE DATABASE db FROM DISK = '<path>'
WITH MOVE 'db' TO '<newpath>.mdf',
     MOVE 'db_log' TO '<newpath>.ldf',
     REPLACE

Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se


Sunday, August 16, 2020 2:40 PM ✅Answered

Hi @Avyayah

There  is a registry mapping .

HKLM\Software\Microsoft\MicrosoftSQL Server\MSSQL{nn}.MyInstance

Thanks and regards


Monday, August 17, 2020 6:02 AM ✅Answered

Hi Avyayah,

Is there any update on this case? Was your issue resolved?

Please check:

Restore a Database to a New Location (SQL Server)

Best regards,
Cris

""SQL Server related"" forum will be migrated to a new home on Microsoft Q&A SQL Server!
We invite you to post new questions in the "SQL Server related" forum’s new home on Microsoft Q&A SQL Server !
For more information, please refer to the sticky post.


Saturday, August 15, 2020 7:20 AM

check physically T drive is present on server.

you can see drives using following query.

xp_fixeddrives

https://social.technet.microsoft.com/wiki/contents/articles/37872.sql-server-installation-on-centos-linux.aspx


Saturday, August 15, 2020 8:10 AM

If sys.master_files says that there are database files that are supposed to be on the T: drive, but there is no T: drive, you obviously have a problem.

You will need to go and find it. Hopefully you have some idea where there T: drive used to be. For instance, if it used to be on a SAN, you need to talk the SAN people.

Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se


Saturday, August 15, 2020 1:31 PM

xp_fixeddrives

there is no T drive. Is there any other way to generate Report server database.


Saturday, August 15, 2020 2:44 PM

The database server was comprised from ransomware and could not be restored. So we had to manually mount the databases to the server. In Older server  there was a T: drive. New server does not have that drive. How do I fix the older pointer? It is the only database it is complaining about from what I see is the report server database.


Saturday, August 15, 2020 3:01 PM

First of all, check which DB actually trying to use the file.

SELECT DB_NAME(DBID), FILENAME  AS DATABASENAME,FILENAME FROM SYSALTFILES 
WHERE FILENAME LIKE '%T:\Trans\ReportServer.mdf%'

This will give you the DB name which tried to use the location, if you smaller list on the instance, check which DB is in Recovery Pending as the drive is not available on the new server.

I assume you will be having your old data file which was hosted on T drive i.e. ReportServer.mdf

So copy the file to new data file location for example let me guess your location is like "F:\Data\

Then move the file logically in system meta data with below command.

ALTER DATABASE [DBName] 

MODIFY FILE ( NAME = LogicalFileName, FILENAME = 'F:\Data\ReportServer.mdf')

Logical file name you can get from below query

SELECT DB_NAME(DBID) AS DATABASENAME,name as LogicalFileName,FILENAME FROM SYSALTFILES 
WHERE FILENAME LIKE '%T:\Trans\ReportServer.mdf%'

Once you have run this , then your query database location will be moved to new one logically and validate the same.

SELECT DB_NAME(DBID), FILENAME  AS DATABASENAME,FILENAME FROM SYSALTFILES 
WHERE FILENAME LIKE '%ReportServer.mdf%'

If this shows new valid location, you are good to start the DB now.

ALTER DATABSE DBName SET ONLINE

This will try to start the DB from new location.

Below link will help if you need assistance on moving files.

https://sqltechuniverse.wordpress.com/2020/08/13/how-to-move-a-user-database-file-from-one-location-to-another/  

Thanks,

Sreekanth Madambath

If this fixed your query, please mark as answer.