The essentials

Quick reference

One focused task per row. Jump to the related section for complete, working examples.

UseSyntaxExamples
Show disk attributesattributes diskView examples
Set disk read-onlyattributes disk set readonlyView examples
Clear disk read-onlyattributes disk clear readonlyView examples
Show volume attributesattributes volumeView examples
Set volume read-onlyattributes volume set readonlyView examples
Clear volume read-onlyattributes volume clear readonlyView examples
Mark a volume hiddenattributes volume set hiddenView examples
Suppress default letterattributes volume set nodefaultdriveletterView examples
Take a disk offlineoffline diskView examples
Bring a disk onlineonline diskView examples
Take a volume offlineoffline volumeView examples
Bring a volume onlineonline volumeView examples
Show SAN policysanView examples
Keep shared disks offlinesan policy=OfflineSharedView examples
Show disk IDuniqueid diskView examples
Set a GPT disk IDuniqueid disk id=6f9619ff-8b86-d011-b42d-00c04fc964ffView examples
Verify final disk statelist diskView 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

01

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.

Inspect before changing write access
list disk
select disk 3
detail disk
attributes disk
rem Only after approval: attributes disk clear readonly
attributes disk
Back to quick reference ↑
02

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.

Review volume attributes and paths
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
Back to quick reference ↑
03

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.

Verify a disk before an offline maintenance window
list disk
select disk 3
detail disk
list volume
rem Stop applications and confirm cluster ownership.
offline disk
detail disk
Back to quick reference ↑
04

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.

Inspect policy without changing it
san
list disk
rem Do not set OnlineAll on storage shared by multiple servers.
Back to quick reference ↑
05

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.

Read and record the selected disk ID
list disk
select disk 3
detail disk
uniqueid disk
rem Record the current value before any collision repair.
Back to quick reference ↑
06

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.

Post-change state check
select disk 3
attributes disk
detail disk
list disk
list volume
exit
Back to quick reference ↑

Sources and further reading

References

Authoritative documentation used to verify and expand this cheat sheet.

  1. Microsoftattributes disklearn.microsoft.com
  2. Microsoftattributes volumelearn.microsoft.com
  3. Microsoftonlinelearn.microsoft.com
  4. Microsoftsanlearn.microsoft.com
  5. Microsoftuniqueidlearn.microsoft.com

Help us improve

Found a typo or missing example?

Tell us what would make this cheat sheet clearer, more complete, or more useful.

Share feedback