The essentials
Quick reference
One focused task per row. Jump to the related section for complete, working examples.
| Use | Syntax | Examples |
|---|---|---|
| Show disk attributes | attributes disk | View examples |
| Set disk read-only | attributes disk set readonly | View examples |
| Clear disk read-only | attributes disk clear readonly | View examples |
| Show volume attributes | attributes volume | View examples |
| Set volume read-only | attributes volume set readonly | View examples |
| Clear volume read-only | attributes volume clear readonly | View examples |
| Mark a volume hidden | attributes volume set hidden | View examples |
| Suppress default letter | attributes volume set nodefaultdriveletter | View examples |
| Take a disk offline | offline disk | View examples |
| Bring a disk online | online disk | View examples |
| Take a volume offline | offline volume | View examples |
| Bring a volume online | online volume | View examples |
| Show SAN policy | san | View examples |
| Keep shared disks offline | san policy=OfflineShared | View examples |
| Show disk ID | uniqueid disk | View examples |
| Set a GPT disk ID | uniqueid disk id=6f9619ff-8b86-d011-b42d-00c04fc964ff | View examples |
| Verify final disk state | list disk | View examples |
DiskPart state commands can make storage writable, invisible, or unavailable without changing its partition table. That makes them useful for maintenance and shared storage, but still operationally risky. Verify focus and ownership, understand cluster or application dependencies, and distinguish a disk's read-only state from a volume's attributes before changing anything.
Step by step
Detailed examples
Separate disk attributes from operational state
Disk read-only is an attribute; offline is an operational state. A disk can be online but read-only, or offline with the read-only attribute cleared. Inspect detail disk and attributes disk together. Clearing read-only does not override storage-array protection, hardware write protection, policy, or cluster ownership.
list disk
select disk 3
detail disk
attributes disk
rem Only after approval: attributes disk clear readonly
attributes disk Account for partition-style attribute scope
On basic MBR disks, hidden, read-only, and no-default-letter attributes apply to every volume on the disk. On basic GPT disks and dynamic disks, they apply only to the selected volume. Hidden and nodefaultdriveletter affect discovery and letter assignment; they are not access-control boundaries. Record existing mount points before changing these flags.
list volume
select volume 7
detail volume
attributes volume
rem On basic MBR, this change can affect every volume on the disk.
rem Only after impact review: attributes volume set nodefaultdriveletter Coordinate online and offline transitions
Offlining a disk interrupts all volumes on it. Offlining a volume can break services, shares, paging, databases, backups, or failover workflows. Confirm application quiescence and cluster ownership first. Bringing storage online can expose duplicate filesystems or signatures, so identify why Windows kept it offline before overriding the state.
list disk
select disk 3
detail disk
list volume
rem Stop applications and confirm cluster ownership.
offline disk
detail disk Treat SAN policy as a host-wide default
SAN policy controls how newly discovered disks are brought online and whether they start read-only. OfflineShared is generally safer for shared-bus storage because it reduces accidental simultaneous access. OnlineAll can be dangerous when disks are visible to multiple nonclustered servers. Changing policy does not replace storage zoning, reservations, or cluster coordination.
san
list disk
rem Do not set OnlineAll on storage shared by multiple servers. Change duplicate identifiers only with a recovery plan
Unique IDs help Windows distinguish disks. Clones can produce collisions that leave a disk offline. On GPT, uniqueid disk displays or sets a GUID; on MBR it uses an eight-digit hexadecimal signature. Changing an ID can invalidate boot configuration, application bindings, replication, or backup metadata. Capture the old ID and verify the clone is not a production source.
list disk
select disk 3
detail disk
uniqueid disk
rem Record the current value before any collision repair. Verify state through more than one view
After a change, repeat attributes, detail, list disk, and list volume. Then validate the consumer: a filesystem path, service, cluster resource, or application. DiskPart reporting that a command succeeded only proves that the storage operation was accepted, not that the workload is healthy.
select disk 3
attributes disk
detail disk
list disk
list volume
exit Sources and further reading
References
Authoritative documentation used to verify and expand this cheat sheet.
Help us improve
Found a typo or missing example?
Tell us what would make this cheat sheet clearer, more complete, or more useful.



