Today I want to tell you about such a wonderful program as. What's so wonderful about it? – you ask. And the fact that with its help you can (data from a flash drive after formatting) or a disk, and the most interesting thing is that this program is available to anyone Windows user through command line, in other words, does not require installation. And don’t let the phrase “command line” scare you – using it is much more convenient and simpler than it seems at first glance.


So, after we have inserted the flash drive into the USB connector, we launch the command line. To do this, click Start and in the search bar we write cmd, and press Enter.

In the command line that appears, write , thereby launching the disk management program. Click Enter.

In the list of devices we find our flash drive - it can be recognized by its size. In my case it's Disc 6. Therefore, next we write the command. If your flash drive is number 4, then you need to enter the command. If the number is 2, then , accordingly. Click Enter.

Then enter the command clean, which will delete all files from a flash drive or disk. Click Enter.

Then we enter the command. Thus, select the specified section and move the focus to it. Click Enter.

Then we execute the command. The system marks the partition as active. Click Enter.

Now it is necessary. It can be quick or complete. Full formatting is done with the command format fs=NTFS. If you don’t want to wait and time is running out, then do it quick formatting team format fs=NTFS QUICK. Click Enter.

We are waiting for the formatting to finish.

Now you need to assign a letter to the flash drive. We do this using the command assign. Click Enter.

The flash drive is automatically assigned a letter, and then the media automatically starts.

Now you can shut down the program. Enter the command exit and press Enter.

The last thing to do is to copy the operating system distribution files (the one for which we made bootable USB flash drive) to, in fact, our flash drive. After this, our flash drive will be bootable and will boot absolutely everywhere, on any device. With its help, you can install your operating system anywhere.

I would like to note that with the help of the program you can carry out many manipulations with both hard drives(), and with flash drives. The example discussed today is only a small part of all the possibilities. I will consider other commands and examples of working with this program in the following articles.

Also read on this topic:

Formatting a flash drive to NTFS
How to recover data from a flash drive after deleting or formatting? How to change disk size in Windows 2000/XP/Vista/7/8. Free EaseUS program Partition Master Free How to create a bootable UEFI USB flash drive for Windows installations 8.1 and 10?
How to freeze a row in Excel? How to create a disk image using Daemon Tools?

If a USB flash drive, memory card or any other type of storage media not working properly, cleaning the disk and its partitions using the “Clean” command and the Diskpart tool is one of the ways to solve problems. This way you can solve problems with a drive that cannot be formatted or whose capacity is displayed incorrectly.

This trick will also delete partitions that cannot be deleted built-in Windows tool such as Disk Management. This process will completely remove disk partition table, which will allow you to record it again.

Attention: This process will completely erase the entire disk, so be careful about the safety of your files. Also make sure that the correct drive is selected, otherwise you may accidentally delete data from the wrong drive.

Run Command Prompt as Administrator

To get started, run Command Prompt as an administrator. In Windows 10 or 8.1, simply right-click on the Start menu and select “Command Prompt (Admin).”

On Windows 7, search for "Command Prompt" in the Start menu. Right-click and select “Run as Administrator”.

Diskpart

For disk cleanup use the Diskpart command. Before continuing, make sure that the desired USB drive, memory card, or other device you are about to clean is connected to the computer.

To run the diskpart tool, enter the appropriate command in the Command Prompt window and press Enter:
Diskpart

Display a list of disks installed on your computer by entering the following command:
list disk

Review the results of the command and determine the disk number that needs to be cleaned.

Be careful! If the wrong disk number is selected, it will be erased and possibly important data will be lost.

In the screenshot below you can see that Disk 0 has a capacity of 111 GB, and Disk 1 has a capacity of 15 GB. We know that we need a 15 GB disk. So Disk 1 is a USB disk, and Disk 0 is internal hard drive computer.

Once the disk number has been determined, enter the following command, replacing the # sign with the disk number.

Attention: Be very careful. If an incorrect drive number is specified, all data on the wrong drive will be deleted.
select disk #

The diskpart command selected the specified disk. Now all actions will be performed with it. To completely clear the partition table, type the following command and press Enter.

Attention: This command will delete everything on the specified disk! Make sure you have copies of all important data before proceeding.
Clean

If everything is done correctly, you will see “disk cleanup completed successfully.” Close the command prompt.

Creating partitions and formatting a disk

Now, using the built-in Windows Disk Management tool, you can create partitions on the disk and format it. You can also use the diskpart command for this, but using the Disk Management tool is much easier.

To launch the Disk Management tool in Windows 10 or 8.1, right-click on the Start menu button and select “Disk Management”.

Now you will see that the disk you were working with has no partitions. Right-click on the unallocated area and select “Create simple volume” to create a partition on the disk and format it as desired file system. By default, Windows will create one partition the size of the entire disk.

If the described method does not work, for example, the disk has been cleaned, but it cannot be partitioned or formatted, or diskpart does not detect it, then the disk is physically damaged and will no longer be able to function normally. But the disk cleanup function via diskpart is a solution that can bring back to life disks that at first glance look absolutely hopeless.

If, despite repeated warnings, you still erase the wrong disk (and this happens VERY often), do not be discouraged. Data from it can still be recovered. This tool is perfect for this. data recovery from Hetman Software – Hetman Partition Recovery.

One way to format a flash drive is to use the command line. Usually it is used when standard means this cannot be done, 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.

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.

Diskpart is a tool for managing computer disk objects: disks, volumes, partitions. It is a text command interpreter. Allows you to sequence commands from batches and save them into automatic scripts. Included in operating systems Windows families, both home (since XP) and server (since 2003).

Running and entering commands

Using Commands and Scripts

Using the sequence of Diskpart commands we can create, for example, a bootable USB flash drive:

Creating a bootable USB flash drive using the diskpart utility

Scenarios are text files, the same sequence of commands is written on one line. The interpreter executes them one by one.

To run the script, you need to enter on the command line: diskpart /s script_name.txt. The output from script execution can also be redirected: diskpart /s script.txt>log.txt.

If an error occurs when executing one of the script commands, the script will stop executing. To avoid this, you need to add the following at the end of each script command:

Create partition primary noerr

format fs=FAT32 label=WinNT quick noerr

This option causes errors to be ignored and the script to run regardless of whether they occur.


Close