How to configure a new hard disk with the command line diskpart under Windows


Of course, you can format and partition hard disks or USB sticks under Windows, not only with the graphical user interface (GUI). Windows has been offering the tool diskpart for many years.

The question immediately arises again: Why the Command Line? Firstly, because you often don’t have a GUI at your disposal at all, e.g., with a server core or a Window PE CD. Secondly, the cmd regularly offers many more possibilities, and thirdly you can – as so frequently with the cmd – automate processes.

Open Diskpart

For a test scenario, we use a 5 GB hard disk, which we partition and format afterward with Diskpart. For this, we need a cmd with administrative rights.

Then you open the program diskpart. To get a small overview of the possibilities, you can call diskpart with the option help. You can get the first overview of all data carriers in the system by listing them.

list disk
With the command line tool diskpart you get all informations about the disk inside your windows system

Create a new volume

With the above command, you can list all disks. In our example, we want to create a new volume with the 5 GB disk 1. This volume should be assigned the drive letter E. Generally very helpful is the option help. Not only volumes can be created, but also partitions.

But what is the difference?

  • A partition is a number of sectors (areas) of a hard disk. In general, a distinction is made between primary and logical partitions. A boot partition must always be a primary partition, and only four primary partitions can be created on one disk. Logical partitions can be imagined as containers.
  • A volume is in principle a logical unit and can designate both a partition and a group of several partitions or hard disks. This is why it is possible to create RAID groups with it.

By the way, with every additional option you add to the Diskpart command, you can work your way through the command chain with help. This means that you can, e.g., extend the create partition command with help to get the next possible options.

create Partition help
How to configure an hard disk on windows - diskpart help

Now we create volume E: as described above

select disk 1
create partition primary size=5000
select partition 1
format fs=ntfs quick label="Work"
assign letter=E

As we can easily see now, a new volume has been created. The easiest way to see this is in the Windows Explorer. But you can also switch to the newly created volume with the command line tool. If no size is specified, the entire free memory space is automatically used.

How to create a new Volume with diskpart unter Windows
How to create a new Volume with diskpart unter Windows

Das könnte dich auch interessieren:

Der Blogbetreiber und Autor: Markus Elsberger

Über den Autor

Mein Name ist Markus Elsberger und ich beschäftige mich mit der Administration von Windows und Linux Systemen sowie mit diversen Themen bzgl. Netzwerktechnik. In meiner Lehrtätigkeit erstelle ich verschiedene Szenarien und teste auch verschiedene Konfigurationen, welche ich in diesem Blog festhalten möchte.

Nach oben scrollen