Disk offline with error – the disk is offline because of a policy set by an administrator

In my home environment I tried to add a VHD disk to one of my virtual machines.
I was surprised to see that, even after deletion and re-add of the disk, the disk remained with a status of “offline” and would not come online. To make it even stranger, the only option I saw when right-clicking on the disk in Disk Management, was “Help”.

 

Now what could have been the cause of this issue? The disk was alright, because when I added it to a Windows Server 2003 machine, it worked perfectly! Perhaps somehow my virtual SCSI controller experienced some problems? No, because when I added the disk to an IDE controller the issue remained.

 

image
Now here comes the fun part. When I hoover over the exclamation mark on Disk 1, I saw the following message: “the disk is offline because of a policy set by an administrator”.
Say what?! The user and server had no policies set on them; none whatsoever!

 

Troubleshooting
Open a command prompt and type “diskpart.exe”.
You will now receive a diskpart-prompt:
Diskpart>

Now type “san”. This will provide you with the current configured SAN policy:

 

SAN Policy : Offline Shared

So this means that the system was right… there was a policy configured… but I didn’t configure it, did I? Anyway, back to solving the issue.

 

The Solution
In the diskpart-prompt, type “san policy=OnlineAll”.
This will result in the following message:
Diskpart successfully changed the SAN policy for the current operating system.

 

Now type “list disk”, which will give this message:

Disk ### Status Size Free Dyn Gpt
Disk 0 Online 30 GB 0 B
Disk 1 Offline 50 GB 1024 KB

In my case, disk 1 was offline so I typed “select disk 1” which provided:
Disk 1 is now the selected disk

 

Now type “attributes disk clear readonly”.
Disk attributes cleared successfully.
And to check if all the settings are now correct, type “attributes disk”.
This will give an output something like:

Current Read-only State : No
Read-only : No
Boot Disk : No
Pagefile Disk : No
Hibernation File Disk : No
Crashdump Disk : No
Clustered Disk : No

After the last check has been successful, type “online disk” to bring the disk online.

The disk should be available right away in Disk Management. If not the case, close and re-open Disk Management.

 

The cause
After I’ve found the solution I started searching on the internet. It seems that Microsoft has decided to change how disks are handled as of Windows Server 2008 Enterprise/DataCenter. The default SAN disk policy is now VDS_SP_OFFLINE_SHARED, with an exception for the boot-disk.

 

31 comments

  1. kjetilpp says:

    TNX 😀 You saved my day

  2. Msbhatti19 says:

    Thank you alots

  3. jc says:

    thank you very much

  4. bobo says:

    This works !!! thanks so much

  5. aditya says:

    Yay! I had to move a drive from a Win XP to a Win 7 machine and this is exactly what happened. Strangely, the policy was already “online all”, but teh disk was set to read only (after the move). Your steps solved the problem instantly! Just had to manually unset the readonly flag, add a drive letter and all the data was still there and things work just fine. Thanks very much 🙂

  6. Ricardo says:

    Thanks for the helpful guide

  7. David says:

    Excellent, thanks – everything worked exactly as described

  8. leo.jiang says:

    Thanks!

  9. ngoc says:

    After command “attributes disk clear readonly”, Windows display “Diskpart failed to clear disk attribute”
    How solution? Thank you for your help

  10. Jeff Wouters says:

    Hi Ngoc,
    I’ve only seen such behaviour when a cluster disk is involved. When the command is executed on a cluster node that’s not the owner of the disk, and the disk is not currently active on that node, the error you’ve written about is provided. What is the output of the ‘attributes disk’ command?
    Jeff.

  11. dekale says:

    brilliant – thanks!

  12. Allan says:

    wow. finally some1 who knows their shit! This fixed it for me, ( for some reason my x-drive had been set to “read only”), and couldn’t be brought online again. Works on windows 7. Thx alot man.

  13. Jeff Wouters says:

    Thanks you for the compliment!
    Happy to read the content of the post helped you 🙂

  14. Alen says:

    Excellent !!! well written and practical procedure that really works !!! worked on my Hyper-V 2012 core server !!! I was then able to format and assign a drive letter to the new Hard Disk via remote Server Manager through Computer Management console !!!

  15. Jeff Wouters says:

    Happy I could help 🙂

  16. Dan says:

    Thanks for the excellent article! I followed your article, but when I restarted the disk management cpl. It wanted me to initialize the disk. I think this will erase the data on the disk. If this is true, is there a way to work around that? We have a large amount of data on this disk.

  17. David says:

    Hi there, question about the command san policy=OnlineAll, will this online ALL offline disks? My cluster had numerous disks, online and offline and I don’t want ALL of them online to remedy the 4 that are in the read only state. I just don’t want to run this command and trash the entire thing. I cannot find anything talking about this, just to run it.

    Thanks

  18. Allan Bean says:

    Brilliant!! Thanks so much Jeff – saved me a load of time.

    The question is why on earth would Microsoft decide that this was a good idea?? And where is the documentation? Or at least some kind of meaningful/helpful error message?

    Yours was the best result on a google search that made any real sense – the Microsoft websites as always were just reams of unintelligible or totally irrelevant garbage!

    Yours is an excellent blog, clearly written and easily understandable. Well done! (and shame on Microsoft!)

  19. anna says:

    muchas gracias, me ayudo!

  20. Jeff, good post! I created an AWS Linux instance with some test data, formatted a volume in windows server 2012, attached it to Linux to copy the data over, then reattached it to windows and got this error.

    Thanks for the simple, quick solution that solved my problem.

  21. Jeff Wouters says:

    Hi David,
    You’re welcome, happy I could help 🙂
    Jeff.

  22. evane says:

    Thanks budy ..
    fix my way

  23. Fred says:

    I love posts like these – exact problem with an exact solution.

    Saved me hours of frustration, I’m sure.

    Thanks!

  24. Rick says:

    Thank you very much! Excellent instructions.

  25. Patrick says:

    Thank you very much for posting this!

  26. Nabin Bogati says:

    Says disk part failed to clear disk attributes

  27. Joo says:

    Worked great for me – many thanks. Not using a SAN, but connecting a persistent drive from Server 2012 R2 to a Synology NAS.

    Many thanks for the write-up.

  28. Adil says:

    Thanks! This saved a lot of time for me.

  29. pekun says:

    Great one Jeff, you saved my ass.
    The step by step solution was just perfect, when the disks came up, it then became unallocated and could not format and could not also assign driver letter.
    Advice on likely solution.

  30. katie v says:

    Hi Jeff,
    when i got to the par of~
    Now type “attributes disk clear readonly”.
    it said
    DiskPart failed to clear disk
    NOT
    Disk attributes cleared successfully.

    it seems i have a similar problem of
    ngoc says:
    February 5, 2013 at 09:18
    After command “attributes disk clear readonly”, Windows display “Diskpart failed to clear disk attribute”
    How solution? Thank you for your help
    Jeff Wouters says:
    February 6, 2013 at 08:34
    Hi Ngoc,
    I’ve only seen such behaviour when a cluster disk is involved. When the command is executed on a cluster node that’s not the owner of the disk, and the disk is not currently active on that node, the error you’ve written about is provided. What is the output of the ‘attributes disk’ command?
    Jeff.

    I’m not sure how to answer your question of “what is the output of the ‘attributes dis’ command?”

    Thanks in advance for your help!!!

    Katie
    Disk attributes cleared successfully.

  31. Ben Tam says:

    When I type “list disk”, it shows
    disk 0: online
    disk 1: offline

    I follow your instructions one by one. All are successful except the one “attributes disk clear readonly”. Then I check with the command “attributes disk” and I find that the disk is already “readonly”.

    When I type “list disk”, It still shows
    disk 0: online
    disk 1: offline

    Any suggestion?

Leave a Reply

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