Same Goal, Different Paths — Formatting External Drives via CLI on Windows, Linux, and macOS

Same Goal, Different Paths — Formatting External Drives via CLI on Windows, Linux, and macOS
In the three-way kingdom of personal computer operating systems — Windows, Linux, and macOS (though the market share gap is huge: Windows at roughly 88%, macOS around 8%, Linux about 2%) — many operations and commands are strikingly similar, yet have to differ for historical or licensing reasons. All three are essentially branches from the UNIX family tree, and operating systems inevitably share similar principles and functions. Still, for users trying to switch from one system to another, there's considerable friction. The deeper you know one system, the harder it is to move to another.
When you need to transfer data between different systems using an external hard drive, things get even messier. If the drive was formatted in a macOS or Linux-specific format, other systems generally can't read or write to it. (You can sometimes install third-party software to work around this, but that's both a hassle and defeats the whole purpose of a portable drive.) So if you want cross-platform compatibility, format your external drive as NTFS or exFAT. (FAT is not recommended.)
All three major operating systems provide graphical disk management tools. Windows has the most convenient one — after all, Windows was designed around the philosophy of "click more, type less," with graphical operations dominating and its command line perpetually criticized yet never much improved. macOS's Disk Utility has a decent interface but can be frustratingly bare-bones, sometimes falling short of what you need. As for Linux, graphical tools are all a facade — the command line is king. This demands that Linux users be proficient with the terminal in a way that Windows and macOS users simply aren't. Linux's biggest disadvantage compared to macOS is the lack of commercial software support, which limits its desktop adoption. macOS's walled garden, meanwhile, is somewhat self-inflicted, making it hard to compete head-to-head with Windows on the desktop.
The biggest limitation of graphical disk tools comes down to permissions and functionality — certain operations are simply off-limits. For instance, if an external drive was previously used as a boot disk, or had Windows To Go or a Linux Live system installed on it (I've run into both), trying to reformat it back to a normal data drive through the GUI might just fail. These problems can usually be solved through the more powerful command-line tools. On Windows, the disk management command is diskpart (back in the DOS era there was also fdisk). On Linux it's fdisk. On macOS it's diskutil.
1. Windows: diskpart
On Windows (using Windows 10 as an example), you need to run the command prompt with administrator privileges for full access. Right-click the Start menu button in the bottom-left corner to find the option. Once you have the command prompt open:
diskpart // enter the diskpart environment
list disk // list all disks
select disk 3 // select a disk (use the actual disk number)
clean // wipe the selected disk
create partition primary // create a partition
format fs=ntfs label="YourLabel" quick // quick format as NTFS
assign // critical — makes everything take effect
2. Linux: fdisk
Unlike Windows, Linux uses sudo to elevate privileges rather than requiring a separate admin terminal.
Run fdisk -l to list all disks. Once you've identified the target (say /dev/sdb), run fdisk /dev/sdb to enter that device for operations. Note the Linux design philosophy: everything is a device — so "entering a device" means operating on a specific disk.
You'll see:
Command (m for help): // type m to see all available commands
Common commands:
d delete a partition
l list known partition types
n add a new partition
p print the partition table
q quit without saving changes
w write table to disk and exit (actually writes to disk)
3. macOS: diskutil
Open Terminal on macOS and run diskutil to see the help menu. In practice, you append parameters to diskutil as needed.
Common operations:
diskutil list // list all disks
diskutil eraseDisk HFS DiskName /dev/DiskNodeID // erase and format as HFS (Mac OS Extended)
diskutil eraseDisk ExFAT DiskName /dev/DiskNodeID // erase and format as exFAT
A Word of Caution
The most important thing — and I cannot stress this enough — is that disk operations require extreme caution. On the command line especially, many actions are irreversible. Pick the wrong disk or type the wrong command, and you could lose data, crash your system (accidentally formatting the system drive), or worse. Backing up your data beforehand is a good safety net, but no amount of backups beats being careful in the first place. When performing any disk operation, you really cannot be too cautious. As the old saying goes: "A careful sailor sails for ten thousand years."


