Sub topic 7
Disk commands: chkdsk, format, and diskpart
This chapter assumes you can open an elevated Command Prompt, read a command's help with /?, and explain the difference between a disk, a partition, and a volume. It covers three command-line disk tools: chkdsk, format, and diskpart. You should finish able to pick the right one for a symptom and run it without destroying data by accident.
The working model
A physical disk holds partitions. A partition formatted with a file system (NTFS, FAT32, or exFAT) becomes a volume, usually with a drive letter. The three tools work at different layers.
| Tool | Layer | Typical use | Risk to data |
|---|---|---|---|
| `chkdsk` | File system and sectors | Find and repair file system errors | Low to moderate |
| `format` | Volume | Create a new, empty file system | Erases the volume |
| `diskpart` | Disk and partition | List, create, delete, and modify partitions | Can erase whole disks |
chkdsk: checking a volume
chkdsk reads a volume's file system structures and reports problems such as lost clusters, cross-linked files, and bad index entries. Run it from an elevated prompt. Without switches it only reports and does not fix anything.
chkdsk C:
chkdsk C: /f
chkdsk C: /rchkdsk C:is read-only. It reports problems but changes nothing./ffixes file system errors. It needs to lock the volume./rdoes everything/fdoes, then locates bad sectors and recovers readable data from them. It reads every sector, so it can take hours on a large or failing drive./rimplies/f.
The locked volume case
chkdsk /f cannot fix a volume that is in use. For the system drive, Windows asks whether to schedule the check for the next restart. Answer Y and restart. For a data drive, chkdsk may offer to dismount the volume first, which closes open handles.
Edge cases and gotchas
- Failing hardware. If
chkdsk /rfinds growing numbers of bad sectors, the drive is dying. Copy data off first, because/rputs heavy read stress on a weak drive. Replace the drive rather than repeating the repair. - SSDs. Bad-sector scanning matters less on a solid-state drive, because the controller remaps failed blocks itself.
chkdsk /fis still useful for file system errors. - Dirty bit. If Windows detects an unclean shutdown, it marks the volume dirty and runs a check at boot. This is normal after a power loss.
- Elevation. Without administrator rights,
chkdskreports that access is denied. - Switch syntax. Switches follow the drive letter in the exam's usual form, such as
chkdsk C: /f.
format: creating a file system
format writes a new file system to a volume. Existing files become inaccessible, so use it only when you intend to wipe the volume.
format E: /FS:NTFS /V:Data /Q/FS:sets the file system:NTFS,FAT32, orexFAT./V:sets the volume label./Qruns a quick format.
Quick versus full format
| Type | What it does | When to use |
|---|---|---|
| Quick (`/Q`) | Writes a new file system structure and skips scanning the disk | New or healthy drives, fast reuse |
| Full (no `/Q`) | Also checks the volume for bad sectors and, on current Windows, overwrites it with zeros | Suspect media, or when you want a stronger wipe than quick |
A quick format does not erase the underlying data blocks. Recovery tools can often read the old files. For disposal or reassignment of a drive that held sensitive data, a quick format is not enough. Use a full format, a manufacturer secure-erase tool, or a destruction method that matches your organization's policy.
Choosing a file system
- NTFS: the Windows default. It supports permissions, encryption, compression, and large files.
- FAT32: compatible with many devices, but a single file cannot exceed 4 GB, and Windows' own formatting tools limit FAT32 volumes to 32 GB.
- exFAT: suited to flash drives and large removable media shared between Windows and macOS. It has no file permissions.
You cannot format the volume Windows is running from while it is booted. format also asks you to confirm before it proceeds.
diskpart: managing disks and partitions
diskpart is an interpreter, so it has its own prompt (DISKPART>). It works on the object you have selected. Almost every mistake with it comes from running a command against the wrong selection.
Start safely with commands that only list information:
diskpart
list disk
list volume
exitThe select-then-act pattern
list diskshows disks with numbers and sizes.select disk 1picks one. The*in the list marks the selection.detail diskorlist partitionconfirms it is the disk you meant, by size and contents.- Only then run an action command.
The following script prepares a new data disk. Check the disk number against your own list disk output first, because this erases the selected disk.
diskpart
list disk
select disk 1
detail disk
clean
convert gpt
create partition primary
format fs=ntfs label="Data" quick
assign letter=E
exitCommon commands
| Command | Effect |
|---|---|
| `list disk`, `list volume`, `list partition` | Show objects, with no changes |
| `select disk N` | Sets the target disk |
| `clean` | Removes all partition and volume information from the selected disk |
| `convert gpt` / `convert mbr` | Changes the partition style. The disk must be empty, so run `clean` first |
| `create partition primary` | Makes a partition from free space |
| `format fs=ntfs quick` | Formats the selected partition |
| `assign letter=E` | Gives the volume a drive letter |
| `active` | Marks an MBR partition as bootable |
Gotchas
cleanis immediate and has no confirmation prompt. Selecting the wrong disk beforecleanis a common cause of data loss.- Disk numbers can change after you unplug or add drives. Do not reuse a script without checking
list disk. - Use
clean allonly when you want to zero every sector. It takes a long time. - MBR disks are limited to 2 TB and four primary partitions. GPT removes these limits and is needed for UEFI boot.
Choosing between them
- A volume behaves oddly, shows corrupted files, or Windows reports a dirty volume: run
chkdsk /f. - A new drive does not appear in File Explorer: it likely needs initializing and partitioning, so use
diskpartor Disk Management. - A flash drive needs a different file system: use
format. - A drive has an unwanted or damaged partition layout: use
diskpartwithclean, after a backup.
The next chapter covers sfc and DISM, which repair Windows system files instead of the file system underneath them.
Exercise
A technician runs chkdsk D: /f on a data drive and gets a message that the volume is in use. What are two ways to proceed, and why would the technician choose /r instead of /f for a drive that is making clicking noises?
Show answer
The technician can allow chkdsk to dismount the volume (closing open handles) or schedule the check for the next restart. /r also locates bad sectors and recovers readable data, which suits a suspect drive. However, a clicking drive is likely failing, so the technician should back up data first, since /r reads every sector and stresses the drive.
Exercise
You need to initialize a new 4 TB disk that appears as Disk 2 in list disk. Which partition style should you pick, and what must you do before convert works?
Show answer
Use GPT, because MBR cannot address more than 2 TB. The disk must have no partitions, so run select disk 2 (after confirming with detail disk) and then clean before convert gpt.