▷ How to use diskpart to manage hard drive partitions
Table of contents:
- What is Diskpart
- How to access the Diskpart to start using it and first steps
- Diskpart options
- List and select objects with Diskpart
- Create, delete, format and resize partitions with Diskpart
- Format a partition with Diskpart
- Erase partitions from a hard drive
- Create partition on hard drive with Diskpart
- Logical and extended partitions
- Extend partition with Diskpart
- Convert basic hard drive to dynamic disk and vice versa
One of the most commonly carried out actions on our computer is to manage the configuration of our hard disk. This is why today we will see how to use the Diskpart command to learn how to do most of the basic operations with our hard disk using this program that is used from a command terminal.
Index of contents
What is Diskpart
Diskpart is a tool available on the command line that will allow us to manage everything related to our hard drives. Although we have a graphical tool in Windows to do this, with Diskpart we will have even more options available for configuring our disks.
Diskpart is integrated in the vast majority of Windows versions, from the XP version. Therefore, if we have Windows XP, Vista, 7, 8 or 10, we will have this tool natively available in our command terminal. In addition, we can use both Windows PowerShell and Command Prompt.
With Diskpart we will be able to see hard disks that the Windows graphical tool is not capable of detecting, as well as create partitions, delete them, resize them, format the disks, turn them into dynamic disks, etc. The options are many. It also has the ability to list failing hard drives or RAW drives and try to recover them using its options.
It really is a command that every somewhat advanced Windows user should know, since, for example, if our system gets corrupted, we will not have the graphical environment available to recover the hard drive. Diskpart is also available on Microsoft's operating system installation DVDs and USBs. In this way we could use them from the disk itself through a command prompt in recovery mode.
How to access the Diskpart to start using it and first steps
Well, the first thing we will have to know is how to access this program. For that we will have to use either Command Prompt or Windows PowerShell. In addition, we will have to take into account that we must run the tool with administrator permissions.
- To access Windows PowerShell we can right-click on the start menu to display a menu with a gray background. Here we will have the option of " Windows PowerShell (Administrator) ", and it is the one that we will have to select.
- To access the command prompt, the classic Windows command terminal, what we will have to do is open the start menu and type "CMD". Automatically a search result will be displayed where we will have to select the " Start as administrator " option after right-clicking on this option.
Then we will be located on any of the two command windows that we want to use, we have opted for PowerShell. What we will have to do is type the following command and press Enter:
diskpart
It does not matter whether it is lowercase or uppercase, at that moment the terminal promt (command identifier) will change and go to the state " DISKPART> ". It will be then when we are already inside the tool and we can access everything related to this tool.
Diskpart options
Now the first thing that we should know are the different options that we will have to use this command. To do this, we only have to type HELP in the promt and press Enter.
help
Let's see the most important ones and what we are going to use more frequently in our team:
- SELECT: it is used to select a volume or disk, for this we will put “select partition
”Or“ select disk " LIST: show a list of objects, either disks or partitions. DETAIL: lists in detail an object such as a hard disk or partition. ACTIVE: We mark a previously selected partition as active. ASSIGN: We assign a letter to the drive or mount point to the created volume. ATTRIBUTES: We manipulate the attributes of the volume. CLEAN: We delete all the configuration information and information from the hard disk that we have selected. CONVERT: we can make conversions between disk formats, normally used to convert a hard disk to dynamic or basic. CREATE: basic command to create partitions or virtual hard disks. DELETE: To eliminate any of the previous cases. EXTEND: Extend a FILESYSTEMS partition: show current and compatible file systems on the volume. RECOVER: Updates the status of all the disks in the selected package. Attempts recovery to disks from invalid packet and resynchronizes mirrored volumes and RAID5 with outdated complex or parity data. FORMAT: Format a volume or partition. REMOVE: We remove a letter to the drive or mount point assignment. EXIT: We quit Diskpart.
List and select objects with Diskpart
After viewing the list of most important options under our opinion, let's start with the basics, which is to list disks and partitions and select them. We must have one thing very clear, and that is that Diskpart bases its actions on the selected drive, volume or partition, and for this we will have to know the number of these when they are listed.
Discs
To list the discs that we have in our team we will write:
list disk
We will be shown a table with different columns of information. In the first one we have the disk number that the program has assigned, it will be very important to you when selecting one. We will also have the size of the disks, which will be necessary to know to identify which is which, and if it is a gpt disk. This will already be explained in a separate tutorial.
To select a hard disk and work on it we will have to put:
select disk For example, if we want disk 1, we will write " select disk 1 ". We can also list in more detail the characteristics of the selected hard drive, for this: detail disk
Using this information we will obtain the type of hard disk it is, the partitions it has created and the file format, in this case two in NTFS, and other extra options of the state of the hard disk. Partitions: We can also only list the partitions of the selected hard disk to access one of them and work: list partition
When we execute this command, one of them will appear with an asterisk if we have it selected, this means that the actions we carry out will be applied to this partition. To select one: select partition For example, we will enter partition 1 with " select partition 1 ". Now we are going to see what information we can get from this partition, for this we will use the detail command again, in this case: detail partition
We can also use another command to see what file systems this partition supports under the Windows system: filesystems
These basic commands will be interesting to use while performing operations on our hard drive. Volumes Volumes represent the partitions and drives mounted on our operating system. As with the other two, we can also work from the point of view of the volumes, list them and select them. For this we will use: list volume
select volume This list is useful to know which partitions or drives do not have a selected letter, and thus we know what is the actual number of partitions that exist in the system. For example, there are partitions such as OEM or System Recovery that do not have a letter selected so that you do not see it in File Explorer. Through the volumes we can see them all. Selecting a volume or partition to work with, for practical purposes, it is exactly the same. As long as we know the difference between the commands. select volume Y select partition We now move on to effective configurations for our discs. These are the basic ones, and with them we can create partitions, delete them or resize them to our liking. The first thing we can do is format a partition on our hard drive to erase all its content and be able to leave it completely clean. We can also choose the file system, cluster size, and its letter. Let's see how the procedure would be based on the fact that we are already inside the hard disk that interests us. list partition
select partition 1
We select the partition that we want. format For example, if we want our partition to be NTFS, have a cluster size of 512 KB, be formatted quickly and we want to give it a name, we will have to put the command in this way. format fs = NTFS unit = 512 label = ”Documents 1” quick
For more information on the format options, we will have to write: help format
Examples of uses of format: format -> is simply formatted by default with NTFS, cluster size 4092, and slowly. format fs = FAT32 -> is formatted slowly and with FAT32 file system format fs = NTFS label = ”Pelis” quick -> is formatted in NTFS, with the name of Pelis and quickly. We already know how to format a partition, now we are going to see how to completely delete partitions from a hard disk to create a new table in a personalized way, and thus eliminate the contents of the hard disk that we want. Of course, the actions will delete all the files on the hard drive. We select the hard disk that we are going to erase, and we put the following command to eliminate absolutely all the partitions: clean
Now we can create the partitions we want, so let's go there. With the selected hard disk, from Diskpart we will be able to create the partitions with the storage size that we want. In the example that follows, we are going to create a partition of a certain size, and the rest of the space for another partition. select disk create partition primary size = We create the first partition with custom size. create partition primary
We create the second partition with the rest of the available size list partition
When we create them, we list the result to see their number, since it will be important to leave them active with the following steps. We must stay, once again with the number of these partitions. It's time to format the partitions and assign them a name and letter to make them work, so let's get to it. First with partition 1: select partition format fs = NTFS label = ” The typical format for Windows partitions will be NTFS, so it will be the one we use. There is also FAT32 and EXFAT as we saw before with the command " filesystems ". activate
We activate the partition we have created. assign letter = We assign a letter for the system to recognize it, otherwise it will not appear in the file explorer. We do exactly the same with the other partition created, from the step on we select the partition. You can see it here: Now we will have our partitions created and ready to be used, and they will be displayed correctly in the browser. Never forget to assign them a letter and leave them active, otherwise they will not appear. As we saw at the beginning, we will be able to list which volumes are assigned letters with “ list volume ”. We can also create partitions that are not primary, in this case, they will be logical or extended. To do this we will use the same “ create partition ” command: create partition extended size = create partition logical size = The next steps in terms of management will be the same as for the primary partition. Now we will also see how we can resize a partition that we have already made on our hard drive in order to make it bigger. In this case we will have to bear in mind some limitations and actions: In our case, we made two partitions in the previous section and we do not have any unallocated space, so we will have to delete one partition before extending the other. So let's delete the 85GB partition 2 to extend partition 1. list partition
select partition delete
Now we are going to extend partition 1 to approximately 50 GB. select partition 1
extend size = 25000
We will already have the selected partition extended, and we will see it in the increase in size. Now with the remaining space we could make a new partition to take advantage of it. If we only put the command: extend
We will be extending a partition to the entire available unallocated size of the hard drive. As main actions, we would be left to see how to convert between a basic hard drive to a dynamic one and the opposite. In this case, we will have to take into account that using Diskpart: There are numerous applications available to do this conversion without losing files, but they are all for a fee. With this, we finish our tutorial on how to use Diskpart and its most frequently used options. We also suggest these tutorials: We hope that all this has been useful to get to know Diskpart better. Do you think this tool is complete or do you know any other better one? Leave us in the comments what you think.Create, delete, format and resize partitions with Diskpart
Format a partition with Diskpart
Erase partitions from a hard drive
Create partition on hard drive with Diskpart
Logical and extended partitions
Extend partition with Diskpart
Convert basic hard drive to dynamic disk and vice versa
How to partition a hard drive or ssd drive: all the information
Learn how to partition a hard drive to get an extra independent storage medium, which will give you many advantages on your hard drive.
Treesize free, the best application to manage the space of your hard drives
TreeSize Free is a free tool that informs us about the use of storage space on a hard drive or SSD.
How to use diskpart to clean and format
Tutorial on how to use Diskpart to format and clean from commands at the prompt step by step. We can breathe new life into our hard drive or SSD.