It is no secret that the Windows GUI does make certain things harder than they need to be, one of these things in particular is formatting drives using Disk Management. Although 90% of the time disk management will work fine you will run into cases where the partition is marked as System Reserved and you can’t delete it or if you are trying to reformat a USB that has had ESXi installed on it you will be unable to delete some of the partitions, these are just the first examples that came to mind, there are likely many more.
Well thankfully DiskPart.exe has you covered with the following commands you will be able to get your disks working the way that you want.
To open diskpart just open a command prompt and type:
diskpart.exe
Once you have this open (it may prompt for admin rights) we can get started with the commands, our first command will show you all the disks that are in your system and it is simply:
list disk
Our next command will select the disk that you want to work on, for our example it is disk 2:
select disk 2
This command will clear the “Read Only” flag on a hard drive, I have only seen this be a problem during a Windows Install however you can launch diskpart from there also by using Shift + F10.
attributes disk clear readonly
In the following command we are going to remove any partitioning information from a disk in order to use it new out of box. Make sure that you have the disk that you want selected as you cannot undo this action.
clean
The second part to this command is to write over the previous partitions with a layer of zeros, and the command for that is just:
clean all
These are just a couple of the most used disk part commands