Configuring a new disk with DISKPART

I found myself struggling to remember the order of commands to use when setting up a new disk in Windows using DISKPART.  Specifically, I had just added a new virtual disk to the server and wanted to configure a new volume on it.  Here is how to complete the process:

First, let’s see if the computer sees the disk.

DISKPART> list disk

  Disk ###  Status         Size     Free     Dyn  Gpt
  ——–  ————-  ——-  ——-  —  —
  Disk 0    Online           40 GB      0 B
  Disk 1    Offline          40 GB    40 GB

Sure enough its showing up as Disk 1, but is offline.  To correct that, we must select the disk and then set its status to Online:

DISKPART> select Disk 1

Disk 1 is now the selected disk.

DISKPART> online disk

DiskPart successfully onlined the selected disk.

DISKPART> list disk

  Disk ###  Status         Size     Free     Dyn  Gpt
  ——–  ————-  ——-  ——-  —  —
  Disk 0    Online           40 GB      0 B
* Disk 1    Online           40 GB    40 GB

Good stuff.  The disk is now online.  Lets take a look at the details:

DISKPART> detail disk

VMware, VMware Virtual S SCSI Disk Device
Disk ID: 00000000
Type   : SAS
Status : Online
Path   : 0
Target : 1
LUN ID : 0
Location Path : PCIROOT(0)#PCI(1500)#PCI(0000)#SAS(P00T01L00)
Current Read-only State : Yes
Read-only  : Yes
Boot Disk  : No
Pagefile Disk  : No
Hibernation File Disk  : No
Crashdump Disk  : No
Clustered Disk  : No

There are no volumes.

Everything looks good, but I can see that the disk is currently set to read-only.  I’m not going to be able to make any changes to the disk unless I first correct that:

DISKPART> attributes disk clear readonly

Disk attributes cleared successfully.

To visually confirm I could use DETAIL DISK again to see all the disk properties, or I can just view a subset of attributes:

DISKPART> attributes disk
Current Read-only State : No
Read-only  : No
Boot Disk  : No
Pagefile Disk  : No
Hibernation File Disk  : No
Crashdump Disk  : No
Clustered Disk  : No

Now that I’ve confirmed that the disk is writeable I need to go ahead and set up my primary partition:

DISKPART> create partition primary

DiskPart succeeded in creating the specified partition.

If I check the disk details again I can see that there is now a raw primary partition. Notice the asterisk indicating that the volume is already selected:

DISKPART> detail disk

VMware, VMware Virtual S SCSI Disk Device
Disk ID: 7C54406E
Type   : SAS
Status : Online
Path   : 0
Target : 1
LUN ID : 0
Location Path : PCIROOT(0)#PCI(1500)#PCI(0000)#SAS(P00T01L00)
Current Read-only State : No
Read-only  : No
Boot Disk  : No
Pagefile Disk  : No
Hibernation File Disk  : No
Crashdump Disk  : No
Clustered Disk  : No

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ———-  —  ———–  —–  ———-  ——-  ———  ——–
* Volume 2                      RAW    Partition     39 GB  Healthy

I can also see just the volume information another way.  Once again, the asterisk indicating that the volume is already selected:

DISKPART> list volume

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ———-  —  ———–  —–  ———-  ——-  ———  ——–
  Volume 0     D                       DVD-ROM         0 B  No Media
  Volume 1     C                NTFS   Partition     39 GB  Healthy    System
* Volume 2                      RAW    Partition     39 GB  Healthy

Now I need to format my volume.  I want to use NTFS as the file-system and perform a quick format:

DISKPART> format FS=NTFS quick

  100 percent completed

DiskPart successfully formatted the volume.

DISKPART> list volume

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ———-  —  ———–  —–  ———-  ——-  ———  ——–
  Volume 0     D                       DVD-ROM         0 B  No Media
  Volume 1     C                NTFS   Partition     39 GB  Healthy    System
* Volume 2                      NTFS   Partition     39 GB  Healthy

That went over without any problems, but notice that there is still no drive letter assigned.  I’m just going to let it use the next letter in order of progression, though I could specify a letter if I wanted to:

DISKPART> assign

DiskPart successfully assigned the drive letter or mount point.

DISKPART> list volume

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ———-  —  ———–  —–  ———-  ——-  ———  ——–
  Volume 0     D                       DVD-ROM         0 B  No Media
  Volume 1     C                NTFS   Partition     39 GB  Healthy    System
* Volume 2     E                NTFS   Partition     39 GB  Healthy

I can now navigate to drive E and do my thing.  This might have been faster using the Disk Manager GUI, but I prefer the command line due to its flexibility, script-ability, and the performance in remote management situations. Ok. Back to my studies. Hope this comes in handy to someone.

Advertisements
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: