9

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)?

MadHatter
  • 79,770
  • 20
  • 184
  • 232
hpsoftware
  • 137
  • 1
  • 3
  • 10

1 Answers1

17

You probably want to use the diskpart.exe tool.

c:\diskpart

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

Geoff Duke
  • 296
  • 2
  • 4
  • 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](https://support.microsoft.com/en-us/kb/971436). – smaclell Jul 17 '15 at 19:24