Tuesday, September 15, 2009

Diskpart Command-Line Utility

I had to make some partitioning changes on few machines. The thought of doing it manually, one by one was depressing. So I spent some time reading and playing with DiskPart and saved myself precious time.

DiskPart is a text-mode command that enables you to manage objects (disks, partitions, or volumes) by using scripts or direct input at a command prompt.

DiskPart is present in XP, Vista and Windows 7. The XP version is more limited because it does not offer advanced features for resizing partitions.

It is a powerful tool that can be used in many ways. I'll go over some basics.
Before you can use DiskPart commands on a disk, partition, or volume, you must first list and then select the object to give it focus. When an object has focus, any DiskPart commands that you type act on that object.

To start the tool, all you have to do is type DiskPart in command line. You'll get a new prompt with the DISKPART> sign replacing c:\

The tool uses two types of commands:
1. Commands which specify the target of action: List, Help, Rem, Select, Exit
2. Commands that apply directly to the element: Active, Assign, Create, Extend, Shrink

You can resize partitions, add or remove them and generally speaking do most of the FDISK or Disk Partition utility functions

One big advantage for DiskPart is it's scripting power. You can use it in script for a range of tasks.
To initiate a Diskpart script, use the diskpart /s script.txt command. By default, Diskpart can quit command processing and return an error code if there is a problem in the script. To continue to run a script in this scenario, include the noerr parameter on the command.

Check the Microsoft Command-line page for DiskPart

DiskPart is a powerful tool. Make sure you're familiar with it and use it carefully

No comments:

Post a Comment