Partition a Hard Drive from Command Line Prompt

This paper tells you how to partition a hard drive from command line prompt, such as resize/move partition without data loss, extend and shrink a volume. Besides, the command line supports to create, format, delete partitions and so on.

Posted by @AOMEI September 29, 2024 Updated By @AOMEI August 4, 2023

How to Use AOMEI Partition Assistant Command Lines?

AOMEI Partition Assistant Professional provides partassist.exe utility for users to partition hard drive from command prompt like Diskpart but more powerful. The partassist.exe command line utility enables you to perform most of the disk partition operations that are supported by the AOMEI Partition Assistant graphical user interface (GUI).
You can resize/move/extend/shrink a partition without data loss from command prompt by using the partassist.exe command followed by various parameters. In addition, it also supports additional operations, such as create/delete/format a partition, rebuild MBR and more.
To use partassist.exe command line utility, click on the "Start" menu at the lower left corner. In the search box, type "cmd" or press "WIN + R" keys and type "cmd", and then run as administrator privilege. After that, Command Prompt will open. In the command window that opens type "cd + installation directory of AOMEI Partition Assistant" to get started (e.g. cd C:\Program Files (x86)\AOMEI Partition Assistant).

The followings are some features supported by AOMEI Partition Assistant command line:
Export Execution Results to File
Because this command execution cannot use the ">" symbol to export execution results to file, so we specially add "/out" parameter for exporting execution results to file, which supports to export execution results of all command lines to file.
Parameters Description
partassist.exe /list /out:text.txt Export a specified execution result to file.
partassist.exe /resize:F /extend:right /out:c:\test.ini
partassist.exe /hd:0 /cre /pri /size:200GB /out:..\..\test.txt
List Disks and Partitions
Parameters Description
partassist.exe /list List all the disks in current system.
partassist.exe /list /usb Only list all the USB flash drives and other USB disks in current system.
partassist.exe /list:0 List all the partitions on a specified disk.
Resize Partition without Data Loss
Parameters Description
partassist.exe /hd:0 /resize:0 /extend:auto /align Automatically extend a specified partition using the unallocated space on its both sides and align partition to optimize reading/writing speed.
partassist.exe /resize:F /extend:auto /align
partassist.exe /hd:0 /resize:0 /extend:right Automatically extend a specified partition using the unallocated space on its right side.
partassist.exe /resize:F /extend:right
partassist.exe /hd:0 /resize:0 /extend:left /align Automatically extend a specified partition using the unallocated space on its left side and align the partition to optimize reading/writing speed.
partassist.exe /resize:F /extend:left /align
partassist.exe /hd:0 /resize:0 /extend:1000 Extend a specified partition using 1000MB or 10GB unallocated space on its right side.
partassist.exe /hd:0 /resize:0 /extend:10GB
partassist.exe /hd:0 /resize:0 /reduce-right:1000 Shrink a specified partition to create 1000MB or 10GB unallocated space on its right side.
partassist.exe /resize:F /reduce-right:10GB
partassist.exe /hd:0 /resize:0 /reduce-left:1000 /align Shrink a specified partition to create 1000MB or 10GB unallocated space on its left side and align the partition to optimize reading/writing speed.
partassist.exe /resize:F /reduce-left:10GB /align
Notes:
  • "/hd" followed by disk number, which starts with 0.
  • "/resize" followed by partition number or drive letter, and the partition number starts with 0. If the specified value is drive letter, disk number can be ignored.
  • The value of "/extend" can be left, right, auto or specified size.
  • "/align" means align a partition to optimize reading/writing speed. If the beginning of a partition is changed when resizing it (in other words, move the beginning of a partition to a new location, forward or backward), then the "/align" works. But if the beginning of a partition is not changed when resizing it, then the "/align" doesn’t works.
  • By default, the specified size is in MB, and GB is also available.

 

Move a Partition without Data Loss
Parameters Description
partassist.exe /hd:0 /move:0 /left:1000 /align Change the location of a partition by moving 1000MB or 10GB to the left side and align the partition to optimize reading/writing speed.
partassist.exe /move:F /left:10GB /align
partassist.exe /hd:0 /move:0 /left:auto /align Move a partition to occupy all unallocated space on its left side and align the partition to optimize reading/writing speed.
partassist.exe /move:F /left:auto /align
partassist.exe /hd:0 /move:0 /right:1000 /align Change the location of a partition by moving 1000MB or 10GB to the right side and align the partition to optimize reading/writing speed.
partassist.exe /move:F /right:10GB /align
partassist.exe /hd:0 /move:0 /right:auto /align Move a partition to occupy all unallocated space on its right side and align the partition to optimize reading/writing speed.
partassist.exe /move:F /right:auto /align
Notes:
  • "/hd" followed by disk number, which starts with 0.
  • "/move" followed by partition number or drive letter, and the partition number starts with 0. If the specified value is drive letter, disk number can be ignored.
  • The value of "/left" can be auto or specified size.
  • The value of "/right" can be auto or specified size.
  • "/align" means creating aligned partition to optimize reading/writing speed.
  • By default, the specified size is in MB, and GB is also available.

 

Create a New Partition
Parameters Description
partassist.exe /hd:1 /cre /pri /size:200 /end /fs:fat16 /act /hide /align /label:EFI Create a 200MB, 10GB or auto size partition at the end of a disk.
partassist.exe /hd:1 /cre /pri /size:10GB /end /fs:fat32 /act /hide /align /label:EFI
partassist.exe /hd:1 /cre /pri /size:auto /end /fs:ntfs /act /hide /align /label:EFI
partassist.exe /hd:0 /cre /pri /size:auto /fs:ntfs /align /label:DATA /letter:E Create an auto size or 500MB partition using the first block of unallocated space on a disk.
partassist.exe /hd:0 /cre /pri /size:500 /fs:ntfs /align /label:DATA /letter:E
partassist.exe /hd:0 /cre /pri /size:auto /offset:100 /fs:fat32 /act /align /label:DATA /letter:F Create a partition using offset. Here is creating a partition at the location of 100MB offset and 100GB offset.
partassist.exe /hd:0 /cre /pri /size:10GB /offset:100GB /fs:fat32 /act /align /label:DATA /letter:F
Notes:
  • "/hd" followed by disk number, which starts with 0.
  • The value of "/size" can be auto or specified size in MB by default, and GB is also available.
  • "/fs" means file system, whose value can be fat16, fat32 or ntfs.
  • "/pri" means creating a primary partition.
  • "/end" means creating a specified size back end partition using the unallocated space at the end of a disk.
  • "/act" means creating an active partition.
  • "/hide" means creating a hidden partition.
  • "/letter" means assigning a drive letter to the partition, in addition, /letter:auto can automatically assign the drive letter.
  • "/offset" means creating a partition from the location of specified offset, starting with the beginning of the disk.
  • "/label" means setting a label for the partition.

 

Format a Partition
Parameters Description
partassist.exe /hd:0 /fmt:0 /fs:fat16 /label:test Format a specified partition.
partassist.exe /fmt:F /fs:fat32 /label:test
partassist.exe /fmt:F /fs:ntfs /label:test
Notes:
  • "/hd" followed by disk number, which starts with 0.
  • "/fmt" followed by partition number or drive letter, and the partition number starts with 0. If the specified value is drive letter, disk number can be ignored.
  • "/fs" means file system, whose value can be fat16, fat32 or ntfs.

 

Delete a Partition
Parameters Description
partassist.exe /hd:0 /del:0 Delete a specified partition.
partassist.exe /del:F
partassist.exe /hd:0 /del:all Delete all the partitions on a disk.
Hide/Unhide a Partition
Parameters Description
partassist.exe /hd:0 /hide:0 Hide a specified partition.
partassist.exe /hide:F
partassist.exe /hd:0 /unhide:0 Unhide a specified partition.
Mark a Partition as Active
Parameters Description
partassist.exe /setact:1 /hd:0 Set a specified partition as active.
partassist.exe /setact:F
Initialize a Disk
Parameters Description
partassist.exe /init:1 Initialize a disk as MBR.
partassist.exe /init:1 /gpt Initialize a disk as GPT.
Rebuild MBR
Parameters Description
partassist.exe /rebuildmbr:0 Rebuild master boot record (MBR) for a hard disk, a removable disk or a USB flash drive.
partassist.exe /rebuildmbr:0 /mbrtype:0
partassist.exe /rebuildmbr:0 /mbrtype:1
partassist.exe /rebuildmbr:0 /mbrtype:2
Notes:
  • "/rebuildmbr" followed by disk number, which starts with 0.
  • "/mbrtype" supports a specified MBR type and its values are 0, 1, 2. The 0 means creating a Windows XP/2000/20003 MBR type. The 1 means creating a Windows Vista/2008 MBR type. The 2 means creating a Windows 7/8/8.1/10/2011/2012 MBR type.
  • If the value of /mbrtype is not specified, the default type is the one of current system. For example, if current system is Windows XP, then the value of "/mbrtype" is set as 0 by default; if current system is Windows 8.1, then the value of "/mbrtype" is set as 2 by default.

 

Change Drive Letter
Parameters Description
partassist.exe /hd:0 /setletter:0 /letter:* Remove drive letter.
partassist.exe /hd:0 /setletter:0 /letter:F Change drive letter to F.
Notes:
  • "/hd" followed by disk number, "/setletter" followed by partition number, and the disk number and partition number always start with 0.
  • If a drive letter needs to be removed, you need to set "/letter" value as *
  • You had better not to remove and change the drive letter of system partition, which may cause Windows to fail to boot.
  • If you use “/letter auto” to replace “/letter:F”, the drive letter will be assigned automatically.

 

Write Files to a Hidden Partition
Parameters Description
partassist.exe /hd:0 /whide:0 /src:C:\file.txt Write files and folders to the root directory of a hidden partition.
partassist.exe /hd:0 /whide:0 /src:C:\folder
partassist.exe /hd:0 /whide:0 /src:C:\file.txt /dest:subfolder Write files and folders to the subdirectory of a hidden partition.
partassist.exe /hd:0 /whide:0 /src:C:\folder /dest:subfolder\test
Notes:
  • Before using the "/resize" and "/move" of AOMEI Partition Assistant Command Line, we suggest you use Windows built-in chkdsk utility to check the partition you want to resize and automatically fix file system error so that the data safety can be ensured effectively. Example: chkdsk.exe /f C: