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.

[Click on image for larger view.] Figure 1. Removing a storage pool in the usual way does not work.

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.

[Click on image for larger view.] Figure 2. I was able to delete the storage pool.

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.

[Click on image for larger view.] Figure 3. Windows won't allow the virtual disks to be removed.

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.

[Click on image for larger view.] Figure 4. Even setting the IsReadOnly flag to False does not allow me to remove the virtual disks.

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.

[Click on image for larger view.] Figure 5. Here is what my storage pool looks like.

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.

[Click on image for larger view.] Figure 6. I was able to successfully remove the storage pool.

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.

About the Author

Brien Posey is a 22-time Microsoft MVP with decades of IT experience. As a freelance writer, Posey has written thousands of articles and 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 health care 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. In addition to his continued work in IT, Posey has spent the last several years actively training as a commercial scientist-astronaut candidate in preparation to fly on a mission to study polar mesospheric clouds from space. You can follow his spaceflight training on his Web site.

Featured

comments powered by Disqus

Subscribe on YouTube