Disk Management Tool is a useful and efficient tool for managing Windows disks and partitions, but it is not as powerful as Diskpart. This command line tool lets you delete, create and modify partitions on any hard drives or USB drives that your computer can detect.
We recommend using the Disk Management Tool in most situations, but if Windows won’t start properly or if you prefer to use the PowerShell terminal, Diskpart is the perfect alternative. Here are some of the most common Diskpart commands to help you learn how to use Diskpart effectively.
How to use Diskpart
If you want to use Diskpart, you need to open a Windows Command Prompt or PowerShell Terminal. Diskpart is a destructive tool, so you need to open a terminal window with appropriate administrative privileges.
- To open Diskpart in Windows, right-click the Windows Start Menu button and select Windows PowerShell. (Administrator).
- In an administrator-level PowerShell terminal (or similar Windows command prompt), type diskpart and press Enter.
- The Diskpart tool starts up in the window, ready to use. Type exit when prompted for “DISKPART>” and press Enter when you’re done using it.
- Diskpart is also available for users who boot into the Windows Recovery Environment, which is available when booting the computer using Advanced Startup. in Settings> Windows Update and Security> Recovery.
- Click Restart Now to download WinRE.
In this article we’ll go over some of the more common Diskpart commands, but if you want to quickly see a complete list of the available Diskpart commands, type help at the DISKPART> prompt and press Enter.
List existing hard drives, folders, and partitions
With Diskpart open, the first thing you need to do is check the current structure of your hard drives and attached storage.
- At the DISKPART> prompt, type list disk and press Enter. It will list all the available drives (including hard drives, USB drives, SD cards, etc.) that your computer can currently detect.
- Starting from scratch, Diskpart will list all found disks. You will need to remember the disk number (for example, “0†for your Windows hard drive) in order to use it with future Diskpart commands.
- Along with a list of disks, you can also ask Diskpart for a list of detected volumes. At the DISKPART> command prompt, enter a list of volumes.
- Diskpart can also let you list individual hard disk partitions (some of which may be the same as the volumes listed with the “list volume” command). First you will need to select your hard drive using the list disk command.
- At the DISKPART> prompt, enter select disk followed by the disk number (for example, select disk 0). Diskpart will confirm that the drive is selected at this point.
- After selecting the drive, enter the list of partitions. This will display a list of the current partitions on your disk. From here you will be able to delete or modify these partitions using the partition number in the following Diskpart command.
Delete a hard drive partition or volume using Diskpart
The hard disk (disk) is divided into partitions, which often coincide with the specified volumes. If your hard drive is divided into several partitions or volumes and you want to remove one of them, you can do this using the Diskpart commands.
– / pre>
- Select hard disk using select disk.
- At the DISKPART> prompt, enter a list of partitions, then select partition #, replacing # with your partition number.
- After selecting a section, enter delete section. Diskpart will confirm if the partition was deleted later.
- You can also delete disk volumes directly if you like. Enter the volume list, find the selected volume number, then enter select volume #, replacing # with your volume number.
- Enter “delete volume” to completely delete the volume. Diskpart will later confirm if the command was successful or not.
Completely wipe your hard drive with Diskpart Clean
Instead of deleting individual volumes or partitions on the disk, you can completely erase the hard disk using the Diskpart clean command. You can also use this command if you want to erase a USB stick that is ready to be formatted.
You won’t be able to do this on your system drive (and won’t want to!) If you don’t use Diskpart when installing Windows
- At the DISKPART> prompt, select the drive you want to erase by typing select disk #, replacing # with your disk number. If you don’t know your disk number, first enter list disk.
- If you are sure you want to completely erase the disk (deleting all volumes / partitions on the disk), type clean and press Enter. You won’t be prompted for confirmation, so be sure to do this before starting.
- Diskpart will confirm that the disk has been “cleaned up” and is ready to create new partitions.
Create and format new hard drive partitions
With a “blank” disk in place, you are ready to create a partition in free space with the Diskpart create partition command. You can then format this new partition to a Windows-friendly file system such as NTFS or FAT32 using the Diskpart format command.
- Start by selecting the selected disk with select disk #, replacing # with your disk number (and using the disk list to find your disk number if you don’t know.)
- With a disk selected, enter create partition primary to create a partition using all the space on that disk.
- If you want to create a partition that only takes up a fraction of the free space (which allows you to create more than one partition), enter create partition primary size = X instead, replacing X with the size of the partition, measured in megabytes. (for example size = 1024 for 1 GB of space).
- Enter a list of partitions to make sure your new partition is listed, then type select partition 1 to select it. Mark the section as active by typing active in the “DISKPART>” line. This is required if you want to use it as a boot disk.
- To quickly format the drive to NTFS, enter format fs = NTFS label = Y quick. You can replace Y with whatever shortcut you want to use.
- After formatting, Windows will likely automatically assign a drive letter. If not, enter assign the letter Z, replacing Z with the letter of the free disk.
Extend Hard Disk Drive Size
If you have an existing hard disk volume that does not take up all the free disk space and you want to grow it, the Diskpart commands allow you to do this.
- Start by selecting the selected disk with select disk #, replacing # with your disk number (and using list disk to find your disk number if you don’t know.)
- Type list volume to list all available volumes on your computer, then type select volume #, replacing # with the volume you want to expand.
- Enter extension to expand it to the maximum available size. Diskpart will confirm if the expansion command worked correctly. Confirm that the volume has grown by typing the list number a second time.
Diskpart has other options available, as the help command briefly explains. If you would like more information on how to use Diskpart, Microsoft has more information on Diskpart support.
–
Comment on “How to Use DiskPart Utility in Windows”