New Partition - PowerShell
Overview
The New-Partition
cmdlet creates new partitions on an existing disk in the system. Partitions are logical divisions within a physical disk that can be formatted with a file system and used to store data. This cmdlet is useful for managing disk space, creating multiple volumes on a single disk, and organizing data effectively.
Syntax
New-Partition -DiskNumber <Int32> -Size <UInt32> [-DriveLetter <Char>]
[-Force] [-FileSystem "NTFS" | "FAT32" | "exFAT" | "XFS" | " ext2" | "ext3" | "ext4" | "linux-swap" | "HFS+" | "ReFS" | "REFS3" | "Resilient File System"]
[-Gpt] [-Label <String>] [-NewFileSystem] [-Offset <UInt32>] [-PartitionStyle]
[-WriteReserved <UInt32>]
Options/Flags
| Option/Flag | Description |
|—|—|
| -DiskNumber
| Specifies the disk number to create the partition on. |
| -Size
| Specifies the size of the partition in megabytes (MB). |
| -DriveLetter
| Assigns a drive letter to the newly created partition. |
| -Force
| Forces the creation of the partition even if it results in data loss. Use with caution. |
| -FileSystem
| Sets the file system type for the partition. NTFS is the default. |
| -Gpt
| Creates a GUID Partition Table (GPT) partition. MBR is used by default. |
| -Label
| Assigns a label to the partition for identification. |
| -NewFileSystem
| Formats the partition with the specified file system after creation. |
| -Offset
| Sets the offset of the partition from the beginning of the disk in MB. |
| -PartitionStyle
| Specifies the partition style. Options are MBR or GPT. |
| -WriteReserved
| Reserves a specified amount of space in the partition in KB for system use. |
Examples
Example 1: Create a 100 MB partition on Disk 0
New-Partition -DiskNumber 0 -Size 100
Example 2: Create a 500 MB partition with the drive letter “E:” on Disk 1 and format it with NTFS
New-Partition -DiskNumber 1 -Size 500 -DriveLetter "E" -FileSystem NTFS -NewFileSystem
Example 3: Create a 100 GB GPT partition with the label “Data” on Disk 2
New-Partition -DiskNumber 2 -Size 100000 -Gpt -Label "Data"
Common Issues
- Insufficient disk space: Ensure that there is enough free space on the selected disk to accommodate the new partition.
- Partition size too large: The partition size cannot exceed the available space on the disk.
- Invalid file system specified: The specified file system must be supported by the operating system.
- Drive letter collision: The specified drive letter may be already assigned to another volume. Choose a unique letter.
Integration
The New-Partition
cmdlet can be combined with other commands to manage partitions and storage. For example:
- Get-Partition: Retrieve information about existing partitions.
- Format-Volume: Formats the newly created partition with a file system.
- Mount-Volume: Assigns a mount point to the partition and makes it accessible.
Related Commands
Format-Volume
Get-Partition
Mount-Volume
Resize-Partition
Set-Partition