Windows
 

Windows 8 : Managing disks and storage (part 5) - Using Microsoft Drive Optimizer to organize data - The DiskPart utility

10/10/2014 9:12:49 PM

The DiskPart utility

This section looks at the DiskPart utility in more detail, explaining the options available with DiskPart and how it might be used when performing maintenance on or troubleshooting a computer. The DiskPart utility and commands are designed to work directly with disks, volumes, and partitions.

When you launch DiskPart from a command line, you are prompted to allow or deny its use by User Account Control. Because DiskPart can make potentially harmful changes to your system, you are prompted to verify that it should be allowed to run. A new command prompt window opens that is running DiskPart.exe. When DiskPart is loaded, your cursor follows the DISKPART> prompt, which is shown in Figure 8.

The DiskPart prompt

Figure 8. The DiskPart prompt

From this prompt, your command-line session can execute any of the DiskPart options and commands. Many commands, DIR for example, will produce different results within DiskPart than might appear when executing the command outside DiskPart. DIR returns a list of the commands available within the DISKPART prompt. This is shown in Figure 9.

Executing DIR within the DiskPart prompt

Figure 9. Executing DIR within the DiskPart prompt

Using DiskPart to manage and review existing items on your Windows 8–based computer can be a great starting point for adding or removing volumes and other potentially dangerous maneuvers.

Note

GETTING HELP FOR COMMANDS

When working with DiskPart, help is available for all the commands by typing help before a command. For example, typing Help Add displays help items related to the Add command.

  • Active Marks the selected partition as active

  • Add Adds a mirror to a simple volume

  • Assign Assigns a drive letter or mount point to the selected volume

  • Attach Attaches a virtual disk file

  • Attributes Manipulates the attributes of a disk or volume

  • Automount Enables or disables automatic mount for basic volumes

  • Break Breaks a mirror set

  • Clean Removes the configuration data or all data from a disk or volume

  • Compact Reduces the physical size of a file

  • Convert Converts a basic disk or volume to a dynamic disk or volume

  • Create Creates a partition, virtual disk, or volume

  • Delete Removes a partition, virtual disk, or volume

  • Detail Provides object details

  • Detach Disconnects a virtual disk file

  • Exit Quits DiskPart

  • Extend Extends a volume

  • Expand Expands a virtual disk file’s maximum size

  • Filesystems Displays current and supported file systems on the selected volume

  • Format Formats the selected disk, partition, or volume

  • GPT Assigns attributes to the selected GPT partition

  • Help Displays help for a DiskPart command or a list of all commands

  • Import Imports a disk group

  • Inactive Sets the selected object to inactive

  • List Displays a list of objects

  • Merge Merges a child disk with its parent

  • Online Sets an offline object online

  • Offline Sets an online object offline

  • Recover Refreshes the state of all disks in a pack, attempts recovery on invalid disks, and resynchronizes mirrored and RAID-5 volumes

  • Rem Enables comment lines in scripts; takes no action on the command line

  • Remove Removes a drive letter or mount point

  • Repair Repairs a RAID-5 volume with a failed disk

  • Rescan Rescans the computer for new or changed disks or volumes

  • Retain Places a retained partition under a single volume

  • SAN Displays or sets the SAN policy for the currently started operating system

  • Select Shifts the context or focus of DiskPart to a disk, partition, volume, or other object

  • SetID Changes the partition type

  • Shrink Decreases the size of the selected volume

  • UniqueID Displays or sets the GUID Partition Table identifier or Master Boot Record signature of a disk

DiskPart performs a number of the same functions as the Disk Management console, providing a command-line alternative to the GUI. In addition to running operations directly at the command line, you can script DiskPart actions to automate the process of managing disks, volumes, and partitions.

Similar to the earlier example of extending the size of a volume with computer management, you can use DiskPart to shrink volumes where space might no longer be needed. For example, you added 250 MB to the documents volume earlier in this lesson. Now, you no longer need the additional space; perhaps a large number of files are no longer needed in your testing. By using DiskPart, you can reclaim this space. To do so, complete the following steps:

  1. Open the Start screen.

  2. Search for DiskPart.

  3. Press Enter or tap or click the result returned to launch the utility.

  4. Allow DiskPart when prompted for UAC by tapping or clicking Yes.

  5. List the volumes available within the computer by typing list volume on the command line and pressing Enter.

  6. From the list of volumes, select the volume to shrink by typing select volume # on the command line, where # is the number of the volume returned in the previous step. Press Enter.

  7. Shrink the volume by 250 MB by typing Shrink desired=250 on the command line and tapping or clicking Enter.

  8. Type Exit on the command line and press Enter to close DiskPart.

Important

DISKPART MAKES CHANGES IMMEDIATELY

Shrinking volumes or partitions by using DiskPart happens almost immediately. Typing Shrink by itself on the command line will reduce the selected volume to the smallest available size.

Even though the DiskPart command-line tool can be scripted, it still requires you to work with one object at a time. When one operation completes, the script can move on to the next object. The following is an example of a script using DiskPart:

Select volume  1
Clean
Create partition primary size=300
Exit

This script selects volume 1 and cleans it, which removes all partitions and data from the disk. Then the script creates a 300-MB primary partition on volume 1.

To execute a script in DiskPart, type the following command:

diskpart -s <scriptfile>
 
Others
 
- Windows 8 : Managing disks and storage (part 4) - Using Microsoft Drive Optimizer to organize data - Check Disk (chkdsk)
- Windows 8 : Managing disks and storage (part 3) - Using Microsoft Drive Optimizer to organize data
- Windows 8 : Managing disks and storage (part 2) - Disk Defragmenter and Disk Cleanup
- Windows 8 : Managing disks and storage (part 1) - Using disk management
- Windows 8 : Sharing printers - Configuring shared printers, Configuring printing permissions
- Windows 8 : Sharing files and folders (part 6) - Understanding NTFS permissions - Identifying permissions, Taking ownership of a resource
- Windows 8 : Sharing files and folders (part 5) - Understanding NTFS permissions - Creating advanced security settings
- Windows 8 : Sharing files and folders (part 4) - Understanding NTFS permissions - Modifying file or folder permissions
- Windows 8 : Sharing files and folders (part 3) - Sharing a folder
- Windows 8 : Sharing files and folders (part 2) - Enabling folder sharing using the Windows 8 interface, Enabling folder sharing using the traditional interface
- Windows 8 : Sharing files and folders (part 1) - Configuring the Network and Sharing Center
- Windows 8 : Configuring virtual machine networking and storage (part 3) - Assigning a virtual switch to a virtual machine , Assigning storage to a virtual machine
- Windows 8 : Configuring virtual machine networking and storage (part 2) - Hyper-V virtual switch
- Windows 8 : Configuring virtual machine networking and storage (part 1) - Introducing storage and networking for Hyper-V
- Windows 8 : Customizing the Lock Screen - Customizing the Lock Screen Background,Controlling the Apps Displayed on the Lock Screen, Disabling the Lock Screen
- Windows 8 for Business : Features Exclusive to Windows 8 Enterprise,Windows RT and Business
- Windows 8 for Business : Virtualization (part 4) - VHD Shell Integration,Remote Desktop and Remote Desktop Host
- Windows 8 for Business : Virtualization (part 3) - Using Hyper-V Virtual Machine Connection
- Windows 8 for Business : Virtualization (part 2) - Using Hyper-V Manager
- Windows 8 for Business : Virtualization (part 1) - Client Hyper-V
 
 
Most View
 
- Windows 7 : Protecting Your Files - Simple File Backups
- About Microsoft SharePoint 2013 : What Is Tagging?
- Application Lifecycle Management in SharePoint 2013 : Planning your Customization Model and Release Packaging Approach (part 2) - Release Packaging Approach
- Windows 8 : Sharing and Securing with User Accounts - Picture Passwords
- Windows 7 : Windows Media Player - Learning the Basics (part 1) - Getting Around in Windows Media Player 12 - Navigating Menu Breadcrumbs
- : Windows Server 2008 and Windows Vista : Administrative (.adm) Templates (part 2) - Default Installed .adm Templates
- Windows Phone 8 : Working with People - Rooms (part 1) - Creating a Room
- Active Directory 2008 : Configuring Active Directory Certificate Services (part 2) - Enrolling User and Computer Certificates
- Windows Phone 8 : Scheduled Notifications (part 1)
- Windows 8 : Sharing files and folders (part 1) - Configuring the Network and Sharing Center
 
 
Top 10
 
- Microsoft LynServer 2013 : Dependent Services and SQL - Office Web Apps Server
- Microsoft LynServer 2013 : Dependent Services and SQL - Network Dependencies (part 2) - Defining Network Sites
- Microsoft LynServer 2013 : Dependent Services and SQL - Network Dependencies (part 1) - Supporting Lync Phone Edition with DHCP
- SQL Server 2012 : Performance Monitor Overview (part 5) - Remotely Running PerfMon
- SQL Server 2012 : Performance Monitor Overview (part 4) - Working with Data Collector Sets
- SQL Server 2012 : Performance Monitor Overview (part 3) - Getting Started with PerfMon - Monitoring Real-Time Server Activity, Starting Out with Data Collector Sets
- SQL Server 2012 : Performance Monitor Overview (part 2) - New PerfMon Counters for SQL Server 2012
- SQL Server 2012 : Performance Monitor Overview (part 1) - Reliability and Performance Monitor
- SQL Server 2012 : Knowing Tempdb - Configuration Best Practices (part 2) - Tempdb Initial Sizing and Autogrowth , Configuring Multiple Tempdb Data Files
- SQL Server 2012 : Knowing Tempdb - Configuration Best Practices (part 1) - Tempdb File Placement