I am working on Server 2012 which doesn't have a GUI. For now, I have two hard disks. My first one is already formatted and I see it as C:

Now, I'd like to format my second hard drive and create a D: partition.

Are there any ideas how could I achieve this through command-line (like cmd or powershell)?


You probably want to use the diskpart.exe tool.


DISKPART> list disk

  Disk ###  Status         Size     Free     Dyn  Gpt
  --------  -------------  -------  -------  ---  ---
  Disk 0    Online           60 GB     0 B
  Disk 1    Online          200 GB   200 GB

DISKPART> select disk 1

Disk 1 is now the selected disk.

DISKPART> create partition primary

DISKPART> list partition

DISKPART> select partition 1

DISKPART> format fs=NTFS quick

DISKPART> assign letter=D

See http://technet.microsoft.com/en-us/library/cc770877.aspx

  • 4
    You might need to run a few commands to bring the disk online and make it writable prior to creating the partition. If you get a "Media is write protected" exception when running create primary partition run these steps. – smaclell Jul 17 '15 at 19:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.