How to format a hard drive via command line – 3 ways

Users encounter situations when it is necessary to format a disk through the Windows command line, for example, if for some reason formatting a hard disk in another way failed.

In this case, the user has the option to format the hard drive through the command line in the Windows operating system. Using the command line, depending on the situation, you can format the entire hard drive or one of the partitions (volumes) on the hard drive.

If the computer has one partition: “Logical disk (C:)”, which contains the Windows operating system and user data, it is impossible to format the disk in a running system, because this disk is currently used for system operation. In this guide, we will analyze how to proceed in this situation.

Please note that when formatting, all data will be completely deleted from the disk: files, folders, programs, photos, videos, music, etc. Therefore, take care of the safety of the necessary information in advance: copy important data to another disk that will not be formatted, or to removable media, such as an external hard drive, flash drive or CD / DVD drive.

Disk formatting is carried out in some situations:

  • when installing an operating system on a disk;
  • in case of virus infection, PC malfunctions;
  • when using a new hard drive;
  • to delete unnecessary data.

In this article, we will look at several ways to format a hard drive through the command line, the instructions provide examples for various situations that users encounter. These methods work on Windows 10, Windows 8.1, Windows 8, Windows 7 operating systems.

How to format a drive through the command line using the format command

The Command Prompt (CMD) tool has a “format” command that formats a drive to a specified file system. In a running operating system, using this command, you can format partitions on a disk that do not have Windows installed.

If there are several partitions on the hard disk (the system is located on the “C” drive), for example, disks “D” and “E” that need to be formatted, then using the “format” command, the disk “D” is formatted first, and then the disk “E”. If another optional hard drive is connected to the computer, this drive can be completely formatted because it does not have an operating system.

1 option. We format the disk through the Windows command line (standard option):

  1. Run command prompt as administrator.
  2. Enter the command to format the drive:
format d: /FS:NTFS
In this command, “d” is the name of the local drive on the computer to be formatted. “FS:NTFS” is the selected file system, instead of the “NTFS” file system, you can select another suitable file system. In the vast majority of cases, there is a choice between the NTFS and FAT32 file systems.
  1. Enter the volume label for the disk to be formatted.
Assign a volume label (disk name) to the disk. You can choose any convenient name that can be changed later from the Windows settings.
  1. Next, you need to press the “Y” key to agree with the conditions for formatting the disk, and then press the “Enter” key. You are warned that all data on the disk will be destroyed.

This will start the disk formatting process.

Option 2. If you add additional switches to the “format” command, you can customize the formatting options.

  1. Run command prompt as administrator.
  2. In the command line interpreter window, run the command:
format d: /FS:NTFS /x /q
The following switches have been added to this command: /x – turn off the volume, / q – quick format. The first key disables external influence on the disk from the running operating system so that everything goes well. The second key starts a quick format.
With a quick format, Windows marks all disk space as unused. The data remains on the disk, the operating system does not see it, new files are gradually written to this place. A normal, full format deletes all data on the drive, but this process takes much longer than a quick format.
  1. To start formatting, press the “Y” key.

After the process is completed, information about the completion of this operation will appear in the command line window.

We considered the option of formatting individual partitions of a hard disk, or another hard disk on which Windows is not installed, on the command line.

Using the DiskPart Utility

The Diskpart utility is designed to work with disks, the application performs the following operations: creating a new disk (volume), deleting an existing disk, creating a bootable USB flash drive , formatting a disk partition or the entire hard disk.

The program can be used on a running Windows operating system, but for simple formatting it is much easier to use the “format” command. We will consider two options for using DiskPart: formatting a hard disk partition, or formatting a hard disk system partition, the entire hard disk, if we have only one partition on it.

Due to the fact that we will not be able to format the system disk in a running Windows, we will use bootable media from which we will launch the command line. To do this, we need bootable media from which we can boot on the computer, and then run the command line: bootable Windows USB flash drive, Windows Recovery Disc, Windows installation DVD, Windows PE flash drive or disc, Live CD (Live CD, Live DVD, Live USB).

You need to boot on your computer from a USB flash drive or CD / DVD, depending on which media you are using. First, enter the BIOS or UEFI boot menu, select a boot device, and then, after booting from the media, in the Windows RE recovery environment, launch a command prompt.

How to format a disk via command line using Diskpart – 1 way

To format a separate non-system partition or hard drive, you can work from Windows or from bootable media.

In the command line interpreter window, you must execute sequential commands (after entering the command, press the “Enter” key):

  1. Launching the DiskPart utility.
diskpart
  1. Enter a command to list all disks (volumes) on the computer.
list volume
We need to find out the volume number (disk number) that needs to be formatted. When working from the recovery environment, the disk name may differ from the volume letter in the running operating system, be guided by the size of the partition.

On this computer it is “Volume 3”. You need to select your drive number to be formatted.

  1. Select a volume letter (you will have your own number).
select volume 3
  1. Start formatting in the “NTFS” file system, if necessary, you can select the “FAT32” file system.
format fs=ntfs quick
In this case, the NTFS file system is selected. The “quick” command performs a quick format.
  1. Run the command to exit the DiskPart application.
exit

Formatting a disk through the command line in Diskpart – 2 way

If you needed to format the entire system disk with all partitions, you need to boot to your PC from bootable media.

When using this method, all partitions on this disk will be cleared, all information will be marked as deleted.

In the Windows RE recovery environment, enter the command prompt, and then run the following commands in sequence:

diskpart
list volume
select volume 2
In our case, the system is located on the “C:” drive, which corresponds to “Volume 2”. On your computer, the system drive may have a different volume number.
clean
The “clean” command performs a quick cleanup of the disk, during which all partitions or volumes are deleted.
create partition primary
format fs=ntfs quick
exit

Article Conclusions

If necessary, the user can format the drive through the command line. Using the “format” command at the command line, format a single hard disk volume or hard disk if it is an additional non-system hard disk. Using the DiskPart program, you can format an individual partition or the entire hard drive.

To do this, you will need to boot on the computer from bootable media with the Windows RE recovery environment, from where you need to launch the command line, and then perform the necessary actions.

Leave a Reply

Your email address will not be published. Required fields are marked *