Using Diskpart to create, delete, clean or extend disk partitions | TechTarget (2024)

For basic disk operations on Windows systems, administrators can use diskpart, a command-line utility that remains useful for many different drive-related jobs more than 20 years after it was released.

Microsoft included the free disk management tool in Windows starting in 1999 with the Windows 2000 operating system. Diskpart scans for newly added disks, but it can also create, delete and resize drive partitions, and assign or reassign drive letters. Diskpart also works with drive volumes, virtual hard disks and removable media such as USB flash drives.

Microsoft continues to develop diskpart, and the latest version of the utility features 38 commands. To use diskpart, you list the objects, such as disks or partitions, and then select the object to change it.

Using Diskpart to create, delete, clean or extend disk partitions | TechTarget (1)

Using diskpart requires understanding data storage terminology

Diskpart use requires a basic understanding of Windows disk terminology. A basic disk is a storage device, such as hard drives, solid-state drives and USB flash drives, which you format with a Windows file system.

A basic disk can hold one or several partitions. A partition is a logical structure confined to a single disk.

A volume is a construct of the operating system that consists of one or more partitions that can span one or more disks.

Using diskpart

You should be careful when using diskpart because there is no undo function if you select the wrong object. Also, once a command is entered, even a destructive one, diskpart does not ask for confirmation before it runs. For example, if you perform an errant diskpart delete partition operation, you must use another utility, such as third-party disk management program, to recover the data or use a backup image to restore the drive.

Follow these tips to avoid issues when using diskpart:

  • Do not use diskpart until you back up the disk you plan to modify.
  • Exercise caution when using diskpart on systems that use dynamic disks, an older technology with advanced features that gave administrators a way to make a volume that spanned several disks.
  • Check with your hardware vendor before using diskpart.

Creating a partition using diskpart

Using diskpart to partition your disk can help increase the I/O performance of hard disks newly added to a RAID array. The documentation for many server applications, such as Exchange Server, recommends using diskpart to create the primary or extended partitions. You can use a primary partition as the system partition; you can only use an extended partition for additional logical drive assignments.

The diskpart create command makes disk partitions, volumes on a single disk or multiple disks, and virtual hard disks.

For this and all following commands, you need to open the command prompt before you run diskpart. Type cmd from the run command window from the Windows search box or the run command dialog box that you open with the Windows+R key combination.

To create a partition:

  1. At a command prompt, type: diskpart
  2. At the DISKPART prompt, type list disk (Note the drive number you wish to manipulate.)
  3. At the DISKPART prompt, type: select disk 0 (This selects disk to edit; make sure to type in the disk number from step two.)
  4. At the DISKPART prompt, type create partition primary size=10000 (The size parameter refers to the size in megabytes. In this case, 10000 equals 10 GB. Change the word primary to extended to create an extended partition. If you do not set a size, then all available space on the disk will be used for the partition.)
  5. At the DISKPART prompt, type assign letter=D (Choose an unused drive letter.)
  6. At the DISKPART prompt, type exit
  7. From the command prompt, use the format command, or the Disk Management utility in Windows or any disk format tool to format the drive. You would typically use the NTFS file system during the initialization process.
Using Diskpart to create, delete, clean or extend disk partitions | TechTarget (2)

Extending a partition using diskpart

When it comes to adding space to a partition or volume, this method is superior to configuring two disks. Dynamic disk extensions only concatenate the newly added space, meaning they merely add the disk space to the end of the original partition without restriping the data.

Concatenation isolates performance within each partition and does not offer fault tolerance when the partition is configured in a RAID array. Diskpart restripes your existing data. This is beneficial when the partition is set up in a RAID array, because the existing partition data spreads across all the drives in the array, rather than just adding new space to the end, like the Disk Management utility.

To extend a partition:

  1. Verify that contiguous free space is available on the same drive and that free space is next to the partition you intend to extend with no partitions in between. Be sure you have a full backup before trying this method.
  2. At a command prompt, type diskpart
  3. At the DISKPART prompt, type select disk 0 (Selects the disk.)
  4. At the DISKPART prompt, type select volume 0 (Selects the volume.)
  5. At the DISKPART prompt, type extend (If you do not set a size, then diskpart will use all available space on the disk.)
  6. At the DISKPART prompt, type exit
Using Diskpart to create, delete, clean or extend disk partitions | TechTarget (3)

Deleting a partition using diskpart

The delete command in diskpart removes dynamic disks, partitions, volumes and shadow copies. When you have multiple volumes on the disk or an unwanted partition, such as a recovery partition, this command will remove them and return them to unallocated space.

To delete a partition:

  1. At a command prompt, type diskpart
  2. At the DISKPART prompt, type select disk 0 (Selects the disk.)
  3. At the DISKPART prompt, type list partition
  4. At the DISKPART prompt, type select partition 4 (Selects the partition.)
  5. At the DISKPART prompt, type delete partition
  6. At the DISKPART prompt, type exit
Using Diskpart to create, delete, clean or extend disk partitions | TechTarget (4)

Creating a volume using diskpart

When using dynamic disks in Windows, you can create four volume types with diskpart: volume mirror, RAID-5 volume, simple volume and striped volume.

To create a simple volume:

  1. At a command prompt, type diskpart
  2. At the DISKPART prompt, type select disk 0 (Selects the disk.)
  3. At the DISKPART prompt, type create volume simple size=1000 (The size is in megabytes.)
  4. At the DISKPART prompt, type exit

Cleaning a disk using diskpart

When you have an entire disk to wipe clean, you can use the diskpart clean command to convert all the stored data into unallocated space. This operation deletes all data on the disk by writing zeros on each disk sector. Diskpart also removes all partition and volume information from the selected drive.

To clean a disk:

  1. At a command prompt, type diskpart
  2. At the DISKPART prompt, type select disk 0
  3. At the DISKPART prompt, type clean all
  4. At the DISKPART prompt, type exit

Other ways to use diskpart

For maintenance work that requires a bootable USB flash drive, you can use diskpart to format the partition and set up the file system on the removable drive. Administrators can also use diskpart in both the Windows Preinstallation Environment and Windows Recovery Environment to correct disk problems or set up the machine for deployment.

With the diskpart /s switch, administrators can run scripts to automate tasks associated with setting up Windows machines, such as configuring the disks for multiple systems, adding a recovery partition or wiping all data from a disk to return it to a factory state.

Sample code from the Microsoft site gives examples of how to develop a text-based script file administrators can call from diskpart and run automatically. IT workers can run several diskpart scripts, but Microsoft recommends building in a delay of 15 seconds after a script runs to prevent issues.

For an in-depth tutorial on how to use diskpart for preparing a Windows 10 system for deployment, this blog post on the SearchEnterpriseDesktop site provides detailed instructions to use diskpart with a script.

Using Diskpart to create, delete, clean or extend disk partitions | TechTarget (2024)

FAQs

How to delete and create partition using diskpart? ›

To delete a partition:
  1. At a command prompt, type diskpart.
  2. At the DISKPART prompt, type select disk 0 (Selects the disk.)
  3. At the DISKPART prompt, type list partition.
  4. At the DISKPART prompt, type select partition 4 (Selects the partition.)
  5. At the DISKPART prompt, type delete partition.
  6. At the DISKPART prompt, type exit.
Jul 20, 2021

Does diskpart clean remove partitions? ›

Cleaning or erasing a storage device removes all data and partitions from the drive. Please read all steps, instructions, and warnings before attempting the Diskpart Erase/Clean. Diskpart Erase/Clean will permanently erase/destroy all data on the selected drive.

How to extend partition using diskpart? ›

At the DISKPART prompt, type extend, and then press ENTER to extend the partition into all of the available disk space to the end of the drive. Or, type extend size=<size> to extend the selected volume by size megabytes (MB). Type exit, and then press ENTER to exit the command prompt.

How to solve diskpart has encountered an error? ›

Solutions
  1. A. Update Disk Driver.
  2. B. Run CHKDSK Command.
  3. CHKDSK command, when run with attributes /f and /r, fixes corruption (if any) on the hard drive. Also, it scans and marks down the bad sectors on the drive. ...
  4. C. ...
  5. Bootrec/fixmbr.
  6. Bootrec/fixboot.
  7. A. ...
  8. Create New Partition Using DiskPart Utility.

How do I create or delete a partition? ›

To create and format a new partition (volume)
  1. Open Computer Management by selecting the Start button. ...
  2. In the left pane, under Storage, select Disk Management.
  3. Right-click an unallocated region on your hard disk, and then select New Simple Volume.
  4. In the New Simple Volume Wizard, select Next.

How do I use diskpart to clean and format a drive? ›

Follow the steps below to format a drive:
  1. STEP 1: Open Command Prompt As Administrator. Opening the command prompt. ...
  2. STEP 2: Use Diskpart. Using diskpart. ...
  3. STEP 3: Type List Disk. ...
  4. STEP 4: Select the Drive to Format. ...
  5. STEP 5: Clean the Disk. ...
  6. STEP 6: Create Partition Primary. ...
  7. STEP 7: Format the Drive. ...
  8. STEP 8: Assign a Drive Letter.
Jul 12, 2023

What is the difference between clean and clean all diskpart? ›

Summing up the differences:

The clean command quickly deletes all existing partitions and data from a hard drive. 2. The clean all command line is to completely erase all disk partitions and content on the drive at once. It will make all partitions and data unrecoverable.

How to extend a hard drive partition? ›

In Computer Management, select [Disk Management]③. In Disk Management, right-click the existing volume you want to extend④, then select [Extend Volume]⑤. If there is no unallocated space, but you want to extend the existing volume, you are able to delete a separate volume, and then it will become unallocated space.

Why can't i delete partition using diskpart? ›

How to delete partition/disk with diskpart and force delete?
  1. Start cmd in admin mode, and type 'diskpart'
  2. type 'list disk'
  3. type 'select disk *'
  4. type 'list partition'
  5. type 'select partition *'
  6. type 'delete partition' (you may also try 'delete partition override' to force delete partition with diskpart cmd)

How long does diskpart clean all take? ›

A: "Clean all" command will take around an hour per 320GB to finish running since it performs a secure erase. Q: Does diskpart clean remove MBR?

How do I extend an extended partition? ›

The procedure to extend an extended or logical partition with fdisk starts with deleting both partitions. Then, we recreate the partition with the desired endpoint.

How to delete recovery partition using diskpart? ›

(2) Enter the following commands...
  1. DiskPart <<<Enter DiskPart.
  2. Select Disk 1 <<<Focus on Disk 1.
  3. List Part <<<Show its partitions.
  4. Select Part x <<<Focus on the MSR (16 or 128 MB) if it exists.
  5. Delete Partition Override <<<Delete it.
  6. Select Part y <<<Focus on the 532 MB partition.
  7. Delete Partition Override <<<Delete it.
Oct 4, 2023

How to repair disk using diskpart? ›

Let's use the diskpart command to make the drive available for scanning.
  1. Open Command Prompt. Type diskpart and press enter. ...
  2. In the new window, type list volume and hit enter.
  3. Select your main drive. ...
  4. Now type attributes disk clear readonly and hit Enter.
Sep 22, 2023

How do I clean up disk error? ›

Disk cleanup in Windows
  1. In the search box on the taskbar, type disk cleanup, and select Disk Cleanup from the list of results.
  2. Select the drive you want to clean up, and then select OK.
  3. Under Files to delete, select the file types to get rid of. To get a description of the file type, select it.
  4. Select OK.

How to reset using diskpart? ›

Steps to Erase and Clean a Drive Using Disk Part Command on Windows
  1. Press the Windows Key + X. Click Disk Management.
  2. Locate the Disk # for the drive.
  3. Press the Windows Key. Type cmd. ...
  4. Type diskpart. Press Enter.
  5. Type list disk. Press Enter.
  6. Locate the Disk #.
  7. Type Select Disk #. Press Enter. ...
  8. Type clean. Press Enter.
Dec 21, 2018

How do I create a system partition in diskpart? ›

Create System Volume, Primary Partition Using Diskpart

Step 1: Open CMD on your Windows computer. Step 2: Enter diskpart and then Type list disk. Step 4: Type the command create partition primary size=20480 to initialize a new partition with a size. Entering the above will create a primary system volume partition.

How do I remove a partition and make one drive? ›

Step 1: Search "Disk Management" at the Start Menu. Step 2: Right-click the drive or partition by clicking "Delete Volume" in the Disk Management panel. Step 3: Select "Yes" to continue the removal process. Then, you've successfully deleted or removed your Windows 11/10 disk.

How do I completely wipe a partition? ›

How to delete a partition from Disk Management
  1. Open Start.
  2. Search for Disk Management.
  3. Select the drive with the partition you want to remove.
  4. Right-click (only) the partition you want to remove and select the Delete Volume option.
Jan 3, 2023

Top Articles
20 Sneaky Ways to Save Money Today!
Travelex Insurance Review: Is it for Everyone?
Kostner Wingback Bed
Frank Lloyd Wright, born 150 years ago, still fascinates
Es.cvs.com/Otchs/Devoted
Encore Atlanta Cheer Competition
What is IXL and How Does it Work?
Corporate Homepage | Publix Super Markets
State Of Illinois Comptroller Salary Database
Alaska Bücher in der richtigen Reihenfolge
Ree Marie Centerfold
Buying risk?
How Many Cc's Is A 96 Cubic Inch Engine
Busted Newspaper S Randolph County Dirt The Press As Pawns
fort smith farm & garden - craigslist
Illinois Gun Shows 2022
Are They Not Beautiful Wowhead
Procore Championship 2024 - PGA TOUR Golf Leaderboard | ESPN
Straight Talk Phones With 7 Inch Screen
U Of Arizona Phonebook
MyCase Pricing | Start Your 10-Day Free Trial Today
D2L Brightspace Clc
Meet the Characters of Disney’s ‘Moana’
Cal State Fullerton Titan Online
Pronóstico del tiempo de 10 días para San Josecito, Provincia de San José, Costa Rica - The Weather Channel | weather.com
Biografie - Geertjan Lassche
Uky Linkblue Login
Donald Trump Assassination Gold Coin JD Vance USA Flag President FIGHT CIA FBI • $11.73
Ellafeet.official
Workboy Kennel
Japanese Pokémon Cards vs English Pokémon Cards
Roch Hodech Nissan 2023
Shaman's Path Puzzle
1987 Monte Carlo Ss For Sale Craigslist
Ixl Lausd Northwest
Greencastle Railcam
Mp4Mania.net1
The Land Book 9 Release Date 2023
New Gold Lee
Felix Mallard Lpsg
Gasoline Prices At Sam's Club
Ezpawn Online Payment
Giovanna Ewbank Nua
Jamesbonchai
Pathfinder Wrath Of The Righteous Tiefling Traitor
Scythe Banned Combos
Frontier Internet Outage Davenport Fl
The Sports Academy - 101 Glenwest Drive, Glen Carbon, Illinois 62034 - Guide
The Blackening Showtimes Near Ncg Cinema - Grand Blanc Trillium
855-539-4712
Aznchikz
Sdn Dds
Latest Posts
Article information

Author: Terence Hammes MD

Last Updated:

Views: 5740

Rating: 4.9 / 5 (69 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Terence Hammes MD

Birthday: 1992-04-11

Address: Suite 408 9446 Mercy Mews, West Roxie, CT 04904

Phone: +50312511349175

Job: Product Consulting Liaison

Hobby: Jogging, Motor sports, Nordic skating, Jigsaw puzzles, Bird watching, Nordic skating, Sculpting

Introduction: My name is Terence Hammes MD, I am a inexpensive, energetic, jolly, faithful, cheerful, proud, rich person who loves writing and wants to share my knowledge and understanding with you.