How to Format a Hard Drive: Windows, MacOS, Linux
Hard drive formatting is a type of disk formatting that prepares a data storage device, such as a hard disk drive (HDD) or solid-state drive (SSD), for use by an operating system. This process creates a file system structure that allows the OS to store, organize, and retrieve data efficiently. Formatting removes existing data and sets up the logical framework needed for file management. Both HDDs and SSDs require formatting before they can function as usable storage, although the underlying hardware technology differs.
The process entails erasing existing file system information, creating a new partition table if required, and writing a fresh file system such as FAT32, exFAT, NTFS, HFS+, APFS, or ext4. Formatting affects the File Allocation Table (FAT) or its equivalent by rebuilding it from scratch, which removes references to existing files and resets the index that tracks where data is stored. While the data itself may remain on the disk until overwritten, the OS treats the space as empty and ready for new files.
There are two common methods: Quick Format and Non‑Quick Format. Quick Format recreates the file system structure without scanning the disk for bad sectors, making it much faster but less thorough. Non‑Quick Format, sometimes called a full format, scans the entire disk surface for errors and marks bad sectors so they are not used. This method takes longer but provides a more reliable result, especially for older or suspect drives.
On Windows, formatting is typically done through File Explorer, Disk Management, or the diskpart command-line tool. The user selects the drive, chooses the file system, and decides between Quick or Non‑Quick Format. On macOS, formatting is performed in Disk Utility, where the user selects the drive, chooses a format such as APFS or Mac OS Extended, and applies the changes. On Linux, tools like GParted or command-line utilities such as mkfs are used to create the desired file system, with options to perform quick or full formatting depending on the command parameters.
How to Format a Hard Drive in Windows?
The following steps outline multiple methods for formatting a hard drive in Windows, from quick in‑system tools to advanced command‑line options.

Pre-checks and Preparation:
Post-format checks and best practices
How to Format a Hard Drive in MacOS?
The following steps outline in detail how to format a hard drive in macOS using both graphical and command‑line methods.
Pre-checks and preparation
- Back up any needed data. Formatting deletes all data on the selected disk or partition.
- If FileVault is enabled, decrypt or ensure you have the password to avoid access issues.
- For external drives, connect directly to the Mac using a reliable cable and port.
- Decide on format and partition scheme:
- APFS for modern Macs and SSDs.
- Mac OS Extended (Journaled) for older Macs or mechanical HDDs used with pre-High Sierra systems.
- exFAT for cross-platform use with Windows.
- GUID Partition Map for Intel and Apple silicon Macs.
Open Disk Utility and reveal device-level view
-
Launch Disk Utility from Applications > Utilities.
- In the View menu, select Show All Devices so you can select the physical drive, not only the volume.
- Identify the target by its capacity and model to avoid formatting the wrong disk
Erase a whole disk using Disk Utility
-
Select the physical drive at the top level in the sidebar.
- Click Erase.
- Set Name, choose Format (APFS, APFS Encrypted, Mac OS Extended, exFAT), and set Scheme to GUID Partition Map.
- For HDDs only, click Security Options and choose the desired overwrite level. Leave it at Fastest for SSDs to avoid unnecessary wear.
- Click Erase, wait for completion, then click Done. The new volume mounts automatically.
Erase or reformat a single volume without touching other partitions
-
Select the specific volume under the disk in the sidebar.
- Click Erase, pick the desired Format, give it a Name, and confirm.
- Use this when you need to change file system type without altering other volumes on the same disk.
Create or adjust partitions in Disk Utility
-
Select the physical disk and click Partition.
- Click the plus button to add a partition, then set its Name, Format, and Size.
- Apply the changes. Disk Utility resizes and creates volumes as requested.
- Use APFS containers if you need multiple APFS volumes that share free space dynamically.
Set up for Time Machine or as a startup disk
-
For Time Machine, prefer APFS on macOS Ventura and later, or Mac OS Extended on much older systems.
- To make a drive bootable, install macOS onto the formatted disk from Recovery or a macOS installer.
Command line method with diskutil
-
Open Terminal from Applications > Utilities.
- List disks to identify the target:
- diskutil list
- Erase and create a fresh partition table and file system in one step:
- GPT with APFS:
- diskutil eraseDisk APFS "NewVolume" GPT diskX
- GPT with Mac OS Extended:
- diskutil eraseDisk JHFS+ "NewVolume" GPT diskX
- Single exFAT partition:
- diskutil eraseDisk ExFAT "NewVolume" MBR diskX
- GPT with APFS:
- Replace diskX with the correct identifier from diskutil list. Double check before running.
Post-format checks and best practices
-
Verify the volume mounts and appears in Finder. If not, select the volume and click Mount in Disk Utility.
- Open Get Info on the volume to confirm format, capacity, and available space.
- Run First Aid in Disk Utility to validate the new file system.
- Safely eject external drives before unplugging to avoid corruption.
How to Format a Hard Drive in Linux?
The following steps outline in detail how to format a hard drive in Linux using both graphical and command‑line methods.
Pre-checks and backups
-
Back up any important data. Formatting deletes all data on selected partitions.
- Disconnect non-target external drives to avoid mistakes.
- Ensure required tools are installed:
- On Debian/Ubuntu: sudo apt update && sudo apt install gparted exfatprogs exfat-fuse ntfs-3g
- On Fedora: sudo dnf install gparted exfatprogs ntfs-3g
- On Arch: sudo pacman -S gparted exfatprogs ntfs-3g
Identify the correct disk
-
List block devices:
- lsblk -o NAME,SIZE,TYPE,MOUNTPOINT,FSTYPE,MODEL
- Note the device path for the target disk (for example, /dev/sdb) and any mounted partitions (for example, /dev/sdb1).
- Double check capacity and model to avoid formatting the wrong device.
Unmount and remove existing signatures
-
Unmount any mounted partitions:
- sudo umount /dev/sdX1
- Remove old filesystem or RAID signatures to prevent conflicts:
- sudo wipefs -a /dev/sdX
Choose a partition table
-
GPT for modern systems and disks larger than 2 TB:
- sudo parted /dev/sdX --script mklabel gpt
- MBR for legacy boot scenarios:
- sudo parted /dev/sdX --script mklabel msdos
Create partitions using parted (CLI)
-
Start a single primary partition aligned to 1 MiB:
- sudo parted /dev/sdX --script mkpart primary ext4 1MiB 100%
- Verify the layout:
- sudo parted /dev/sdX --script print
- Optional separate partitions:
- Example root and data:
- sudo parted /dev/sdX --script mkpart primary ext4 1MiB 200GiB
- sudo parted /dev/sdX --script mkpart primary ext4 200GiB 100%
- Example root and data:
Alternative fdisk method (CLI)
-
Launch fdisk:
- sudo fdisk /dev/sdX
- Create a new GPT label (g), add a new partition (n), write changes (w).
- Re-read partition table:
- sudo partprobe /dev/sdX
Create filesystems
-
ext4 for general Linux use:
- sudo mkfs.ext4 -L Data /dev/sdX1
- xfs for large files and servers:
- sudo mkfs.xfs -f -L Data /dev/sdX1
- btrfs for snapshots and pooling:
- sudo mkfs.btrfs -f -L Data /dev/sdX1
- exFAT for cross-platform exchange:
- sudo mkfs.exfat -n Data /dev/sdX1
- NTFS for Windows compatibility:
- sudo mkfs.ntfs -f -L Data /dev/sdX1
Optional encryption with LUKS
-
Initialize encrypting hard drive:
- sudo cryptsetup luksFormat /dev/sdX1
- Open and map:
- sudo cryptsetup open /dev/sdX1 securedata
- Create a filesystem inside the mapper device:
- sudo mkfs.ext4 -L Secure /dev/mapper/securedata
Mount and verify
-
Create a mount point:
- sudo mkdir -p /mnt/data
- Mount the new filesystem:
- sudo mount /dev/sdX1 /mnt/data
- Check space and filesystem:
- df -h /mnt/data
- sudo blkid /dev/sdX1
Persist mounts in fstab
-
Get the UUID:
- sudo blkid /dev/sdX1
- Edit fstab:
- sudo nano /etc/fstab
- Add an entry (ext4 example):
- UUID=your-uuid-here /mnt/data ext4 defaults 0 2
- Test without reboot:
- sudo mount -a
SSD optimizations
-
Enable periodic TRIM:
- sudo systemctl enable fstrim.timer
- sudo systemctl start fstrim.timer
- Run an on-demand trim when needed:
- sudo fstrim -av
HDD checks and full format options
-
Surface read test to identify bad sectors:
- sudo badblocks -sv /dev/sdX
- Full filesystem check after creation:
- sudo e2fsck -f /dev/sdX1 For ext4
GUI method with GParted
-
Launch GParted with admin rights:
- sudo gparted
- Select the target disk from the top right dropdown.
- Device menu > Create Partition Table > choose gpt or msdos.
- Right click unallocated space > New > set size, alignment, and filesystem.
- Apply all operations and wait for the completion checkmark.
- Right click the new partition > Manage Flags if you need boot or esp flags.
Safe removal and final checks
-
Unmount before unplugging:
- sudo umount /mnt/data
- For encrypted setups, close the mapper:
- sudo cryptsetup close securedata
- Verify the device is no longer mounted:
- lsblk -o NAME,MOUNTPOINT /dev/sdX

