Partition a Hard Drive from Command Line Prompt  

Partition a Hard Drive from Command Line Prompt

Updated on Jun 15, 2024 | by Nick Jones

This paper provides a step-by-step guide on how to partition a hard drive from the command line, allowing users to resize, move, extend, and shrink volumes without losing any data. Additionally, it covers how to create, format, and delete partitions using command line prompts.

How to Use Qiling Disk Master Command Lines?

Qiling Disk Master Professional DiskMasterX.exe is a command line utility that allows users to partition their hard drive from the command prompt, offering more power than Diskpart. It enables users to perform most disk partition operations that are supported by the Qiling Disk Master GUI, providing a flexible and efficient way to manage disk partitions.
You can resize, move, extend, or shrink a partition without data loss from the command prompt using the DiskMasterX.exe command, which also supports additional operations like creating, deleting, or formatting a partition, as well as rebuilding the Master Boot Record (MBR).
To use DiskMasterX.exe, go to the Start menu, type "cmd" in the search box, and run it as administrator. In the Command Prompt, type "cd" followed by the installation directory of Qiling Disk Master (e.g. "cd C:\Program Files (x86)\Qiling Disk Master").
Here are some features of Qiling Disk Master command line in one paragraph:
Export Execution Results to File
Because this command execution cannot use the ">" symbol to export execution results to file, we add a "/out" parameter to export execution results to file, allowing all command lines to be exported to a file.
Parameters Description
DiskMasterX.exe /list /out:text.txt Export a specified execution result to file.
DiskMasterX.exe /resize:F /extend:right /out:c:\test.ini
DiskMasterX.exe /hd:0 /cre /pri /size:200GB /out:..\..\test.txt
List Disks and Partitions
Parameters Description
DiskMasterX.exe /list List all the disks in current system.
DiskMasterX.exe /list /usb Only list all the USB flash drives and other USB disks in current system.
DiskMasterX.exe /list:0 List all the partitions on a specified disk.
Resize Partition without Data Loss
Parameters Description
DiskMasterX.exe /hd:0 /resize:0 /extend:auto /align Extend a partition to utilize unallocated space on both sides and align it for optimal read/write performance.
DiskMasterX.exe /resize:F /extend:auto /align
DiskMasterX.exe /hd:0 /resize:0 /extend:right Automatically extend a specified partition using the unallocated space on its right side.
DiskMasterX.exe /resize:F /extend:right
DiskMasterX.exe /hd:0 /resize:0 /extend:left /align Use a partition manager tool to extend the specified partition by taking the unallocated space on its left side, and align it to optimize reading/writing speed.
DiskMasterX.exe /resize:F /extend:left /align
DiskMasterX.exe /hd:0 /resize:0 /extend:1000 Extend a partition by using 1000MB or 10GB of unallocated space on its right side.
DiskMasterX.exe /hd:0 /resize:0 /extend:10GB
DiskMasterX.exe /hd:0 /resize:0 /reduce-right:1000 Shrink a specified partition to create 1000MB or 10GB unallocated space on its right side.
DiskMasterX.exe /resize:F /reduce-right:10GB
DiskMasterX.exe /hd:0 /resize:0 /reduce-left:1000 /align To optimize reading/writing speed, shrink a specified partition to create 1000MB or 10GB of unallocated space on its left side and align the partition. This process involves resizing the partition to make space for a new drive or to improve performance by optimizing the partition's alignment.
DiskMasterX.exe /resize:F /reduce-left:10GB /align
Notes:
  • "/hd" followed by disk number, which starts with 0.
  • The command "/resize" is used to resize a partition, and it requires a partition number or drive letter. The partition number starts with 0. If a drive letter is specified, the disk number can be ignored.
  • The value of "/extend" can be "left", "right", "auto", or a specified size.
  • "/align" in partition resizing means it optimizes reading/writing speed by adjusting the partition's start point when its size changes, but it's only effective when the start point is actually moved. If the start point remains the same, the optimization doesn't occur.
  • The specified size can be in either MB or GB, depending on the default setting.

Move a Partition without Data Loss
Parameters Description
DiskMasterX.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.
DiskMasterX.exe /move:F /left:10GB /align
DiskMasterX.exe /hd:0 /move:0 /left:auto /align Move a partition to occupy all unallocated space on its left and align it to optimize reading/writing speed.
DiskMasterX.exe /move:F /left:auto /align
DiskMasterX.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.
DiskMasterX.exe /move:F /right:10GB /align
DiskMasterX.exe /hd:0 /move:0 /right:auto /align Move a partition to occupy all unallocated space on its right side and align it to optimize reading/writing speed.
DiskMasterX.exe /move:F /right:auto /align
Notes:
  • "/hd" followed by disk number, which starts with 0.
  • The command "/move" is used to move a partition or drive letter to a new location, and the partition number starts with 0. If the specified value is a drive letter, the 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.
  • The specified size can be in either MB or GB by default.

Create a New Partition
Parameters Description
DiskMasterX.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.
DiskMasterX.exe /hd:1 /cre /pri /size:10GB /end /fs:fat32 /act /hide /align /label:EFI
DiskMasterX.exe /hd:1 /cre /pri /size:auto /end /fs:ntfs /act /hide /align /label:EFI
DiskMasterX.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.
DiskMasterX.exe /hd:0 /cre /pri /size:500 /fs:ntfs /align /label:DATA /letter:E
DiskMasterX.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.
DiskMasterX.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 set to "auto" or a specified size in MB or GB.
  • The term "/fs" refers to the file system, which can have values such as fat16, fat32, or ntfs.
  • "/pri" means creating a primary partition.
  • "/end" is an option in disk management tools that creates 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.
  • The "/letter" option in Windows allows you to assign a drive letter to a partition, and "/letter:auto" can automatically assign the drive letter.
  • "offset" in partitioning means creating a partition from the specified offset, starting from the beginning of the disk.
  • "/label" means setting a label for the partition.

Format a Partition
Parameters Description
DiskMasterX.exe /hd:0 /fmt:0 /fs:fat16 /label:test Format a specified partition.
DiskMasterX.exe /fmt:F /fs:fat32 /label:test
DiskMasterX.exe /fmt:F /fs:ntfs /label:test
Notes:
  • "/hd" followed by disk number, which starts with 0.
  • The format command "/fmt" is used to format a partition or drive, and it requires a partition number or drive letter. The partition number starts with 0. If the specified value is a drive letter, the disk number can be ignored.
  • "fs" in this context refers to the file system type, which can be one of the following: fat16, fat32, or ntfs.

Delete a Partition
Parameters Description
DiskMasterX.exe /hd:0 /del:0 Delete a specified partition.
DiskMasterX.exe /del:F
DiskMasterX.exe /hd:0 /del:all Delete all the partitions on a disk.
Hide/Unhide a Partition
Parameters Description
DiskMasterX.exe /hd:0 /hide:0 Hide a specified partition.
DiskMasterX.exe /hide:F
DiskMasterX.exe /hd:0 /unhide:0 Unhide a specified partition.
Mark a Partition as Active
Parameters Description
DiskMasterX.exe /setact:1 /hd:0 Set a specified partition as active.
DiskMasterX.exe /setact:F
Initialize a Disk
Parameters Description
DiskMasterX.exe /init:1 Initialize a disk as MBR.
DiskMasterX.exe /init:1 /gpt Initialize a disk as GPT.
Rebuild MBR
Parameters Description
DiskMasterX.exe /rebuildmbr:0 Rebuild master boot record (MBR) for a hard disk, a removable disk or a USB flash drive.
DiskMasterX.exe /rebuildmbr:0 /mbrtype:0
DiskMasterX.exe /rebuildmbr:0 /mbrtype:1
DiskMasterX.exe /rebuildmbr:0 /mbrtype:2
Notes:
  • "/rebuildmbr" followed by disk number, which starts with 0.
  • The "/mbrtype" option supports a specified MBR type, with values 0, 1, and 2, indicating the creation of MBR types for Windows XP/2000/2003, Windows Vista/2008, and Windows 7/8/8.1/10/2012/2013 respectively.
  • If the value of /mbrtype is not specified, the default type is the same as the current system, so if the system is Windows XP, the default is 0, and if it's Windows 8.1, the default is 2.

Change Drive Letter
Parameters Description
DiskMasterX.exe /hd:0 /setletter:0 /letter:* Remove drive letter.
DiskMasterX.exe /hd:0 /setletter:0 /letter:F Change drive letter to F.
Notes:
  • The commands "/hd" followed by disk number, "/setletter" followed by partition number, and the disk number and partition number always start with 0.
  • To remove a drive letter, you need to set the "/letter" value to * in the Windows Registry.
  • I won't remove or change the drive letter of the system partition. I will keep it as it is to ensure Windows boots properly.
  • If you use "/letter auto" to replace "/letter:F", the drive letter will be assigned automatically.

Write Files to a Hidden Partition
Parameters Description
DiskMasterX.exe /hd:0 /whide:0 /src:C:\file.txt Write files and folders to the root directory of a hidden partition.
DiskMasterX.exe /hd:0 /whide:0 /src:C:\folder
DiskMasterX.exe /hd:0 /whide:0 /src:C:\file.txt /dest:subfolder Write files and folders to the subdirectory of a hidden partition.
DiskMasterX.exe /hd:0 /whide:0 /src:C:\folder /dest:subfolder\test
Notes:
  • Before using the "/resize" and "/move" commands in Qiling Disk Master Command Line, it's recommended to run the Windows built-in chkdsk utility on the partition you want to resize, with the "/f" option to check and automatically fix any file system errors, ensuring data safety. For example, you can run "chkdsk.exe /f C:" on the C: drive.

Related Articles


Is this information helpful?     

What can we do to improve this information? (Optional)
Refresh Please enter the verification code!


QilingTech uses cookies to ensure you get the best experience on our website.  Learn more  Got it