search
top

How to use diskpart to get disk information

Introduction

In this short post we will use diskpart to get disk information on a Windows server.

Command Scenarios

So let’s cover a few scenarios using diskpart.

Open a command prompt and type diskpart to start using the command.

C:\> diskpart

Using the list disk command we can get back the information on the disks available on the system for viewing and manipulation.

DISKPART> list disk

Disk ### Status Size Free Dyn Gpt
-------- ------------- ------- ------- --- ---
Disk 0 Online 67 GB 0 B
Disk 1 Reserved 1024 MB 1920 KB *

We see we have 2 disks on the server, so we will select disk 0 and view some information.

DISKPART> select disk 0

Disk 0 is now the selected disk.

So let’s try a few commands. What partitions are there?

DISKPART> list partition

Partition ### Type Size Offset
------------- ---------------- ------- -------
Partition 1 OEM 39 MB 31 KB
Partition 2 Primary 100 MB 40 MB
Partition 3 Primary 67 GB 140 MB

DISKPART> list volume

diskpartvolume

DISKPART> select volume 3

Volume 3 is the selected volume.

Now we can see the details of the volume using the FILESYSTEMS command.

DISKPART> FILESYSTEMS

diskpartvolinfo

To create a partition

At a command prompt, type: Diskpart

DISKPART>LIST DISK

(Lists disks found. Make note of the drive number you wish to manipulate.)

DISKPART> SELECT DISK 1

Now lets create a 10 GB partition.

DISKPART> CREATE PARTITION PRIMARY SIZE=10000

Or for a 10 GB partition with 64k allocation to improve disk I/O performance.

DISKPART> CREATE PARTITION PRIMARY SIZE=10000 ALIGN=64

Note: Change the word PRIMARY to EXTENDED to create an extended partition.

Choose a drive letter not already being used.

DISKPART> ASSIGN LETTER=D

All done, exit diskpart.

DISKPART> Exit

Use the Command Prompt format command, Disk Administrator or any disk format utility to format the drive.

To extend a partition

Extend a partition in Windows with Diskpart. When it comes to adding space to a partition or volume, this method is superior to configuring Dynamic Disks. Dynamic Disk extensions only concatenate the newly added space, meaning they merely add the disk space to the “end” of the original partition without re-striping the data.

Concatenation isolates performance within each partition and does not offer fault tolerance when the partition is configured in a RAID array. Diskpart allows you to re-stripe your existing data. This is truly beneficial when the partition is set up in a RAID array, because the existing partition data is spread out across all the drives in the array, rather than just adding new space to the end (like Disk Administrator).

Note: If you try it or any other method, make sure you have a full backup.

Verify that contiguous free space is available on the same drive and that free space is next to the partition you intend on extending (with no partitions in between).

C:\> diskpart
DISKPART> list disk
DISKPART> Select Disk 1 (Selects the disk.)
DISKPART> Select Volume 1 (Selects the volume.)
DISKPART> Extend Size=10000 (If you do not set a size, such as the above example for 10 GB, then all available space on the disk will be used.)
DISKPART> Exit

Delete a partition

To delete a partition in Windows with Diskpart: (Note: You cannot delete an active system or boot partition or a partition with an active page file.)

C:\> diskpart
DISKPART> Select Disk 1
DISKPART> Select Partition 1
DISKPART> DELETE partition
DISKPART> Exit

To wiping (or zero) a disk

This operation deletes all data on the disk

C:\> diskpart
DISKPART> Select Disk 1
DISKPART> CLEAN ALL (The CLEAN ALL command removes all partition and volume information from the hard drive being focused on.)
DISKPART> Exit

Scan for new disks

C:\> diskpart
DISKPART> rescan

Final notes:

Do not use DISKPART until you have fully backed up the hard disk you are manipulating
Do not use DISKPART on dynamic disks

Conclusion

As we can see there is a lot you can do with diskpart, much more than we have covered here in this post. If you are a command line kinda guy then diskpart is the tool for you. For more command line options look here.

 

One Response to “How to use diskpart to get disk information”

  1. Keesha says:

    TYVM you’ve solved all my prmboels

Leave a Reply

Your email address will not be published. Required fields are marked *

top