How to Use Diskpart Safely in Windows

Windows Diskpart command prompt illustration

Diskpart is a powerful built-in Windows command-line tool for disks, partitions, and volumes. It can solve problems that Disk Management cannot, but it also accepts commands immediately, so you need to identify the correct disk or volume before changing anything.

This guide applies to Windows 10 and Windows 11. Diskpart is already included with Windows and does not need a separate download.

Does This Affect You?

Use Diskpart when Disk Management has a greyed-out option, a disk is not appearing correctly, a drive letter needs to be assigned, or a storage task must be scripted. It is less forgiving than the graphical tool because most commands do not ask for extra confirmation.

Open Diskpart and Inspect Safely

Listing disks, volumes, and partitions is safe. These commands let you look around before doing anything that changes storage.

  1. Click Start, type cmd, right-click Command Prompt, and choose Run as administrator.
  2. Type diskpart and press Enter. The prompt changes to DISKPART>.
  3. Type list disk to show the physical drives connected to the PC. Use size to identify the correct drive because disk numbers do not show drive letters at this level.
  4. Type select disk 0, replacing 0 with the disk you need. Diskpart confirms the selected disk.
  5. Type list partition to view the partitions on that disk.
  6. Type exit when you are finished inspecting.

Extend a Partition with Diskpart

A common reason to use Diskpart is extending a volume when Disk Management will not let you. The unallocated space must be adjacent to the volume you are extending.

  1. Open Command Prompt as administrator and start diskpart.
  2. Type list volume and note the volume number for the drive letter you want to extend.
  3. Type select volume 2, replacing 2 with the correct volume number.
  4. Use list disk and Disk Management if needed to confirm there is unallocated space directly next to that volume on the same disk.
  5. Type extend to use all adjacent unallocated space, or use a command such as extend size=20000 to add about 20 GB. The size value is in megabytes.
  6. Type exit, then check File Explorer or Disk Management to confirm the volume is larger.

Useful Diskpart Commands to Know

list disk, list volume, and list partition show available storage objects. select disk X and select volume X choose what the next commands affect. detail disk shows more information about the selected disk. assign letter=E gives a selected volume a drive letter, while remove letter=E removes one without deleting the volume.

Diskpart Safety Notes

Selection Matters

Diskpart is designed for automation and scripting, so it does not pause for “are you sure?” on many commands. Always run the matching list command again before selecting a disk or volume, and read the size and number back carefully.

The Clean Command Erases a Disk

clean removes partition information from the selected disk. It is useful in the right recovery or wipe procedure, but it is destructive enough that it deserves its own careful checklist, backups, and confirmation of the selected disk.

Use Disk Management for Routine Jobs

For creating, formatting, or shrinking everyday partitions, right-click Start and use Disk Management. It shows a visual layout and more confirmation prompts. Reach for Diskpart when Disk Management cannot do the job or when a script is required.

Sources

  • Microsoft Learn: Diskpart command-line reference
  • Microsoft Support: Extend a basic volume
  • Microsoft Learn: Diskpart clean command reference
Disclosure: This post may contain affiliate links which means I may receive a commission for purchases made through links. I will only recommend products that I have personally used! Learn more on my Private Policy page.
A thoughtful woman reads a newspaper while enjoying coffee at an indoor workspace.

DEALWEEK

SUBSCRIBE AND GET 20% OFF YOUR NEXT ORDER! OFFER ENDS SOON - DON’T MISS OUT!

We don’t spam! Read our privacy policy for more info.

Shopping Cart