---
title: "Mastering Diskpart : Erase and Partition Volumes with Ease"
description: "Master Diskpart to manage disks, volumes, and partitions. Includes extending, shrinking and deleting volumes, creating partitions, and cleaning disks."
canonical: "https://adamtheautomator.com/diskpart/"
---

# Mastering Diskpart : Erase and Partition Volumes with Ease

> Master Diskpart to manage disks, volumes, and partitions. Includes extending, shrinking and deleting volumes, creating partitions, and cleaning disks.

Source: https://adamtheautomator.com/diskpart/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Mastering Diskpart : Erase and Partition Volumes with Ease](https://adamtheautomator.com/wp-content/uploads/2021/05/How-to-Partition-and-Erase-Windows-Volumes-with-Diskpartx.jpg)

# Mastering Diskpart : Erase and Partition Volumes with Ease

[![](https://secure.gravatar.com/avatar/d0b9d42e21e5622713f8b693aa5c0f9244d5f7dd200ed29b8398f52dee5de337?s=192&d=mm&r=g)Adam Bertram](https://adamtheautomator.com/author/adam-bertram/)3 October 20237 min. read

Categories: [Uncategorized](/category/uncategorized/), [IT Ops](/category/it-ops/)

Tags:[Disk Management](/tag/disk-management/)[Windows 10](/tag/windows-10/)

Table of Contents

*   [Diskpart Prerequisites](#h-diskpart-prerequisites)
*   [How to Access Diskpart in Windows](#h-accessing-diskpart)
*   [Selecting a Disk](#h-selecting-a-disk-in-diskpart)
*   [Selecting a Volume](#h-selecting-a-diskpart-volume)
*   [Shrinking a Volume](#h-diskpart-shrinking-a-volume)
*   [Creating a Partition](#h-creating-a-diskpart-partition)
*   [Creating and Formatting a Volume](#h-creating-and-formatting-a-volume-with-diskpart)
*   [Extending a Volume](#h-extending-a-diskpart-volume)
*   [Extending a Windows Volume](#extending-a-windows-volume-with-diskpart)
*   [Deleting a Volume or Partition](#h-deleting-a-volume-or-partition-with-diskpart)
*   [Using Diskpart to Clean an Entire Disk](#h-diskpart-cleaning-an-entire-disk)
*   [Conclusion: Mastering Diskpart for Volume and Partition Management](#h-diskpart-conclusion)

If you’re tasked with managing disks, partitions, and volumes on your Windows machine, then mastering [Diskpart](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/diskpart) is essential. Diskpart is a powerful disk management tool that allows you to manipulate [disks, partitions, and volumes](https://www.maketecheasier.com/difference-between-disk-drive-volume-partition-image/) in Windows, all through the command line interface.

Not a fan of reading? Watch this related video tutorial!”

**_Video not visible? Make sure to disable your ad blocker._**

In this Diskpart tutorial, you’ll learn how to shrink, extend, and delete volumes, as well as manage unallocated space.

Ready to dive in? Let’s get started!

## Diskpart Prerequisites

To follow the demos in this Diskpart guide, make sure you have the following:

*   A machine running Windows 7 or higher. All demos will use Windows 10, but the techniques should apply to older versions as well.
*   A local user account with [administrator privileges](https://support.microsoft.com/en-us/windows/create-a-local-user-or-administrator-account-in-windows-20de74e0-ac7f-3502-a866-32915af2a34d) for full access to Windows storage management features.

## How to Access Diskpart in Windows

Unlike many command-line tools, Diskpart is interactive. Instead of running the `diskpart` command multiple times, you initiate it once to start an interactive session.

To launch the Diskpart interface, open [Windows PowerShell as an administrator](https://adamtheautomator.com/powershell-run-as-administrator/).

> _Cmd.exe can also be used, but since PowerShell is the modern successor, this tutorial focuses on using PowerShell._

Once in PowerShell, initiate a Diskpart session by typing `diskpart`. You’ll know you’re in when you see the **DISKPART>** prompt, as illustrated below.

![Diskpart](https://adamtheautomator.com/wp-content/uploads/2021/05/diskpart.png)

Accessing Diskpart in Windows

To exit the Diskpart interface, simply type `exit`.

## Selecting a Disk

Many sections in this Diskpart tutorial involve selecting a disk. To avoid redundancy, here’s how you can select a disk whenever it’s mentioned.

If you’re working with multiple disks on your Windows system, your first task in Diskpart is to specify which disk you wish to manipulate. To do so, list all available disks within your Diskpart session.

```powershell
list disk
```

The `list disk` command will display all of the disks that your Windows operating system currently recognizes. To proceed, you’ll need to select a disk by providing the disk number. For instance, in the command below, we are selecting disk number `0` using Diskpart.

```powershell
select disk 0
```

Once Diskpart has selected the disk, a message similar to the one below will appear, indicating that the disk is now selected. This will return you to the Diskpart prompt, and you’re ready to start managing the disk’s partitions and volumes.

![diskpart selecting a Disk](https://adamtheautomator.com/wp-content/uploads/2021/05/sel-disk0.png)

Selecting a Disk with Diskpart

## Selecting a Volume

Just like you select a disk, Diskpart also enables you to select a volume. Below, we’ll explain what it means when the tutorial instructs you to _select a volume_.

When it comes to volumes, the process is similar to disks: list the available volumes and then choose the one you’d like to manipulate using Diskpart.

![Selecting a Volume](https://adamtheautomator.com/wp-content/uploads/2021/05/sel-vol2.png)

Selecting a Volume

## Shrinking a Volume

Now that we’ve covered the basics, let’s delve into something practical—shrinking a volume using Diskpart.

Shrinking a volume with Diskpart will convert unused space from the selected volume into [unallocated space](https://answers.microsoft.com/en-us/windows/forum/windows_10-files-winpc/unallocated-space-vs-free-space/42e7cf7e-ce12-4028-84ea-84de658e3a58), which is essentially space that doesn’t belong to any partition.

> _If you’re following along, be sure you have a disk that has some unused space with an unformatted volume or one formatted as NTFS (see Creating and Formatting a Volume). Also, ensure the partition isn’t an [Original Equipment Manufacturer (OEM) partition](https://www.urtech.ca/2018/12/everything-you-need-to-know-about-healthy-oem-partitions-and-how-to-easily-remove-them/), [Extensible Firmware Interface (EFI) system partition](https://helpdeskgeek.com/help-desk/what-is-the-system-reserved-or-efi-partition/), or [recovery partition](https://www.computerhope.com/jargon/h/hiddpart.htm). This tutorial will use Volume 2 labeled as C._

1.  Launch Diskpart.

2\. Choose a disk that has some unallocated or unused space.

3\. Next, identify a volume by running the `list volume` command, or execute the `detail disk` command to view information about the disk and its associated volumes. Volume 2 below is ideal for shrinking, given its NTFS formatting.

![Viewing Volumes Inside The Selected Disk](https://adamtheautomator.com/wp-content/uploads/2021/05/detail-disk.png)

Viewing Volumes Inside The Selected Disk

4\. After selecting the volume, find out the maximum amount it can be shrunk by executing the `shrink querymax` command in Diskpart.

In this tutorial, you’ll discover how to reduce your example disk volume by 14GB using Diskpart. See how it’s done below.

![Diskpart: Viewing Maximum Space to Shrink](https://adamtheautomator.com/wp-content/uploads/2021/05/querymax.png)

Viewing Maximum Space to Shrink with Diskpart

5\. Enter the amount of space you’d like to reduce by typing `shrink desired=#`, replacing # with your chosen amount in megabytes. The example below demonstrates how to do this.

> _`10240` megabytes [is equivalent to 10GB](https://www.calculatorsoup.com/calculators/conversions/computerstorage.php)._

If other applications might be utilizing the disk volume, execute the `shrink` Diskpart command below with a `minimum` parameter. This parameter acts as a fallback if your `desired` size is not attainable.

```powershell
shrink desired=10240 minimum=8192
```

As you can see, Diskpart successfully reduces the chosen volume by 10GB.

![Shrinking Volume with Diskpart](https://adamtheautomator.com/wp-content/uploads/2021/05/shrink-success.png)

Successfully Shrinking Volume

## Creating a Partition

After you’ve reduced a volume, that space becomes unallocated. To confirm the unallocated space in Diskpart, you can list the disks again using the `list disk` command. Look under the **Free** column to find this space.

![Viewing Unallocated Space](https://adamtheautomator.com/wp-content/uploads/2021/05/check-unallocated.png)

Identifying Unallocated Space with Diskpart

Unallocated space does not belong to any partition. To make use of this space, you’ll have to create a Diskpart partition from it.

To initiate a new volume from unallocated space using Diskpart:

1.  Open Diskpart on your computer.

2\. Use `list disk` to view all available disks. Select the disk with unallocated space to transform it into a separate Diskpart volume.

![Selecting Disk in Diskpart to Manage](https://adamtheautomator.com/wp-content/uploads/2021/05/select-disk0.png)

Choosing Disk for Diskpart Management

3\. Execute the `create partition` Diskpart command to set up a 10GB partition on the selected disk.

```powershell
create partition primary size=10240
```

![Creating Partition Out of Unallocated Space with Diskpart](https://adamtheautomator.com/wp-content/uploads/2021/05/create-partition-primary.png)

Creating Partition Out of Unallocated Space

> _If you plan to install an operating system on your newly created partition, make the partition bootable using the `active` parameter._

## Creating and Formatting a Volume

Once you’ve created a partition using Diskpart, it’s time to format it. Formatting the partition creates a volume, enabling you to use the space for storage.

With Diskpart, once you create a partition, the tool automatically focuses on the new partition. To verify this, you can run the `list partition` command. Below, you’ll see that `Partition 4` is currently selected, as indicated by the asterisk (`*`) next to the partition number.

![Viewing List of Partitions](https://adamtheautomator.com/wp-content/uploads/2021/05/selected-partition.png)

Viewing List of Partitions

1\. To start, first determine which [file systems](https://kb.wisc.edu/helpdesk/page.php?id=11300) are supported by your partition. Use the Diskpart `filesystems` command for this. As you can see below, the selected partition (Partition 4) supports NTFS, FAT32, and REFS.

> _A file system manages how files are named, stored, and retrieved, letting you distinguish each file from one another._

![Viewing Supported File Systems](https://adamtheautomator.com/wp-content/uploads/2021/05/filesystems.png)

Viewing Supported File Systems

2\. Next, perform a [quick format](https://smallbusiness.chron.com/quick-format-vs-full-format-new-external-hard-drive-79123.html) (`quick`) on the partition. Opt for NTFS (`fs=NTFS`) and label the volume (`label="Backup"`) as you see fit.

> _By default, Diskpart retains control of the session until the format is complete. Use the `nowait` parameter to immediately regain console control._

```powershell
format fs=NTFS label="Backup" quick
```

![Formatting Partition to a Volume with Diskpart](https://adamtheautomator.com/wp-content/uploads/2021/05/formatted-1.png)

Formatting Partition to a Volume

3\. Optionally, you can assign a drive letter to the newly-created volume using Diskpart’s `assign` command. Check out your new volume by running the `list volume` command.

```powershell
assign letter=F
 list volume
```

![Assigning Drive Letter with Diskpart](https://adamtheautomator.com/wp-content/uploads/2021/05/assigned2.png)

Assigning Drive Letter

## Extending a Volume

If you’re running low on disk space and have some unallocated space next to a Windows volume, you can use Diskpart to extend that volume. Extending a volume with Diskpart is essentially the opposite of shrinking one.

## Extending a Windows Volume

Here’s how to extend a volume using Diskpart:

1.  Open Diskpart on your Windows machine.

2\. Use the command `list disk` to find a disk with enough unallocated space for extending your desired volume.

> _If you don’t have enough unallocated space to extend, you may skip this whole section and clean up your disk to get additional space._

Related:[9 Methods to Clean Up Windows 10 for More Disk Space](https://adamtheautomator.com/disk-cleanup-cmd/)

Next, select the disk that has unallocated space adjacent to it. For this Diskpart tutorial, we’ll use disk 0 as an example.

![Diskpart Extending Volume](https://adamtheautomator.com/wp-content/uploads/2021/05/select-disk0-1.png)

Selecting Disk in the System to Extend Volume with Diskpart

3\. List all volumes by executing `list volume` or you can run `detail disk` to find the specific volume you wish to extend. In this guide, we’ll work with Volume 2.

![Viewing Selected Disk Details](https://adamtheautomator.com/wp-content/uploads/2021/05/detaildisk.png)

Viewing Selected Disk Details for Extending with Diskpart

4\. Once you’ve identified the volume, select it and use Diskpart’s `extend` command to expand it. For instance, to extend Volume 2 by 10GB, you would use the command as shown below.

Congratulations! If the Diskpart extend operation was successful, you now have an extra 10GB of space on your volume.

![Selecting Volume to Extend](https://adamtheautomator.com/wp-content/uploads/2021/05/extendvol2.png)

Successfully Extending a Volume with Diskpart

## Deleting a Volume or Partition

If you have multiple volumes or partitions and wish to consolidate space, Diskpart can also be used to delete them and convert them into unallocated space. If, however, your system has only a single-volume drive, deleting is not advisable.

Related:[Nine Effective Ways to Free Up Space on Windows 10](https://adamtheautomator.com/disk-cleanup-cmd/)

> _To ensure data safety, always have all critical data [backed up](https://support.microsoft.com/en-us/windows/backup-and-restore-in-windows-352091d2-bb9d-3ea3-ed18-52ef2b88cbef) before deleting any volume._

Deleting a volume with Diskpart follows a similar procedure to the steps you’ve learned for extending and shrinking volumes.

1\. Start by selecting the disk that contains the partition or volume you want to delete using the `select` command in Diskpart.

2\. List the Diskpart partition or volume with the `list` command.

```powershell
list partition
list volume
```

3\. Select the Diskpart partition or volume you aim to remove.

```powershell
select partition #
select volume #
```

4\. Execute the Diskpart `delete` command to remove the partition or volume.

```powershell
delete volume
delete partition
```

![Diskpart Successfully Deleted a Volume](https://adamtheautomator.com/wp-content/uploads/2021/05/del-volume-1.png)

Successfully Deleted a Volume

![Successfully Deleted Partition](https://adamtheautomator.com/wp-content/uploads/2021/05/deleted-partition.png)

Successfully Deleted Partition

## Using Diskpart to Clean an Entire Disk

If you have a disk without useful data and you’re opting for a clean slate, Diskpart can turn that disk into unallocated space with the `clean` command.

> _Cleaning a disk erases everything inside the selected disk and cannot be undone. If the disk is inaccessible and has important files in the disk, give [Windows File Recovery Tool](https://adamtheautomator.com/windows-file-recovery/) a try to recover files after cleaning the entire disk._

To initiate Diskpart’s clean command on an entire disk, select the disk you wish to clean and simply run `clean`.

![Successfully Cleaned Entire Disk](https://adamtheautomator.com/wp-content/uploads/2021/05/clean-success.png)

Successfully Cleaned Entire Disk

> _If you intend to create another partition from a cleaned disk, run the `create partition primary` command without the `size` parameter (See Creating a Volume/Formatting a Partition)._

## Conclusion: Mastering Diskpart for Volume and Partition Management

In this tutorial, you’ve honed your skills in using Diskpart for creating partitions, extending, deleting, and shrinking volumes, as well as cleaning an entire disk. Diskpart is a versatile tool for controlling partitions and volumes on your disks.

So, will you turn to Diskpart for managing disk partitions and volumes the next time?

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fdiskpart%2F&text=Mastering%20Diskpart%20%3A%20Erase%20and%20Partition%20Volumes%20with%20Ease)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fdiskpart%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fdiskpart%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2024/03/terragrunt.png)

### [Keeping Terraform Maintainable with Terragrunt](/terragrunt/)

Discover Terragrunt and embrace the power to simplify Terraform workflows—Ensure maintainability and organization of your infrastructure today!

![](https://adamtheautomator.com/wp-content/uploads/2023/01/wireguard-raspberry-pi.jpg)

### [How to Set Up a WireGuard Raspberry Pi VPN Server](/wireguard-raspberry-pi/)

Learn how to use a WireGuard Raspberry PI VPN server and create a secure connection for outside your office in a compact package!

![](https://adamtheautomator.com/wp-content/uploads/2022/02/Network-Troubleshooting-from-the-Command-Line-with-TShark.jpg)

### [Network Troubleshooting from the Command-Line with TShark](/tshark/)

Learn how to set up TShark on your machine to capture packets for effective network troubleshooting in this step-by-step tutorial!

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
