Pages

Tuesday, September 13, 2016

DiskPart : Attach a new disk and create new volume

Here are the steps required to rescan and attach a Disk on any windows server from command prompt using DiskPart utility.

  • Enter DiskPart Prompt:

C:\Windows\system32>diskpart
Microsoft DiskPart version 6.3.9600
Copyright (C) 1999-2013 Microsoft Corporation.
On computer: MyHostName

  • Perform rescan to allow DiskPart to look for any changes on the Disks attached:

DISKPART> rescan
Please wait while DiskPart scans your configuration...
DiskPart has finished scanning your configuration.

  • List Disks attached to the system:

DISKPART> list disk
  Disk ###            Status         Size                 Free     Dyn  Gpt
  --------                -------------  -------               -------  ---  ---
  Disk 0                 Online          100 GB         0 B
  Disk 1                 Offline         400 GB          400 GB

  • Select the Disk we are going to work on:

DISKPART> select disk 1
Disk 1 is now the selected disk.

  • Bring the disk online:

DISKPART> online disk
DiskPart successfully onlined the selected disk.

  • Initialize the disk:

DISKPART> attributes disk clear readonly
Disk attributes cleared successfully.

  • Create a Partition on the selected disk:

DISKPART> create partition primary
DiskPart succeeded in creating the specified partition.

  • Quick Format the newly created partition with NTFS supplying Quick parameter:

DISKPART> format fs=ntfs quick
  100 percent completed
DiskPart successfully formatted the volume.

  • List the Volumes/Partitions created and mounted on server:

DISKPART> list vol
  Volume ###      Ltr      Label                    Fs           Type                     Size        Status                  Info
  ----------              ---     -----------              -----        ----------                -------     ---------  --------
  Volume 0     D                                         DVD-ROM                          0 B         No Media
  Volume 1                     boot                     NTFS      Partition              350 MB Healthy                   System
  Volume 2     C                            Windows 201     NTFS      Partition              99 GB    Healthy                   Boot
* Volume 3                                                 NTFS      Partition              399 GB  Healthy

We want to create the Volume with Drive letter D: but since it is in use by DVD/CD Rom hence We need to change Drive Letter D: assigned to CD/DVD Rom so that it can be allocated to next partition we are going to create:

  • Select Volume number representing CD/DVD ROM drive:

DISKPART> sel vol 0
Volume 0 is the selected volume.

  • Assign a different Drive letter (Z:) to Selected Volume:

DISKPART> assign letter=z
DiskPart successfully assigned the drive letter or mount point.

Now We can assign D: to our newly created volume:
  • Select Volume number representing to the newly created volume (3 in this case):
 DISKPART> sel vol 3
Volume 3 is the selected volume.

  • Optional: We can see the details of the selected Volume:

DISKPART> det vol
  Disk ###            Status                  Size        Free    Dyn  Gpt
  --------                -------------           -------     -------  ---  ---
* Disk 1               Online                 400 GB      0 B

Read-only                          : No
Hidden                               : No
No Default Drive Letter    : No
Shadow Copy                    : No
Offline                               : No
BitLocker Encrypted         : No
Installable                          : Yes

Volume Capacity        :  399 GB
Volume Free Space      :  399 GB

  • Since the new Volume is selected now so we can change it:

DISKPART> assign letter=d
DiskPart successfully assigned the drive letter or mount point.

  • Done!
DISKPART> Exit