How to format hard drive with command prompt​?

Formatting a hard drive using the Command Prompt in Windows allows you to erase all data on the drive and set up a new file system.

Prerequisites

You should have administrative privileges on the computer.

Make sure you have backed up all important data on the hard drive you plan to format, as the process will erase all data.

Steps to Format a Hard Drive with Command Prompt

Open the Command Prompt as Administrator:

Press the Windows key + R on your keyboard to open the “Run” dialog box.

Type “cmd” in the Run dialog box.

Press Ctrl + Shift + Enter to run the Command Prompt as administrator. You may be prompted to confirm the action by clicking “Yes” in the User Account Control dialog box.

List Disk Information:

In the Command Prompt window, type “diskpart” and press Enter. This will launch the DiskPart utility, which is used for disk management.

Inside DiskPart, type “list disk” and press Enter. This command will display a list of all the disks connected to your computer, along with their sizes and other basic information. Take note of the disk number that corresponds to the hard drive you want to format.

Select the Disk to Format:

Type “select disk [disk number]” and press Enter, replacing [disk number] with the actual number of the disk you want to format. For example, if the hard drive you want to format is disk 1. you would type “select disk 1”.

Clean the Disk (Optional but Recommended):

The “clean” command in DiskPart erases all partition and volume information on the selected disk. This is an optional step but is recommended if you want to start with a completely blank disk. Type “clean” and press Enter. This process may take some time depending on the size of the disk and the amount of data on it.

Create a New Partition (Optional):

After cleaning the disk, you can create a new partition. To create a primary partition that uses the entire disk, type “create partition primary” and press Enter.

If you want to create a partition with a specific size, you can use the “create partition primary size=[size in MB]” command. For example, “create partition primary size=5000” will create a primary partition that is 5000 MB (5 GB) in size.

Select the New Partition:

Type “select partition 1” to select the newly created partition. If you have multiple partitions on the disk, make sure to select the correct one.

Format the Partition:

Now it’s time to format the partition. The basic command to format a partition is “format fs=[file system] label=[volume label]” where [file system] is the type of file system you want to use (such as NTFS, FAT32. or exFAT) and [volume label] is the name you want to give to the drive.

For example, to format the partition as NTFS with the volume label “MyData”, you would type “format fs=ntfs label=MyData”.

You can also add other options to the format command. For example, “/q” is used for a quick format, which is faster but doesn’t perform a full surface scan of the disk. So the command would be “format fs=ntfs label=MyData /q”.

Assign a Drive Letter (Optional):

By default, the newly formatted partition will be assigned a drive letter automatically. However, if you want to change or specify a particular drive letter, you can use the “assign letter=[drive letter]” command. For example, “assign letter=D” will assign the drive letter “D” to the formatted partition.

Verify the Formatting:

You can use the “list volume” command in DiskPart to see a list of all volumes on the disks, including the newly formatted one. Check that the volume has the correct file system, label, and drive letter.

Exit DiskPart:

Once you are done with all the operations, type “exit” to exit the DiskPart utility.

Formatting a Hard Drive in Linux

In Linux, the process of formatting a hard drive is different from that in Windows. Here are the general steps:

Identify the Hard Drive:

Use the “lsblk” command to list all the block devices in the system. This will show you the hard drives and their partitions.

Look for the hard drive you want to format. It will usually be named something like “/dev/sda”, “/dev/sdb”, etc.

Unmount the Drive:

Before formatting, you need to unmount the drive if it is currently mounted. Use the “umount” command followed by the mount point or the device name. For example, if the drive is mounted at “/mnt/mydrive”, you would type “umount /mnt/mydrive”.

Format the Drive:

The most common tool for formatting in Linux is “mkfs”. To format a drive as ext4. you would use the command “mkfs.ext4 /dev/sda1”, replacing “/dev/sda1” with the actual device name of the partition you want to format.

You can also format the drive as other file systems such as FAT32 or NTFS. For FAT32. you can use “mkfs.vfat /dev/sda1”, and for NTFS, you may need to install the “ntfs-3g” package first and then use “mkfs.ntfs /dev/sda1”.

Mount the Drive (Optional):

After formatting, you can mount the drive to a specific directory in the file system. Use the “mount” command followed by the device name and the mount point. For example, “mount /dev/sda1 /mnt/mydrive”.

Potential Issues and Solutions

Disk in Use Error: If you try to format a disk that is currently in use by the system or other applications, you will get an error. Make sure to close all programs that may be accessing the disk and unmount the disk if it’s a removable drive.

Permission Issues: If you don’t have administrative privileges, you won’t be able to format the disk. Make sure to run the Command Prompt or the relevant commands with root or administrative rights.

Formatting Errors: If there are bad sectors on the disk, the formatting process may fail or take a long time. You can try using disk repair tools to fix the bad sectors before attempting to format again.

About us and this blog

Panda Assistant is built on the latest data recovery algorithms, ensuring that no file is too damaged, too lost, or too corrupted to be recovered.

Request a free quote

We believe that data recovery shouldn’t be a daunting task. That’s why we’ve designed Panda Assistant to be as easy to use as it is powerful. With a few clicks, you can initiate a scan, preview recoverable files, and restore your data all within a matter of minutes.

Subscribe to our newsletter!

More from our blog

See all posts