Disk management tasks are the basic tasks for a system or server administrator. These tasks include creating, formatting, and managing disks and volumes on a system. To become familiar with the disk management tasks, you can start from creating and managing simple volumes on a system. A simple volume is simply a disk partition that takes the disk space from a single disk. Since it uses the space from a single disk, it cannot provide fault tolerant. In the previous posts, we have discussed how to create and manage volumes using the Disk Management console.
Disk Management Tools in Windows
You can use any of the following tools to perform the disk management tasks in the latest version Windows machines:
- Disk management using Disk Management tool.
- Disk management using DISKPART.EXE utility.
- Disk management using Windows PowerShell.
Performing disk management tasks such as creating and formatting a simple volume using the command-line tools will stand you in a different queue from others. Performing any system management task using command-line tools makes you more professional than others. In this post, we will explain how to create and manage Simple Volume Using Windows PowerShell.
Managing Disks Using Windows PowerShell
There are various Windows PowerShell cmdlets that can be used to perform the disk management tasks. The following some of the most common PowerShell cmdlets used to create and manage disk partitions in a Windows system:
- New-Partition : To create a new disk partition or volume
- Get-Partition : To get details of a disk partition or volume
- Format-Volume : To format a volume or partition
- Set-Partition : To set the parameters of a partition or volume
Syntax of New-Partition PowerShell cmdlet
First, understand the syntax of the New-Partition PowerShell cmdlet:
New-Partition -DiskNumber <number> -Size <size of disk> -AssignDriveLetter
Creating Volumes Using PowerShell
The New-Partition PowerShell cmdlet allows you to create a new volume or partition.
For example, to create a simple volume with the parameters given as below, you need to execute the following command:
- Disk name = Disk 2
- Drive Letter = AutoAssign
- Size = 5 GB
New-Partition -Disk2 -Size 5GB -AssignDriveLetter
The following figure shows an example of creating a new simple volume using PowerShell.
Viewing Partition Details Using PowerShell
To get the details of disk partition or volume, use the following PowerShell cmdlet.
Get-Partition -DiskNumber <number>
The following figure shows an example of viewing details of a disk partition using Get-Partition PowerShell cmdlet.
Formatting Volumes Using PowerShell
To format a volume or partition, use the following PowerShell cmdlet.
Format-Volume -DriveLetter <Your Drive Letter> -FileSystem <Your File System>
For example, the following cmdlets will format F drive with the NTFS file system.
Format-Volume -DriveLetter F -FileSystem NTFS
Changing Drive Letters Using PowerShell
The Set-Partition PowerShell cmdlet allows you to change the various attributes and parameters for a volume. For example, to change the default drive letter of a partition or volume, use the following PoweShell cmdlet.
Set-Partition –DriveLetter <Old Drive Letter> -NewDriveLetter <New Drive Letter>
For example, the following cmdlet will change the drive letter from F to G for a volume.
Set-Partition –DriveLetter F -NewDriveLett G
The following figure shows how to format, and how to change a drive letter for, a simple volume using Windows PowerShell cmdlets.
In this post, we have discussed various Windows PowerShell cmdlets that are used to perform Disk Management tasks on a Windows system. How this post helped you? Please share your experience with us using the comment box and stay connected with us.