Windows Storage Spaces – Remove physical disk from storage pool with PowerShell

I have an Intel NUC with 8 GB as media center and Hyper-V host for a test domain controller. I attached 2 physical external disks (1x 2,5″ USB 3, 1x 3,5″ USB 2) and created a storage pool. A couple of weeks later, I bought a new 2,5″ USB 3 disk with 1 TB to replace the older USB 2.0 disk. That disk is a lot quieter than the older one.

First, attach the new disk and make sure it’s added to your storage pool. You can’t remove the physical disk from the console when it’s in use. The only option is to rename a disk:Remove-PhysicalDisk-1

Remove physical disk from the storage pool with PowerShell

Open PowerShell (as Administrator) and paste the following code:

Get-PhysicalDisk

Remove-PhysicalDisk-2

As you can see, my drives are in a healthy state and operational. We need the FriendlyName of the device. You can use -AutoSize after ft or just use FriendlyName:

Get-PhysicalDisk | ft FriendlyName

Remove-PhysicalDisk-3

Copy the FriendlyName of the Physical Drive you want to remove from the storage pool and use the following code:

Set-PhysicalDisk -FriendlyName “<DeviceName>” -Usage Retired

Remove-PhysicalDisk-4

We have to repair the Virtual Disks on the drives, because some Virtual Disks are maybe located on the retired drive. Firstly, make sure you know the name of the Virtual Disk:

Get-VirtualDisk

Remove-PhysicalDisk-5

If your Virtual Disk names are too long for the output, you can use

Get-VirtualDisk | ft -AutoSize

Copy the FriendlyName of the first Virtual Disk and type:

Repair-VirtualDisk -FriendlyName “YourVirtualDisk”

Do this for every Virtual Disk in the storage pool. Some repairs are quick, because the Virtual Disk was not located on the drive or was very small.

Open a new PowerShell window to monitor the repairs with

Get-StorageJob

Remove-PhysicalDisk-6

Last but not least: remove the PhysicalDisk if all repairs are successfully done. Make sure that your drive is in the output of the following command:

Get-PhysicalDisk | Where-Object { $_.Usage -eq ‘Retired’}

Remove-PhysicalDisk-7

Assign the disk to a variable:

$DiskToRemove = Get-PhysicalDisk | Where-Object { $_.Usage -eq ‘Retired’}

Find the name of the storage pool:

Get-StoragePool

Remove-PhysicalDisk-8

Delete the physical disk from the storage pool:

Remove-PhysicalDisk -PhysicalDisks $DiskToRemove -StoragePoolFriendlyName “Storage pool”

This should work! Your drive should now be deleted.

Troubleshooting

Remove-PhysicalDisk: One of the physical disks specified could not be removed because it is still in use.

Remove-PhysicalDisk-12

If the Remove-PhysicalDisk command doesn’t work, try to remove the disk when the device is turned off, so you can see which virtual disk is using the physical drive. Turn the device off and attach the drive. I had a simple storage space on the old hard disk. I had to delete that storage space manually before the command above worked.

 

22 thoughts on “Windows Storage Spaces – Remove physical disk from storage pool with PowerShell

  1. Do you have a “Simple” storage space or a “Parity” storage space? I’m looking for something to remove drives from my simple storage space without losing data.

    Like

  2. I have >3TB available in my pool and i want to remove a drive holding 2,73TB. I did all the cammands… as discribed two repairs took over 5h, so i think i copied alot… but still i get:
    Remove-PhysicalDisk : One of the physical disks specified could not be removed because it is still in use.

    what shud i do…
    regards

    ps. sorry for bad english 😉

    Like

  3. I have done it all. The troubleshooting is a bit unclear. Are you suggesting put the old failed drive back in the enclosure?? I don’t have any free sata ports left on the Motherboard!

    Like

    • Hi William,

      Try to remove (unplug) the harddisk when your server/PC is turned off, and turn the server/pc back on. Then you know which virtual disk is actually using the drive. Turn the device (server/pc) off again and plug the harddisk back in. Migrate the data from the virtual disk that is in use to another virtual disk and remove the old virtual disk. My virtual disk was quite small, so I was able to migrate the data to another virtual disk.

      Is that possible for your environment?

      Like

      • THANKS so much for the reply. I have done all the tricks and tips from every article I could find including Jose Barreto’s blog. http://blogs.technet.com/b/josebda/archive/2014/04/01/step-by-step-for-mirrored-storage-spaces-resiliency-using-powershell.aspx When I started this whole debacle I had like TRULY Just a Bunch Of Disks!! 1- 4Tb, 2- 500Gb, 1- 1Tb(which is the one that went bad), and 1- 2Tb. I used the TechNet article https://technet.microsoft.com/en-us/library/dn782852.aspx and Brien Posey’s https://redmondmag.com/Articles/2014/10/23/Rebuild-Windows-Storage-Spaces.aspx?Page=2 to use as the main guides. I put another 4Tb in checked firmware and all the stuff mentioned by everyone. Brien even was kind enough LIKE YOURSELF to answer an email and suggested the “trick” of running the PS commands which fail then immediately use Storage Spaces GUI to right click and “remove” the Physical Disk……. NO DICE I canNOT get rid of that sucker no matter what. As you suggest it IS already removed from the computer and it’s under my arm as we speak. I KNOW someone somewhere out there HAS the magic command to make it go away and allow the Virtual Disk(which shows up) to “attach) there WAS another Virtual Disk and it has attached just peachy. There was nothing special about the other one. I had an issue with an “object” that couldn’t be removed while fooling around with the new Remote Desktop on 2012R2 and emailed Freek Bearson about it. He knew of it like everybody knows about this Physical Disk not removing deal but I managed to somehow get through to a MS Engineer who gave me a WMI script to run through the WMI Management console and sure enough: gone!! I DID use thin provisioning which I now read some bad things about. There was only a total of 576Gb of data so space is not the issue. I’m luckier than most in that I DO have a DPM backup of the Virtual Volume that is only 2 days old. I just did not want to nuke everything, recreate things and “restore” the volume from the backup IF I did not need to as there is no real guidance out there on that. THANKS again for listening, guess I’m gonna wing it on deleting everything, recreate, then “restore” from the DPM backup…..probably REALLY mess things up and have to rebuild the server!!! I just get SO bound up that nobody has an answer to a question many many have asked and they are still active in a lot of forums. THX

        Like

  4. Hi Jean-Paul,

    I want to remove one a physical disk ; and then replace it by a new one ; but I am afraid there may be issues during the “repair” process. For example what if there is a bad-block ? It would be best to have a combined “Retire & Repair” operation ; so the disk being retired would still be used ; if needed ; in case of bad-block.

    Do you know if there is such a possibility ?

    Regards,
    Gregory

    Like

    • Hi Gregory,

      I think that this should not be a problem, because you have to move your storage pool manually to one of your new disks. So first insert your new disk, add the disk to your storage pool and when your old disk has a bad block, your data is still save. I guess that you can take it out of the storage pool and check afterwards on the same server? Or you have to insert the old disk into another system and check for failures with that machine.

      Good luck and let me know if this works for you!

      Regards,

      Jean-Paul

      Like

  5. Hi Jean-Paul and many thanks for your article.
    I’m doing some test on a microserver to be prepared when i setup things in the real world 🙂

    I’m trying to simulate a safe remove scenario without a replacement, using virtual disk with resilency on Parity.
    I followed your instruction, but the repair operation fails.

    Here are the steps i tryed:
    – Connected a series of physical disks (using USB external disks and raid external disks)
    – Created a storage pool with these disks, getting a total space of about 5TB.
    – Created a new Thin Virtual Disk with resiliency mode on parity.
    – Copied on the new virtual disk some files (20Gb of data)
    – Set one physical disk to retired. I’ts a 500Gb disk.
    – In the pool there are a total of 5 physical disks, 4 are still active and there is a lot of space available (the pool is 5TB in size)
    – When i run the repair command i get this error:
    Repair-VirtualDisk : Failed
    At line:1 char:1
    + Repair-VirtualDisk -FriendlyName Media
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (StorageWMI:ROOT/Microsoft/…SFT_VirtualDisk) [Repair-VirtualDisk], CimEx
    ception
    + FullyQualifiedErrorId : StorageWMI 4,Repair-VirtualDisk

    Can you help me?

    Like

  6. Hello Jean-Paul,

    I try to arrange your instructions to remove an old hard drive and replace it with a new one.
    (It is a Simple Volume on them)

    But with the command “Repair Virtual Disk -FriendlyName” Your Virtual Disk “” he springer always 100% and does not move data …

    Do you have a tip for me?

    Greetings
    Jannik

    (Translated with Google ;o) )

    Like

  7. Worked like a charm thanks man. Was searching everywhere how to remove the failed disk that still showed as lost communication even though storage pool was healthy and no repair jobs were running. The GUI is horrible and kept locking up on me so Power Shell was a must. Cheers!

    Like

      • Well I tried all this on Windows 10 but the drives are just stuck. My storage space is saying it’s 37.8 TB but I have 5 – 3TB drives stuck in Waiting for removal”. Once you set a drive for removal – even with space – you can’t do more than 1 or 2 at at a time. I can’t get the Virtual attached even though it says healthy. I can’t take the drives out – even powered off – I get the message too many drives are disconnected or retired. There has to be a way. I’m in parity, drives moved what appears to be all the data; 6 – 99+% filled 3TB drives, 1 – 4TB @ 94% and a 5 TB and 1 TB @ 50 %. I have 5 – 3 TB drives stuck and the storage space is dead. I have to find a way – it has my entire movie collection on it and the disks are spread amongst my 4 kids on the other side of the country. HELP – PLEASE! Thanks, Tom

        Like

      • Hi Tom,

        That doesn’t sound good. I must say that I haven’t used Storage Spaces anymore. Most of my data is in the cloud now. Is it possible to just create a new pool with the remaining drives and start from scratch?

        Like

      • That’s going to be a last resort. I have 14 TB of data and I would like to recover most of it before I blow it away.

        Like

  8. Used to have a drive “R:” then one drive failed, I removed and installed a new drive. Can get it to recover. Now I have done so many different things, I don’t know where I am at. Can you have a look?

    PS C:\Users\jroy> Get-PhysicalDisk

    FriendlyName SerialNumber MediaType CanPool OperationalStatus HealthStatus Usage
    ———— ———— ——— ——- —————– ———— —–
    TS256GSSD320 A28045136932180100BE SSD False OK Healthy Auto-S…
    ST2000DM 001-1CH164 SCSI Disk Device W241B0JW Unspecified False OK Healthy Auto-S…
    ST2000DM 001-1CH164 SCSI Disk Device Unspecified False Lost Communication Warning Retired
    ST2000DM001-1CH164 Z2F0SHLV Unspecified False OK Healthy Auto-S…
    ST2000DM 006-2DM164 SCSI Disk Device Unspecified False Lost Communication Warning Auto-S…

    PS C:\Users\jroy> Get-PhysicalDisk | ft FriendlyName

    FriendlyName
    ————
    TS256GSSD320
    ST2000DM 001-1CH164 SCSI Disk Device
    ST2000DM 001-1CH164 SCSI Disk Device
    ST2000DM001-1CH164
    ST2000DM 006-2DM164 SCSI Disk Device

    PS C:\Users\jroy> Set-PhysicalDisk -FriendlyName “ST2000DM 001-1CH164 SCSI Disk Device” -Usage Retired
    Set-PhysicalDisk : Access denied
    Activity ID: {24ee45ff-9093-4516-830b-2a2034dd141d}
    At line:1 char:1
    + Set-PhysicalDisk -FriendlyName “ST2000DM 001-1CH164 SCSI Disk Device” …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : PermissionDenied: (StorageWMI:ROOT/Microsoft/…_StorageCmdlets) [Set-PhysicalDisk], CimException
    + FullyQualifiedErrorId : StorageWMI 40001,Set-PhysicalDisk

    PS C:\Users\jroy> Get-VirtualDisk

    FriendlyName Usage MediaType ResiliencySettingName PhysicalDiskRedundancy OperationalStatus HealthStatus IsManualAttach Size FootprintOnPool StorageEfficiency
    ———— —– ——— ——————— ———————- —————– ———— ————– —- ————— —————–
    My First Space Data Unspecified Parity 1 Detached Unhealthy False 3.63 TB 40.25 GB 9,236.02 %

    PS C:\Users\jroy> Repair-VirtualDisk -FriendlyName “My First Space”
    Repair-VirtualDisk : Access denied
    Activity ID: {a3817be8-91a9-467f-8928-0bb889bcd9e0}
    At line:1 char:1
    + Repair-VirtualDisk -FriendlyName “My First Space”
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : PermissionDenied: (StorageWMI:ROOT/Microsoft/…SFT_VirtualDisk) [Repair-VirtualDisk], CimException
    + FullyQualifiedErrorId : StorageWMI 40001,Repair-VirtualDisk

    PS C:\Users\jroy>

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s