keepcalculator

06 Numbers and Powers

No Partition Selected in Diskpart? Fix It

Card No. 06·55236 · Updated · Standard formula, shown below

When DiskPart reports “No partition selected,” it means you ran a command that requires an active partition context, but DiskPart has no partition in focus. The fix is to select a partition first with select partition <number> or select partition after listing available partitions. This article explains why the error occurs, how to resolve it in a few steps, and how to avoid it in the future.

What “No Partition Selected” Actually Means

DiskPart is a command-line disk partitioning utility in Windows. It works on a “focus” model: you select a disk, then a partition, then perform actions on that focused object. If you try to run a command like delete partition, format, active, or assign without first selecting a partition, DiskPart returns “No partition selected.” This is not a corruption error; it simply means the context is missing.

Think of it like telling someone to “delete the file” without specifying which file. DiskPart needs you to point it to the exact partition before it can act. The error is common when you open DiskPart fresh and immediately type a partition command, or after you’ve selected a disk but forgot to select a partition within it.

How to Select a Partition in DiskPart

Here’s the standard sequence to select a partition and run a command:

  1. Open Command Prompt as Administrator. Type diskpart and press Enter.
  2. Type list disk to see all physical drives. Note the disk number (e.g., Disk 1).
  3. Type select disk 1 (replace 1 with your disk number). You’ll see “Disk 1 is now the selected disk.”
  4. Type list partition to see partitions on that disk. Note the partition number (e.g., Partition 2).
  5. Type select partition 2. You’ll see “Partition 2 is now the selected partition.”
  6. Now you can run commands like delete partition, format fs=ntfs quick, or active.

If you only have one partition on the disk, you can type select partition without a number after selecting the disk. DiskPart will select the only partition. This works only if there is exactly one partition on the selected disk.

Common Scenarios That Trigger the Error

Several situations lead to “No partition selected”:

  • You ran delete partition immediately after opening DiskPart, without any selection.
  • You selected a disk but not a partition, then tried a partition-specific command.
  • You used select partition on a disk with multiple partitions and no number, which fails because DiskPart doesn’t know which one.
  • You previously selected a partition, but then selected a different disk, which clears the partition focus.
  • You used a script that forgot the selection step.

In all cases, the fix is the same: select the partition again before proceeding.

How to Choose the Right Partition Number

When you type list partition, the output shows a list with numbers. The partition number is not the same as the drive letter or the disk number. For example, Disk 0 might have Partition 1 (System Reserved), Partition 2 (C:), and Partition 3 (Recovery). If you want to format C:, you’d select partition 2. Be careful: selecting the wrong partition can lead to data loss. Always double-check the size and type column in the list to confirm you have the right one.

If you’re unsure, you can use detail partition after selecting a partition to see its details, including the volume letter and size. This helps confirm you’re acting on the correct partition.

What to Do If Selection Still Fails

Sometimes you select a partition but the error persists. Possible reasons:

  • The partition is hidden or has no drive letter. It still exists, and you can select it by number.
  • You’re trying to select a partition on a disk that isn’t initialized or is offline. Use select disk and then online disk if needed.
  • The partition may be on a dynamic disk, but selection works the same way.
  • If you’re using a script, ensure there’s no typo in the partition number.

If list partition shows no partitions, the disk might have unallocated space. In that case, you need to create a partition first with create partition primary before you can select it.

How to Avoid the Error in Scripts

When writing DiskPart scripts, always include the selection steps. A minimal script to clean a disk looks like:

select disk 1
clean
create partition primary
select partition 1
format fs=ntfs quick
assign

Note that after create partition primary, the new partition is automatically selected, but it’s safer to explicitly select it. This avoids the “No partition selected” error if the script is modified later.

Frequently Asked Questions

Why does DiskPart say “No partition selected” when I just selected a disk?
Selecting a disk only sets the disk focus. Partition commands require a partition focus. You must select a partition after selecting a disk.

Can I select a partition without selecting a disk first?
No. DiskPart requires a disk to be selected before you can list or select partitions. If you try, you’ll get an error like “No disk is selected.”

What does “select partition” do without a number?
It selects the only partition on the selected disk. If there are multiple partitions, DiskPart returns an error asking for a number.

Does “No partition selected” mean my disk is broken?
No. It’s a user error in the command sequence. Your disk and partitions are fine; you just need to select the partition.

How do I see which partition is selected?
Type detail partition after selecting a partition. It shows the partition number, type, size, and offset. If no partition is selected, you’ll get the error.

What if I accidentally delete the wrong partition?
Deleting a partition erases its data. There is no built-in undo in DiskPart. Always verify the partition number with list partition and detail partition before deleting.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →