Using the diskpart in Command Prompt/Windows Powershell

Rob574188

PC Specialist
Hi All,

I've had a few people come to me at PC Specialist with issues with the latest windows updates adding a drive letter to things that dont really need a drive letter. For this reason I thought I would put together a few little bits regarding Diskpart.

Diskpart can be a useful tool for various reasons, this is a tool that can be used to format and manage drives/volumes in your system.

A quick warning before I go into anything. It is possible to do a lot of "damage" if you perform the wrong commands to the wrong drives, it could be that you accidentally format some of your important data so do be careful when using this tool. I would not advise using this tool to edit your active windows partitions in any way.

First, you will want to launch either Command Prompt or Powershell as admin, to do this I generally just search for the relevant item, right click it in the list of results and select "run as administrator".

In here, as many of you will know, you can run commands by typing the relevant command and hitting enter.

To launch the diskpart tool simply type diskpart and press Enter. Typing Exit will take you back out of the diskpart tool to the command prompt.

In here you can launch numerous different commands, I will include some below and some potential uses but please feel free to add any you might find useful that I may have missed.

Listing and selecting available disks/volumes

Type list disk for a list of disks in the machine. This is useful if you are looking at having an effect an entire disk. An example would be looking to format a secondary storage drive.

Type list volume for a list of volumes in the machine, this is useful if you are looking at having an effect a specific volume. An example of this is if you have a partition on a drive that you are looking to format.

Type select disk # or select volume # replacing the "#" with the disk/volume you are looking to effect.

Assigning and removing drive letters

First select the volume you are looking to effect.

To assign a letter type assign letter=# replacing the "#" with the letter you want to assign. This is useful for if you have a volume without a label that you would like to access in the file explorer. Note that some windows partitions are not assigned due to them being recovery/system partitions, assigning a letter to one of these isn't generally a problem but can give you annoying "your disk is almost full" notifications.

To remove a letter type remove letter=# replacing the "#" with the letter you want to assign. This is useful in the case that a partition should not be visible to the file explorer or if a windows update has decided that one of your system partitions wants to be assigned a drive letter, usually resulting in the aforementioned and rather annoying "your disk is almost full" notifications.

Cleaning/Formatting a drive (here is where it gets risky, look before you leap with these commands, and make sure to ask us if you arent sure)

Typing clean will completely remove all information from a drive/volume and unallocate the resulting space, this can be useful if you are looking to install an Operating system (If you boot to the command prompt on a windows recovery media).

Typing format will remove all the data from the drive but leave the drive allocated. Useful if you are looking to clear a particular partition but are looking to use it as normal.

There are a fair few other commands so this is not by any means an exhaustive list. Again, please feel free to add to this if you come across anything.
 

ubuysa

The BSOD Doctor
Diskpart is a massively useful, but as RobPCS says, very dangerous if used wrongly. It really is like holding a loaded gun. Ask for help on here if you're not absolutely sure what you're doing with diskpart.

If your only problem is a drive letter assigned to one of the normally hidden UEFI partitions (typically the 'Recovery' partition) then a much safer way to remove it is to use the Windows Disk Management tool....

Right-click on the 'start' icon and select Disk Management from the menu.

Scroll down to the drive that has incorrectly been assigned a drive letter in the 'images' of the drives at the bottom.

Right-click on the partition that has wrongly been assigned a drive letter and select Change Drive Letter and Paths... from the menu.

In the Window that opens the drive letter will be highlighted, so simply click the Remove button and the drive letter will be removed, making the partition hidden once more. Make very sure you've picked the right drive and partition though!
 
Top