Example virtual disk diskpart in xp. Diskpart utility commands. Legacy DiskPart Windows Commands

This guide explains how to use the diskpart utility for the following Windows versions: Windows XP, Vista, 7, 8, 8.1 or 10.

What is diskpart

The diskpart utility (available in Windows 2000, XP, Vista, 7, 8, 8.1 and 10) can be used to create or delete partitions on your PC.

The utility allows you to:

  • Partion
  • Remove partitions
  • Remove formatting
  • Assign and remove drive letters and mount points
  • Convert disks from basic to dynamic
  • Create and extend volumes

Most commands that you can perform in Disk Management (see ) are available with diskpart. Because it’s a command line utility, you need to open Command Prompt and type diskpart .

On Windows Vista, 7, 8 and 10 systems, you can type diskpart at Run, click OK or press Enter and Command Prompt will automatically open with diskpart loaded.

When the utility is loaded, you will notice the version installed on your computer:

Microsoft DiskPart version 6.1.7600 Copyright 1999-2008 Microsoft Corporation. On Computer: MY_COMPUTER

Commands and parameters

The diskpart tool has the following commands and parameters available:


Error Codes

You can find a list of error codes to debug various errors:

  • Code 0 means that no errors occurred
  • Code 1 means that a fatal exception occurred
  • Code 2 means that the parameters you specified for a command are incorrect
  • Code 3 means that diskpart is unable to open the specified file
  • Code 4 means that diskpart (one of the services used by the utility) returned a failure
  • Code 5 means a command syntax error

diskpart in Windows XP

Note that the fdisk utility found in pre-Windows XP systems is now known as diskpart on Windows XP systems.

If you can boot into Windows XP

If you can boot into your computer, you simply need to open Command Prompt to access diskpart:

  1. Boot into Windows XP
  2. Click Start
  3. Click Run
  4. Type cmd
  5. Press Enter or click OK
  6. At the Command Prompt window, type diskpart
  7. Press Enter

If you can't boot into Windows XP

If you can’t boot into Windows XP to access diskpart, you have 2 options:

  • Use the original CD to access Recovery Console

If you have the original CD:

If you can’t boot into Windows XP, but you have the original CD, you can access the Recovery Console:

  1. Insert the Windows XP CD
  2. Reboot the computer
  3. Press any key to boot from the CD
  4. At the Microsoft Setup menu, press R
  5. Select the operating system and enter the Administrator password, if requested
  6. When Command Line appears, type diskpart
  7. Press Enter

diskpart in Windows Vista

You need to run these steps as an Administrator on Windows Vista systems.

If you can boot into Windows Vista with no errors, . Otherwise, follow.

If you can boot into Windows Vista

You simply need to open Command Prompt, if you can boot into Windows Vista:

  1. Boot into Windows Vista
  2. Click Start
  3. Type cmd
  4. Click Command Prompt from the search results list. You may need to right-click Command Prompt > Run as Administrator, if you are not logged in as Administrator already
  5. Type diskpart
  6. Press Enter

If you can't boot into Windows Vista

If you can't boot into your system, you have the following options:

  • Use the installation disc to access System Recovery Options
  • Access System Recovery Options without the installation disc (if installed)

If you can’t boot into Windows Vista, but you have the Windows Vista disc, follow these steps to open diskpart:


For the full list of diskpart commands and parameters, go to .

If your Windows Vista has the System Recovery Options installed and is available at the Advanced Boot Options menu, you can run Command Prompt from there. Otherwise, see the “If you use Easy Recovery Essentials” set of instructions below.

Follow these steps below to access diskpart without the installation disc:

    1. Reboot the computer
    2. Press F8 as your computer starts to boot, but before the Windows Vista logo appears
    3. Select Repair Your Computer, at the Advanced Boot Options menu

If a “Repair Your Computer” option isn’t listed, System Recovery Options is not installed on your computer. Use the original installation disc or go to the “If you use Easy Recovery Essentials”set of instructions below .

For the full list of diskpart commands and parameters, go to .

If you use Easy Recovery Essentials:

If you don't have the installation disc available, can't boot into Windows Vista or you don't have the “Repair Your Computer” option listed at the Advanced Boot Options menu, you can use Easy Recovery Essentials to access Command Prompt and load diskpart.

Follow these steps:


diskpart in Windows 7

Note that you need to run these steps as an Administrator on Windows 7 computers.

If you can boot into Windows 7

If you can boot into your Windows 7 system, simply open Command Prompt:

  1. Boot into Windows 7
  2. Click Start
  3. Type cmd
  4. Click Command Prompt from the search results list. Right-click on Command Prompt > Run as Administrator.
  5. When Command Prompt loads, type diskpart
  6. Press Enter

For the full list of diskpart commands and parameters, go to .

If you can't boot into Windows 7

Similar to Windows Vista, if you can’t boot into your system, you have the following options:

  • Use the installation disc
  • Boot into the Advanced Boot Options menu to access System Recovery Options
  • Use Easy Recovery Essentials and access Command Line

If you have the installation disc:

If you can’t boot into Windows 7, but you have the installation disc, you can run diskpart using the disc. To do so, follow these steps:


diskpart
  1. Press Enter

For the full list of diskpart commands and parameters, go to .

If you don't have the installation disc:

Usually, Windows 7 systems should have the System Recovery Options installed on the hard drive. If it’s not (follow steps below), go to the “If you use Easy Recovery Essentials” set of instructions below for an alternative to access diskpart.

Follow these steps to access diskpart without an installation disc on a Windows 7:


For the full list of diskpart commands and parameters, go to .

If you use Easy Recovery Essentials:


diskpart in Windows 8

If you can boot into Windows 8

If you can boot into your Windows 8 system, you simply need to open Command Prompt to access diskpart. To do so, follow these steps:

For the full list of diskpart commands and parameters, go to .

If you can't boot into Windows 8

If you can't boot into your Windows 8, you have these options available:

  • Use the original DVD or USB with Windows 8 or Windows 8.1 to access the Repair your computer option
  • Use Easy Recovery Essentials to launch Command Line

If you have the installation disc:


For the full list of diskpart commands and parameters, go to .

If you don't have the installation disc:

To access diskpart without an official Windows 8 or Windows 8.1 disc, follow these steps:


For the full list of diskpart commands and parameters, go to .

If you use Easy Recovery Essentials:

Easy Recovery Essentials can run from any CD, DVD or USB flash drives.

To access diskpart using Easy Recovery Essentials, follow these steps:


diskpart in Windows 10

If you can boot into Windows 10

If you can boot into your Windows 10 system, you simply need to open Command Prompt to access diskpart. To do so, follow these steps:

For the full list of diskpart commands and parameters, go to .

If you can't boot into Windows 10

If you can't boot into your Windows 10, you have these options available:

  • Use the original DVD or USB with Windows 10 to access the Repair your computer option
  • Boot into the System Recovery Options with Shift and F8
  • Use Easy Recovery Essentials to launch Command Line

If you have the installation disc:

If you can’t boot, but you have the installation disc, follow these steps:


For the full list of diskpart commands and parameters, go to .

If you don't have the installation disc:

If you don’t have the installation disc, you can boot into System Recovery Options or use Easy Recovery Essentials.

To access diskpart without an official Windows 10 media, follow these steps:


For the full list of diskpart commands and parameters, go to .

If you use Easy Recovery Essentials:

Easy Recovery Essentials can run from any CD, DVD or USB flash drives.

To access diskpart using Easy Recovery Essentials, follow these steps:


Troubleshooting

Download diskpart

You can not download diskpart utility. This utility is a command line utility part of Windows.

To access diskpart, you have the following options:

  • Use the original CD/DVD or USB of your Windows to access Recovery Console ( for Windows XP) or System Recovery Options (for Windows Vista-8)
  • Boot into the recovery mode of your Windows
  • Use Easy Recovery Essentials, our recovery and repair disk, and open Command Line to access diskpart

Instructions on how to access diskpart if you use Easy Recovery Essentials:

  1. Download
  2. Burn the ISO Image. Follow. If you’d like to have a recovery USB instead, follow .
  3. Boot Easy Recovery Essentials from the CD, DVD or USB
  4. Select Launch Command Line

Instructions on how to access diskpart if you have the installation disc:

Instructions on how to access diskpart if you don’t have the installation disc:

Format USB with diskpart

To format a USB flash drive with diskpart, follow these steps:

  1. Open the utility by typing diskpart in Command Prompt
  2. Press Enter
  3. Once loaded type list disk: list disk
  4. Press Enter
  5. Determine which of the disks listed is your USB flash drive, e.g. Disk 2.
  6. Type select disk 2 , if #2 is the USB flash drive presented by the list disk command
  7. Press Enter
  8. Type clean to clean the USB flash drive: clean
  9. Press Enter
  10. Type this command: create partition primary
  11. Press Enter
  12. Type active: active
  13. Press Enter
  14. You should now receive this confirmation message: DiskPart marked the current partition as active.
  15. Type this command to format the USB flash drive: format fs=ntfs label="MY USB DRIVE"

    where ntfs is the NTFS file system (you can also use fs=fat32) and “MY USB DRIVE” is the label given to the USB drive.

  16. Type assign: assign
  17. Press Enter
  18. Quit diskpart by typing exit: exit
  19. Press Enter

Bootable USB with diskpart

To create a bootable USB using diskpart, follow the steps from .

Once successfully formatted the drive, simply copy the files to the USB drive.

USB not showing in diskpart

diskpart will not list external media, e.g. USB flash drive, if you’re using Windows XP.

Windows Vista to Windows 8 systems will show the USB flash drives in diskpart.

More Information

Support Links

  • – our repair and recovery disk.

    It’s an easy-to-use and automated diagnostics disk. It's available for , and . It’s also available for Windows XP and Windows Server.

One way to format a flash drive is to use the command line. Usually it is resorted to in cases where it is impossible to do this using standard means, for example, due to an error occurring. We will look further at how formatting occurs via the command line.

We will consider two approaches:

  • through the team "format";
  • through the utility "diskpart".

Their difference is that the second option is used in more complex cases when the flash drive does not want to be formatted in any way.

Method 1: "format" command

Formally, you will do everything the same as in the case of standard formatting, but only using the command line.

The instructions in this case look like this:


If an error occurs, you can try to do the same, but in « safe mode» - so no unnecessary processes will interfere with formatting.

Method 2: "diskpart" utility

Diskpart is a special utility for managing disk space. Its wide functionality includes media formatting.

To use this utility, do the following:



This way you can set all the necessary formatting settings for the flash drive. It is important not to confuse the drive letter or number, so as not to erase data from another medium. In any case, completing the task is not difficult. The advantage of the command line is that everyone has this tool Windows users without exception. If you have the opportunity to use special programs to delete, use one of those indicated in our lesson.

For various tasks that users face, for example, you need to create bootable USB flash drive or there are problems formatting the flash drive using standard tools from Explorer, you need to format the flash drive using the command line. Formatting a flash drive via command line can be done in several ways.

In order to open the command line, launch the Start menu and enter the cmd command in the search bar.

In the command line window that appears, enter: format /fs:NTFS H: /q – where:

  • format – formatting task;
  • fs:NTFS – description of the file we select file system;
  • H: - the drive we need;
  • /q - command for quick formatting.

In the event that we want to format the file system in Fat or Fat32, the command will look like this: format /FS:FAT32 H: /q.

After entering the command, a message will appear: “Insert new disk into drive H: and press the ENTER key...” – press ENTER.

Then the command line window displays: “Volume label (11 characters, ENTER - no label needed)” -

so click on ENTER.

Our flash drive is formatted.

Format command (second method)

Call the command line as described in paragraph one.

In the command line window that appears, type: format H: /fs:NTFS /v:Arhiv – where:

  • format – disk formatting task;
  • fs:NTFS – description of the file systems we choose;
  • v:Arhiv – the label of the drive we select (the name of your drive is entered).

Accordingly, when we choose another file system, after fs: we enter what we need - Fat or Fat32. The command looks like this: format H: /fs:FAT32 /v:Arhiv. If you want to select quick formatting, you need to add Q to the formatting command and the command will look like this: format H: /FS:NTFS /Q /v:arhiv.

Immediately after entering the command, a notification appears in the command line window: “Insert a new disk into drive H: and press the ENTER key...” - press the Enter key.

The flash drive is formatted.

Method 3: Built-in Diskpart utility

In the operating room Windows system There is a built-in utility for working with drives, which allows us to format a flash drive.

Call the command line using the command cmd in search bar Start menu.

In the command line window that appears, enter: diskpart and the utility for managing storage spaces will launch.

Type the command: list disk. This will allow us to see all the drives present on our computer. We find a flash drive that we are going to format by size. We began to see all the disks with an indication of their volumes. We remember the number of the disk we select, for example, 2.

Then we type the command: select disk 2, where 2 is the drive we select. Press Enter.

After this, the flash drive must be cleared of attributes, for which we enter the command: attributes disk clear readonly. After that, enter the command: clean.

After clearing the drive of attributes, we need to create a primary partition, for which we mark our disk in the file system of our choice:

First, enter the command: create partition primary, then set the file system we need with the command: format fs=ntfs or format fs=fat32. If quick formatting is necessary, then write the command as follows: format fs=NTFS QUICK or format fs=FAT32 QUICK. Click on Enter and the flash drive is formatted.

Exit the program using the command: exit.

Built-in Diskpart utility (another way)

There is another, slightly different way to format the drive using the built-in Diskpart program.

Open the command line window as described above, then enter the diskpart command and press Enter to launch the utility.

Then enter the command list disk and press Enter again. This way we will see all our drives. After this, the same as in previous method, recognize your flash drive by size and remember the drive number. For example, 2.

We write the command: select disk 2, where 2 is the flash drive we select. Click on Enter.

Enter the command clean and press Enter - all files on the drive are deleted.

Next, you need to create a new partition on the flash drive, for which you enter the command: create partition primary and Enter, then the disk selection command: select disk 2 and Enter, where 2 is the drive we need. Then you need to enter the command: active so that the utility marks the partition as active. Then enter the command to mark up the file system: format fs=ntfs or format fs=fat32. As mentioned in the previous method, to quickly format, add QUICK to the command: format fs=NTFS QUICK or format fs=FAT32 QUICK.

After formatting is completed, you need to assign a letter to the flash drive. We do this using the command: assign, after which the drive autostarts, and we see an Explorer window on the screen with an already formatted flash drive.

To exit Diskpart, use the exit command.

Conclusion

As we showed in this article, formatting a flash drive via the command line is not difficult. The main thing is to carefully select the disk to format and remember that after formatting, your data may be lost forever. Working on the command line will help especially when working with the built-in Diskpart utility if the flash drive cannot be formatted in a simple way from the Explorer menu or when working with a flash drive, you noticed that part of the file system is not visible and the volume of the flash drive has decreased for some reason.

In the eventuality that you have been using computers since the early 1990s, then there is a chance that you heard of fdisk. If not, this is a utility embedded in the MS-DOS and Windows that allows users to format hard disk and create logical partitions. Microsoft DiskPart is a tool that replaces this handy application in operating systems starting with Windows 2000.

Allows you to preview details of the drive before making any adjustments

The program does not feature an interface, but rather you can install and access it using Command Line. On a side note, on Windows 10, the utility does not work with PowerShell. Following the straightforward installation, you can access the tool and commence managing your disks and volumes.

It is worth mentioning that the tool uses scripts and hence, it is recommended that you list and select the object of choice before performing various operations. Once selected, you will be happy to learn that you can find out more about the volume you are managing via the detail command. At the same time, you can assign new letters to the partitions and set the primary drive.

The application works with standard, extended and logical partitions and you can remove or further extend the ones already configured. Other noteworthy operations include import, retain, create volume stripe or setting up a raid from multiple hard drives. Moreover, you can change a drive into a dynamic or basic one using the convert command and selecting the MBR or GPT partitioning styles.

A comprehensive tool for formatting and setting partitions on your HDD

In spite of the CLI operation, Microsoft DiskPart is a reliable tool that enables you to adequately prepare and partition a brand new or older hard drive. Not only does it allow you to grab explicit information about the disk volumes but advanced users can conveniently manage multiple disks, volumes and create as many partitions as necessary.

Not all users know how to format a flash drive using the command line. Although this method is the most effective and convenient solution that allows you to quickly change the media format. Therefore, we want to tell you in detail about this operation, various associated nuances and features.

The formatting procedure may be needed in a variety of situations:

  1. Let's say you need to quickly delete all files stored on a flash drive.
  2. Another option is that you want to completely clean the media from viruses and malicious software.
  3. Change the file system format. For example, from FAT32, where there are restrictions on the size of written files, to NTFS.
  4. Tired of the slow performance of your flash drive? Or does the device not see it, but only displays a window with errors when connecting? Formatting will again be helpful and will most likely fix the problem.
  5. Also, quite often, users resort to this procedure if they need to fix errors on the drive that interfere with reading or writing files.
  6. If you need to create a bootable USB flash drive, then again you cannot do without formatting.

As you can see, there are many situations in which this operation is useful and irreplaceable. Therefore, it will be useful for you to learn how to format a flash drive via the command line.

Via the Format command

This is the most common method. With it, formally, you do everything the same as if you were using standard Windows tools. But in this case the command line is used. There is nothing complicated about this:


In addition, instead of the above command, you can enter another slightly modified one. It looks like this – “Format /FS:NTFS H”. “N” – in this case, is the drive we need. If you need to change the file system to FAT32, then the command should look like this: “Format /FS:FAT32 H”.

For reference! If your flash drive is not working well, information cannot be read from it, and new data, on the contrary, is not written, then you can only resort to a last resort - low level formatting. To do this, use not the command line, but special utility. For example, HDD program Low Level Format Tool.

Using the "diskpart" utility

There is another way to format a flash drive via the command line. In this case, a special utility built into the OS is used, which is used to manage disk space. It's called diskpart.

To use it to format the drive, do this:


Now, after formatting via diskpart, the flash drive can be made bootable. You just need to copy the distribution files operating system to the carrier.

What else should the user know? Working on the command line with the built-in diskpart utility is recommended in cases where the flash drive cannot be formatted in a simple way from the Explorer menu. If, when working with removable media If you notice that part of the file system is not visible or for unknown reasons its volume has decreased, then it is also advisable to format it in the manner described above.

Format the flash drive using the SDFormatter utility

In case formatting methods via the command line do not suit you (for example, they seem inconvenient), we can recommend the graphical utility SDFormatter. It contains only two formatting options, but allows you to configure the cluster size. You can download the program from the link. The functionality is free.

Finally

Through the command line you can format any USB drive or HDD without resorting to standard means formatting or special utilities. Moreover, even a novice user can easily cope with this procedure. The main thing is to know the commands, and also be able to enter them correctly and consistently.