keepcalculator

06 Numbers and Powers

Diskpart Create Partition: Commands & Examples

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

Diskpart is a built-in Windows command-line tool that manages disks, partitions, and volumes. To create a partition with Diskpart, you use the create partition command after selecting the target disk, and the basic syntax is create partition primary size=10000 (size in MB) or create partition extended for extended partitions. This article explains the full command set, how to choose the right partition type, and what to do when the command fails.

What Diskpart Is and When to Use It

Diskpart is a text-based utility included with Windows since XP, accessible from Command Prompt or PowerShell by typing diskpart and pressing Enter. It is more powerful than the graphical Disk Management snap-in because it can script operations, handle multiple disks in one session, and work with raw disks that have no file system. You typically use Diskpart when you need to:

  • Create or delete partitions on a new disk before formatting.
  • Convert a disk between MBR and GPT partition styles.
  • Assign or remove drive letters, or mount volumes to folders.
  • Clean a disk completely (removes all partitions and data).
  • Automate disk setup in a batch script or deployment task.

Because Diskpart operates on raw disk structures, it does not require the disk to be formatted first. However, it also does not create a file system; after making a partition, you must format it with format fs=ntfs quick or similar before storing files.

Before You Start: Open Diskpart with Admin Rights

Diskpart requires administrator privileges. If you open Command Prompt as a standard user, typing diskpart will show an error or run with limited access. To start correctly:

  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 see all physical disks. Note the disk number (Disk 0, Disk 1, etc.).
  4. Type select disk 1 (replace 1 with the correct number) and press Enter. The message “Disk 1 is now the selected disk” confirms success.

All partition commands act on the selected disk only. If you forget to select a disk, Diskpart returns “No disk is selected.”

The create partition Command Syntax

The full syntax for creating a partition is:

create partition [primary | extended | logical] [size=] [offset=] [noerr]

Each parameter has a specific meaning:

  • primary – Creates a primary partition. On MBR disks, you can have up to four primary partitions (or three primary and one extended). On GPT disks, there is no practical limit.
  • extended – Creates an extended partition on MBR disks, which can contain logical drives. This is only needed when you want more than four partitions on an MBR disk.
  • logical – Creates a logical drive inside an extended partition. You must select the extended partition first.
  • size= – Size in megabytes (MB). If omitted, the partition uses all remaining free space on the disk. For example, size=50000 creates a 50 GB partition.
  • offset= – Byte offset from the start of the disk where the partition begins. Rarely used; defaults to the first available alignment boundary.
  • noerr – Used in scripts to continue even if an error occurs. Not needed for interactive use.

After the command, Diskpart reports “DiskPart succeeded in creating the specified partition.” The new partition appears as “Partition 1” in list partition.

Choosing the Right Partition Type: Primary vs Extended vs Logical

The type you choose depends on the disk’s partition style (MBR or GPT) and how many partitions you need.

  • MBR (Master Boot Record) – Older style, supports disks up to 2 TB and a maximum of four primary partitions. To have more than four, create three primary partitions, one extended partition, and then create logical drives inside the extended partition. Logical drives behave like primary partitions for most purposes, but they cannot be used to boot an operating system.
  • GPT (GUID Partition Table) – Modern style, required for disks larger than 2 TB and for UEFI boot. GPT supports up to 128 partitions per disk by default, and all partitions are “primary”. There is no extended or logical partition concept on GPT disks.

If you are unsure which style your disk uses, type list disk in Diskpart. The GPT column shows an asterisk (*) for GPT disks. To convert a disk from MBR to GPT, you must first clean the disk (which erases all data), then type convert gpt.

Step-by-Step: Creating a Primary Partition on a New Disk

Here is a complete example that creates a 50 GB primary partition on a fresh disk, formats it as NTFS, and assigns a drive letter:

  1. Open Diskpart as administrator.
  2. Type list disk and note the disk number of the new disk (e.g., Disk 2).
  3. Type select disk 2 and press Enter.
  4. Type create partition primary size=51200 and press Enter. (51200 MB = 50 GB)
  5. Type list partition to confirm the partition was created. Note the partition number (usually 1).
  6. Type select partition 1 and press Enter.
  7. Type format fs=ntfs quick and press Enter. This formats the partition with NTFS.
  8. Type assign letter=E and press Enter. This gives the partition the drive letter E.
  9. Type exit to leave Diskpart.

If you want to use the entire disk for one partition, omit the size= parameter: create partition primary.

Common Errors and How to Fix Them

Diskpart commands often fail with cryptic messages. Here are the most frequent issues and their solutions:

  • “There is no free space available to create a partition” – The disk already has a partition using all space. Delete an existing partition or use the extend command to grow a partition into unallocated space.
  • “The requested operation requires an elevated process” – Diskpart is not running as administrator. Close and reopen Command Prompt with “Run as administrator”.
  • “The specified disk is not convertible” – You tried to convert MBR to GPT without cleaning the disk first. Back up data, then run clean before convert gpt.
  • “The volume is in use” – The partition you are trying to delete or modify is being used by a program, page file, or system process. Close all programs, or boot from a recovery drive to modify system partitions.
  • “DiskPart has encountered an error: Access is denied” – You may be trying to modify a system or OEM partition. Do not delete these unless you are absolutely sure, as they are needed to boot Windows.

If a command fails, type detail disk to see the disk’s current layout and free space, then adjust your command accordingly.

Safety: What Not to Do with Diskpart

Diskpart is a powerful tool that can permanently destroy data. Always follow these rules:

  • Never run clean or clean all on a disk unless you intend to erase everything on it. clean removes all partitions and data; clean all also zeroes every sector, which takes much longer.
  • Double-check the selected disk with list disk and select disk before any destructive command. Selecting the wrong disk (e.g., Disk 0 with your OS) and running clean will wipe your system drive.
  • Do not delete system partitions (EFI, System Reserved, Recovery) unless you are reinstalling Windows. Deleting them can prevent your computer from booting.
  • Back up important data before changing partition layouts. Even a simple resize can fail and cause data loss.
  • Use the noerr flag only in scripts where you want to continue after an error; in interactive mode it can hide problems.

If you are unsure about a command, test it on a spare USB drive first. USB drives appear as disks in Diskpart and are safe to experiment with.

Alternatives to Diskpart

Diskpart is not the only way to manage partitions. Depending on your needs, you might prefer:

  • Disk Management (diskmgmt.msc) – The graphical tool in Windows. Right-click Start and select “Disk Management”. It can create, shrink, extend, and delete partitions with a few clicks. It is easier for beginners but less scriptable.
  • PowerShell cmdlets – Windows 10/11 include modules like Initialize-Disk, New-Partition, and Format-Volume. These are more powerful than Diskpart for automation and can be used in scripts.
  • Third-party partition managers – Tools like GParted (free, Linux-based) or commercial Windows software can resize partitions without deleting them, which Diskpart cannot do easily. They often have a graphical interface and support moving partitions.
  • Windows Setup – When installing Windows, the installer itself can create, delete, and format partitions on the target disk. This is the safest way to set up a boot drive.

For most users, Disk Management is sufficient. Diskpart becomes necessary when you need to script operations or work with disks that the GUI cannot handle (e.g., certain OEM partitions).

Frequently Asked Questions

What is the difference between create partition primary and create partition logical?

A primary partition is a standalone partition that can hold an operating system. A logical drive exists inside an extended partition on MBR disks and cannot boot an OS. On GPT disks, there is no logical drive concept; all partitions are primary.

How do I create a partition using all free space on a disk?

Omit the size= parameter. For example, create partition primary will create a primary partition using all unallocated space on the selected disk.

Can I create a partition larger than 2 TB with Diskpart?

Yes, but only on a GPT disk. MBR disks are limited to 2 TB. If your disk is larger than 2 TB, convert it to GPT first (after backing up data) with convert gpt.

Why does Diskpart say “The requested operation requires an elevated process”?

Diskpart must run as administrator. Right-click Command Prompt and select “Run as administrator”, then try again.

How do I delete a partition with Diskpart?

Select the disk, then select the partition (e.g., select partition 1), then type delete partition. For extended partitions, you may need delete partition override if the partition is protected.

Does Diskpart format the partition after creating it?

No. Diskpart only creates the partition structure. You must format it separately with format fs=ntfs quick or use the format command in Explorer after assigning a drive letter.

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 →