Task 11: Clear Previous Storage Configuration (Conditional)
DOCUMENT CATEGORY: Runbook SCOPE: Clear previous Storage Spaces Direct configuration if redeploying on existing... PURPOSE: Clear previous Storage Spaces Direct configuration if redeploying on existing hardware MASTER REFERENCE: Azure Local Storage Spaces Direct
Status: Active
Overview
If nodes have previously been used with Storage Spaces Direct, all existing storage pools, virtual disks, and disk metadata must be cleared before Azure Local deployment.
This step DESTROYS ALL DATA on data disks. Ensure all data is backed up before proceeding. This is irreversible.
When to Run
| Scenario | Run? |
|---|---|
| New hardware, first deployment | ❌ Skip |
| Redeployment on existing hardware | ✅ Yes |
| Hardware with previous S2D config | ✅ Yes |
Disks showing CanPool = False | ✅ Yes |
| After a failed deployment | ✅ Yes |
Prerequisites
| Requirement | Details |
|---|---|
| Tasks 01–10 complete | Hostname configured, nodes restarted |
| Data backed up | All important data saved — this cannot be undone |
Variables from variables.yml
| Path | Type | Description |
|---|---|---|
cluster_nodes[].management_ip | string | PSRemoting target IP (orchestrated mode) |
cluster_nodes[].hostname | string | Node display name for logging |
Execution Options
- Direct (On Node)
- Orchestrated Script
- Standalone Script
Run on each node individually via console, KVM, or RDP.
Toolkit script: scripts/deploy/04-cluster-deployment/phase-03-os-configuration/task-11-clear-previous-storage-configuration-conditional/powershell/Clear-StorageConfiguration-Direct.ps1
# Task 11 - Clear Previous Storage Configuration (run locally on target node)
Update-StorageProviderCache
Get-StoragePool | ? IsPrimordial -eq $false | Set-StoragePool -IsReadOnly:$false -ErrorAction SilentlyContinue
Get-StoragePool | ? IsPrimordial -eq $false | Get-VirtualDisk | Remove-VirtualDisk -Confirm:$false -ErrorAction SilentlyContinue
Get-StoragePool | ? IsPrimordial -eq $false | Remove-StoragePool -Confirm:$false -ErrorAction SilentlyContinue
Get-PhysicalDisk | Reset-PhysicalDisk -ErrorAction SilentlyContinue
Get-Disk | ? Number -ne $null | ? IsBoot -ne $true | ? IsSystem -ne $true | ? PartitionStyle -ne RAW | ? BusType -ne USB | % {
$_ | Set-Disk -isoffline:$false
$_ | Set-Disk -isreadonly:$false
$_ | Clear-Disk -RemoveData -RemoveOEM -Confirm:$false
$_ | Set-Disk -isreadonly:$true
$_ | Set-Disk -isoffline:$true
}
Get-Disk | Where Number -Ne $Null | Where IsBoot -Ne $True | Where IsSystem -Ne $True | Where PartitionStyle -Eq RAW | Group -NoElement -Property FriendlyName
Run from the management server against all nodes.
Toolkit script: scripts/deploy/04-cluster-deployment/phase-03-os-configuration/task-11-clear-previous-storage-configuration-conditional/powershell/Invoke-ClearStorage-Orchestrated.ps1
# Task 11 - Clear Previous Storage Configuration (orchestrated, all nodes)
# variables.yml variables:
# cluster_nodes[].management_ip -> $ServerList
$ConfigPath = "$env:USERPROFILE\variables.yml"
$ServerList = (Get-Content $ConfigPath | Select-String 'management_ip:\s+"?([^"'' ]+)' |
ForEach-Object { $_.Matches[0].Groups[1].Value.Trim() })
Invoke-Command ($ServerList) {
Update-StorageProviderCache
Get-StoragePool | ? IsPrimordial -eq $false | Set-StoragePool -IsReadOnly:$false -ErrorAction SilentlyContinue
Get-StoragePool | ? IsPrimordial -eq $false | Get-VirtualDisk | Remove-VirtualDisk -Confirm:$false -ErrorAction SilentlyContinue
Get-StoragePool | ? IsPrimordial -eq $false | Remove-StoragePool -Confirm:$false -ErrorAction SilentlyContinue
Get-PhysicalDisk | Reset-PhysicalDisk -ErrorAction SilentlyContinue
Get-Disk | ? Number -ne $null | ? IsBoot -ne $true | ? IsSystem -ne $true | ? PartitionStyle -ne RAW | ? BusType -ne USB | % {
$_ | Set-Disk -isoffline:$false
$_ | Set-Disk -isreadonly:$false
$_ | Clear-Disk -RemoveData -RemoveOEM -Confirm:$false
$_ | Set-Disk -isreadonly:$true
$_ | Set-Disk -isoffline:$true
}
Get-Disk | Where Number -Ne $Null | Where IsBoot -Ne $True | Where IsSystem -Ne $True | Where PartitionStyle -Eq RAW | Group -NoElement -Property FriendlyName
} | Sort -Property PsComputerName, Count
When to use: Use this option for a self-contained deployment without a shared configuration file.
Script: See azurelocal-toolkit → scripts/deploy/ for the standalone script for this task.
Standalone script content references the toolkit repository. See the Orchestrated Script tab for the primary implementation.
Validation
# Verify all data disks are CanPool = True
$ServerList = @("<node1-ip>", "<node2-ip>")
Invoke-Command ($ServerList) {
Get-PhysicalDisk | Where-Object { $_.BusType -ne 'USB' } |
Select-Object FriendlyName, CanPool, CannotPoolReason, BusType, MediaType
} | Format-Table -AutoSize
Expected: All data disks show CanPool = True. Boot disk shows CannotPoolReason = Insufficient Capacity — this is expected.
Validation Checklist
- Script ran without errors on all nodes
- All data disks show
CanPool = True - Boot disk excluded (shows
Insufficient Capacity— expected)
Troubleshooting
| Issue | Resolution |
|---|---|
CanPool = False after running | Re-run Reset-PhysicalDisk |
| Storage pool still exists | Remove from cluster first, then re-run |
Alternatives
The procedures in this task use the scripted methods shown in the tabs above. Additional deployment methods including Azure CLI and Bash scripts are available in the azurelocal-toolkit repository under scripts/deploy/.
| Method | Description |
|---|---|
| Azure CLI | PowerShell-based Azure CLI scripts for Azure resource operations |
| Bash | Linux/macOS compatible shell scripts for pipeline environments |
Navigation
← Task 10: Configure Hostname · ↑ Phase 03 · Task 12: Combined Script →
Version Control
| Version | Date | Author | Changes |
|---|---|---|---|
| 1.0.0 | 2025-03-25 | Azure Local Cloud | Initial release |