Windows Server How-To
How To Delete a Corrupt Windows Server Storage Pool
When things go wrong, we turn to a PowerShell command to right the ship.
Although Windows Server storage pools have been around for long enough to be stable, things can and sometimes do go wrong. When that happens, it can be surprisingly difficult to delete a corrupt storage pool and start over.
I encountered this exact situation recently with some Windows Server 2016 machines. I had been experimenting with Storage Spaces Direct, but ended up needing my lab hardware for something else. I absentmindedly deleted the failover cluster without first removing the underlying storage spaces. After spending the better part of a day trying to figure out how to remove the now invalid storage pool, I resorted to reformatting the servers,and installed Windows from scratch. Even that, however, did not fix the problem. Ultimately the solution involved using a single PowerShell command. Before I show you the command, I want to show you what happens when you try to remove the storage pool in the usual way.
If you look at Figure 1, you can see that I have used the Get-StoragePool cmdlet to retrieve the names of the storage pools on my system. I then used the Remove-StoragePool cmdlet to attempt the removal of a storage pool named S2d on Cluster. As you can see in the figure, the removal fails because the storage pool is read only.
Since that didn't work, I decided to set the storage pool's IsReadOnly flag to False. To do so, I used the following command:
Get-StoragePool -FriendlyName MyStoragePool | Set-StoragePool -IsReadOnly $False
As you can see in Figure 2, I attempted to delete the storage pool after setting the Read Only flag to False. This time, the operation worked, as shown in Figure 2. I have to admit that I was more than a little surprised that the deletion was successful, because previous attempts had failed.
When this operation had previously failed, one of two things would generally happen. In some cases, Windows would continue to insist that the storage pool was read only. If you look back at the previous figure, you will notice that the IsReadOnly flag was set to False, but the OperationalStatus continued to be listed as Read Only.
The other thing that commonly occurred was that I received a message indicating that the storage pool could not be deleted so long as virtual disks existed within the storage pool. However, deleting virtual disks is easier said than done. If you look at Figure 3, you can see that when I attempt to delete virtual disks, I receive an error message stating that the storage pool could not complete the operation because its configuration is read-only.
If I set the storage pool to Read Only and attempt the operation again, I receive a Permission Denied error, as shown in Figure 4.
In case you are wondering what my actual storage pool configuration looks like, check out Figure 5. As you can see, the storage pool and the virtual disks are in an error state. Most of the physical disks are also shown to be in an error state, because those disks reside on a different server.
The way that I was eventually able to remove the storage pool (and the virtual disks within it) was to reference the storage pool's health status. The command that I used was:
Get-StoragePool -HealthStatus Unhealthy | Remove-StoragePool
You can see how this works in Figure 6.
As you can see, the storage pool can be removed with a single command. Once the storage pool has been deleted, the physical disks that previously resided in the pool are returned to the primordial pool.
Brien Posey is a seven time Microsoft MVP with over two decades of IT experience. As a freelance writer, Posey has written many thousands of articles and written or contributed to several dozen books on a wide variety of IT topics. Prior to going freelance, Posey was a CIO for a national chain of hospitals and healthcare facilities. He has also served as a network administrator for some of the country's largest insurance companies and for the Department of Defense at Fort Knox. When He isn't busy writing, Brien Posey enjoys exotic travel, scuba diving, and racing his Cigarette boat. You can visit his personal Web site at: www.brienposey.com.