What Is Diskpart? Ultimate Guide to Use Diskpart Commands on Windows - Qiling  

What Is Diskpart? How to Master and Use Diskpart Commands on Windows [Full Guide]


The Diskpart is a free disk utility that allows Windows users to manage disk partitions. However, to process specific orders to the Operating System, users need to know the right commands. This guide will help beginners learn what Diskpart does, how to use it to manage disk drives, and provide tips to fix Diskpart errors, ensuring data protection from being removed by these commands.

Let's see how to use Diskpart on your computer now.

In this article, you'll learn:

  • What Is Diskpart
  • Learn About Most Common Diskpart Commands 
  • How to Open Diskpart Utility in Windows
  • How to Use Diskpart to Manage Hard Drive Partitions
  • How to Use Diskpart to Fix Device Errors
  • Troubleshooting Diskpart Errors On Windows

What Is Diskpart

Diskpart is a command-line disk partitioning utility included in Windows 2000 and later Microsoft operating systems, replacing its predecessor, fdisk.
                                                                                                  - by Wikipedia

Definition of Diskpart

Diskpart is a newer command-line disk partitioning tool that replaces the older fdisk, allowing all Windows users to run Diskpart syntax parameters to manage disk partitions on desktop computers, laptops, and external storage devices.

Here is a list of basic information about Diskpart that you may feel like knowing:

How Does Diskpart Work? 

The operating system processes the command parameters and applies the executions on the target hard drive partitions through a series of steps. First, the Diskpart utility is initialized, and the operating system loads the necessary drivers and libraries to interact with the hard drive partitions. Next, the user inputs a command, such as creating a new partition or formatting an existing one, and the Diskpart utility parses the command parameters to determine the specific action to take.

Step 1. Open the Diskpart.

Step 2. To create a new partition table on a disk, you can use the `parted` command with the `mktable` option. For example, on a disk named `/dev/sdb`, you can run `parted /dev/sdb mktable gpt` to create a GPT partition table.

Step 3. Focus on an object - the disk, volume, or partition:

Step 4. To process operation orders to the OS via specific Diskpart syntax parameters, you would use commands like `CREATE PARTITION PRIMARY` or `CREATE PARTITION EXTENDED` followed by the size of the partition, and then `SELECT DISK #` to specify the disk on which to perform the operation. For example, `CREATE PARTITION PRIMARY SIZE=1024` would create a primary partition of size 1024 MB on the disk selected by `SELECT DISK #`.

Diskpart working process

What Does Diskpart Do - Benefits of DiskPart [Pros & Cons]

The diskpart command interpreter is a tool that helps manage a computer's drives, including disks, partitions, volumes, and virtual hard disks.

The diskpart utility is used for partitioning hard drives, but can also format removable media like flash drives.

Briefly, Diskpart could be applied to execute the following tasks:

Diskpart is a popular tool due to its numerous benefits. Its pros include being able to create, delete, and format partitions, as well as manage disk volumes and perform disk-related tasks. However, it also has some cons, such as being a command-line interface that can be intimidating for beginners, and requiring specific syntax for commands.

01

Pros of Diskpart:

  • 1. Free
  • 2. Cross-platform: Windows & ReactOS
  • 3. Applicable to all levels of users.
  • 4. Support more operational features than Disk Management.
  • 5. Rapid to process orders to the OS.
02

Cons of Diskpart:

  • 1. Complex
  • 2. No confirm option, and no undo option.
  • 3. Hard to remember all syntax parameters.
  • 4. Easy to type false commands and cause serious problems.
 

Learn About Most Common Diskpart Commands  

The command for formatting a volume is `FORMAT` and the command for creating a new partition is `CREATE PARTITION`. However, it's worth noting that the `CREATE PARTITION` command can be used in various ways, such as specifying the size and file system type of the new partition. For example, `CREATE PARTITION PRIMARY` or `CREATE PARTITION PRIMARY SIZE=1024 FS=NTFS`.

Diskpart Commands Function
  • list disk
Get information about all disks on your computer.
  • list partition/volume
Get information about all partitions/volumes on a disk.
  • select disk/partition/volume *
To focus on a specific disk, partition, or volume, you can select it by its name or identifier, and then use the `*` symbol to indicate the number of selected items. For example, if you want to focus on the first disk, you can use `disk 0`, or if you want to focus on the first partition on the first disk, you can use `disk 0, partition 0`. The `*` symbol will be used to indicate that you are focusing on the selected item(s).
  • detail disk/partition/volume
Display detailed information about the selected disk, partition, or volume.
  • create partition primary/logical size=*
1. Open a terminal and type "fdisk /dev/sdb" (replace "/dev/sdb" with your desired disk name) to enter the fdisk utility. 2. Press 'n' to create a new partition.
  • delete disk/partition/volume *
To delete a specific disk, partition, or volume, you can use the "delete" command followed by the disk or partition number. For example, if you want to delete the first disk, you would type "delete 1". If you want to delete a specific partition, you would type "delete partition 1". If you want to delete a specific volume, you would type "delete volume 1".
  • convert basic/dynamic/mbr/gpt
Convert a disk between basic and dynamic, MBR and GPT.
  • assign
Assign a drive letter to a new volume.
  • clean/clean all
To completely erase a hard drive or SSD, delete all partitions on the disk and remove all existing data. This will wipe out all existing data on the device.
  • format
Format a partition or a volume, change its file system to NTFS, FAT32, exFAT, etc.
  • active
Set a selected partition active.

Note that We've only listed some common Diskpart commands here. If you need more advanced commands, you can refer to Microsoft's documentation at https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/diskpart for further assistance.

How to Open Diskpart Utility in Windows

To access the Diskpart utility on a Windows computer, you can follow one of the four paths: on Windows 10/11, type "diskpart" in the Windows Search bar and press Enter; on Windows 8, go to the Start screen, type "diskpart" and press Enter; on Windows 7, click on the Start button, type "diskpart" in the Search bar, and press Enter; or, if you're using Windows XP, click on the Start button, select "Run", type "diskpart" and press Enter.

1. Open Diskpart in Windows 11:

Open Diskpart in Windows 11

2. Open Diskpart in Windows 10:

Open Diskpart in Windows 10

3. Open Diskpart in Windows 8:

Open Diskpart in Windows 8

4. Open Diskpart in Windows 7:

Open Diskpart in Windows 7

To manage your hard disk partitions or external storage devices, follow these steps: open Diskpart, and then use the respective Diskpart commands, such as list disk, select disk, list partition, select partition, delete partition, create partition, assign letter, and exit, to perform tasks like deleting, creating, and assigning drive letters to your storage devices.

How to Use Diskpart to Manage Hard Drive Partitions

To manage disk partitions using the Diskpart command, follow these steps: Use the Diskpart command to open the Diskpart utility, and then list the available disk partitions using the "list disk" command. Select the disk you want to manage using the "select disk" command, and then list the partitions on that disk using the "list partition" command.

Notice:
Before proceeding with the tutorials, please note that using Diskpart command lines to format, delete, clean, erase, or convert disks can lead to serious data loss issues. To avoid this, make sure to create a backup of all essential data before attempting the next steps.

#1. Use Diskpart to Create Partition (Primary or Logical)

Applies to: create a new simple volume, primary partition, or logical partition.

Step 1. Open Diskpart.

Step 2. Type list disk and hit Enter.

Step 3. To create a new partition on a specific disk, type `select disk *` and press Enter, replacing the asterisk with the number of the target disk you want to create a partition on.

Step 4. `fdisk /dev/sdb` or `parted /dev/sdb`

Format partition

LEARN MORE

You can use Diskpart commands to create various types of volumes aside from primary or logical partitions, such as a boot volume, dynamic volume, RAID-5, and mirrored volume, among others. For more information on how to create volumes using Diskpart, you can visit the link that explains How to Create Volume by Using Diskpart.

#2. Use Diskpart to Format or Quick Format Hard Drive/SSD or USB

Applies to: Format hard drive/SSD, quick format USB or external disks using Diskpart/CMD. 

Step 1. Open Diskpart.

If you need to format an internal hard drive, you can skip Step 2. Just go ahead and format the drive using the built-in formatting tool, and then proceed with the installation of the operating system.

Step 2. Connect a removable external hard disk or USB to your PC.

Step 3. The command line "python -m pip install --upgrade pip" should be typed in one go, followed by hitting Enter. This command upgrades the pip package manager to the latest version.

Note that you need to repeat the process if you need to format multiple partitions on your computer.

Step 4. Type exit and close Diskpart when the process completes. 

Formt partitoin using Diskpart

BONUS TIP:

How to Clean and Format a Disk Using Diskpart

You can also use the Diskpart Utility to clean and format a disk, making it like new. This process allows you to reuse the disk as a fresh storage device.

Format disk using diskpart

#3. Use Diskpart to Delete Partition, Cleanup, or Erase Disk 

Applies to:To completely wipe a hard drive or solid state drive, you can use Diskpart to delete volumes, remove the recovery partition, clean the disk, or erase the entire drive.

To Delete Partitions from Hard Drive:

Delete partition usig Diskpart

If you need to delete a recovery partition, replace "delete partition" with "delete partition override".

Bonus Tip:

To quickly delete all existing partitions on a disk, you can use the Diskpart utility, and follow the instructions provided in the link "How to Use Diskpart to Delete All Partitions".

To Cleanup or Erase Disk:

If you're about to wipe everything from your hard drive or SSD, the Diskpart Clean command is exactly what you need. To do this, you can follow a series of steps: first, open Command Prompt as an administrator, then type "diskpart" and press Enter to open the Diskpart tool, next type "list disk" and press Enter to list all available disks, identify the disk you want to clean and type "select disk X" (where X is the number of the disk you want to clean), then type "clean" and press Enter to clean the selected disk. This will completely erase all data on the disk, so make sure to back up any important files before proceeding.

Clean all paritions on disk with diskpart

If you need to continue using the disk for other purposes, you can revert to the first guide to Create Partition with Diskpart on the disk.

#4. Use Diskpart to Convert Disk from MBR to GPT or GPT to MBR

Applies to: Change disk type, convert MBR to GPT or GPT to MBR using Diskpart.

Convert disk to mbr or gpt using Diskpart

Bonus Tip: 

Note that Diskpart will remove all existing partitions on a disk before converting its disk type to another one, making it a potentially data-losing solution. For a seamless conversion, consider using a third-party disk conversion tool, which can help you successfully convert a GPT disk to MBR without losing any data.

#5. Other Hot Commands to Manage Partitions with Diskpart

Alongside creating, formatting, cleaning, or converting disk partitions, Diskpart commands can also be used to extend, shrink, or make an active partition.

To Extend Partition with Diskpart:

Extend partition using Diskpart

To Shrink Partition with Diskpart:

Shrink partition using Diskpart

To Mark Partition as Active with Diskpart:

Set partition active usign diskpart

Aside from using third-party software, you can also use Diskpart command lines to merge partitions, hide partitions, and even show hidden partitions.

Diskpart Alternative Free Download

While Diskpart is a free tool for Windows users to manage disks, its complexity can be a barrier for those with limited computing skills. A more user-friendly alternative is Qiling Partition Master Free, which offers reliable disk partition features that can fulfill various requests with simple clicks, making it a suitable replacement for Diskpart.

Bonus Tip:

If you're looking for free and equal tools to manage disk partitions, you can check out the best Diskpart alternatives for Windows 11, 10, 8, 7.

How to Use Diskpart to Fix Device Errors 

The Diskpart Utility can also be used to resolve common device errors, such as a storage device becoming RAW or a hard drive becoming read-only.

If you happen to have the same issue on your storage devices, follow the tips here, and you'll make your device work normally again:

#1. Fix Drive Read Only with Diskpart

Command: attributes disk clear readonly command

Applies to Fix: hard drive partition or storage devices show Read-only.

Step-By-Step Guide:

Step 1. To open Diskpart, click the Start menu, type 'cmd' in the search box, and hit Enter. Then, in the command prompt, type 'diskpart' and hit Enter.

Step 2. Type list disk and hit Enter.

Step 3. 1. Select the disk you want to format and hit Enter. (Replace * with the number of your disk, which is read-only.)

Step 4. Type attributes disk clear readonly and hit Enter.

Fix device read only issue with Diskpart

LEARN MORE

The Disk Read Only error can be caused by various reasons, and aside from using Diskpart, other solutions include modifying the Registry, using read-only removal software, and other methods to fix the issue on your device. You can learn more about 5 methods to change a drive from read-only to read and write by following this link.

#2. Convert Device from RAW to NTFS

Command: chkdsk, format FS=NTFS

Applies to Fix: USB, hard drive, or external disk becomes RAW, inaccessible.

If you have essential data saved on a RAW device, you can use reliable data recovery software to scan and restore all content from the device first.

Step-by-Step Guide: 

Step 1. Open Diskpart.

Step 2. 1. Open Command Prompt as Administrator. 2. Type `chkdsk E: /f /r /x` and hit enter.

Fix device becoming RAW issue with diskpart

Step 3. Type list partition and hit Enter.

Step 4. Run the command select partition * and hit Enter. (Replace * with the number of the RAW partition.)

Step 5. Type format fs=NTFS quick and hit Enter.

LEARN MORE

Aside from Diskpart, you can also apply disk management or a third-party disk partitioning software to get rid of the RAW issue on your device, by visiting the link: Convert RAW to NTFS to learn more details.

Troubleshooting Diskpart Errors On Windows

Many Windows users, both experienced and beginner, have reported encountering strange error messages from the Diskpart utility in the command prompt window.

If you're experiencing Diskpart errors, don't panic! You can resolve the issue by following the troubleshooting steps provided, which will help you eliminate the errors and get Diskpart functioning normally again.

Error 1: Diskpart I/O Device Error

Error message of I/O device error in Diskpart

Troubleshooting: Fix DiskPart I/O Device Error in Windows 10/8/7

Error 2: Diskpart Has Encountered an Error, Access Is Denied

Diskpart has encountered an error

Troubleshooting: How to Fix Diskpart Has Encountered an Error Access Is Denied Error

Error 3: Diskpart Failed to Clear disk Attributes

Diskpart failed to clear disk attributes

Troubleshooting: How to Fix Diskpart Failed to Clear Disk Attributes Error

Error 4: The System Cannot Find The File Specified

System cannot find the file specified

Troubleshooting:The "System Cannot Find The File Specified" error can be resolved with 8 fixes. Firstly, ensure the file path is correct and the file exists.

Error 5: Virtual Disk Service errors in Disk Part

Clean is not allowd with virutual disk service error

specified disk is not convertable with virtual disk service error

Troubleshooting: How to Fix DiskPart Virtual Disk Service Errors 

Conclusion

This page provides an in-depth look at Diskpart, including its capabilities, benefits, and common commands. Diskpart is a powerful tool that can perform various tasks, and its advantages include enhanced data management, improved system performance, and increased flexibility.

This page will guide you through mastering Diskpart commands to manage your hard drive partitions and external storage devices. By following this page, you'll learn how to effectively utilize Diskpart commands to manage your hard drive partitions and external storage devices.

You can apply some troubleshooting fixes to eliminate normal device errors like Read-only, or the device becomes RAW and makes your device function normally again.

For beginners, using Diskpart can be overwhelming, but there's an alternative. Qiling Partition Master Free is a helpful tool that can assist you in managing your disk partitions, saving your device from potential errors and bringing life back to your disk partitions.

Related Articles


Is this information helpful?     

What can we do to improve this information? (Optional)
Refresh Please enter the verification code!