How to Format Storage Drives Using Linux Terminal


A storage device is an integral part of your computer hardware and of computing in general. Used to store processed data, storage devices come in many different forms. Some of the most common include external or internal hard drives, flash drives, CDs, etc.

This guide will show you how to format a storage device directly from the Linux terminal.

How to follow

When you format a storage device, you are essentially deleting any data or information stored on that device, more like restoring it to its factory default settings. Here are a few reasons why you might want to do this: to get rid of malware, improve performance, or remove sensitive data before handing the storage device over to someone else.

To note: Always be careful when formatting drives to avoid losing important information.

If you want to follow along, the best way is to practice using a USB stick. Note that the steps are the same for other storage devices. Just make sure to back up your data before formatting the device.


Connect your USB key to your PC. Most Linux desktops automatically mount your storage device once you connect it to your computer.

If for some reason the device did not mount automatically, here is how you can mount the drive in Linux.

Your USB drive will be listed in the files menu or on the desktop depending on your desktop environment. Most Debian based distributions like Ubuntu will list the drive in the files menu.

usb key under files

Get the properties of your storage device

Before you can proceed with formatting your storage device, it is important that you can list and get the properties of the connected devices on your PC in order to format the correct storage device.

Open the terminal from the Applications menu or via the shortcut Ctrl + Alt + T. In the terminal, run the following df command:

df -h

The command lists all the storage devices available on your system. The -h The option lists storage devices in a human readable format.

Linux storage device command list

Most Linux distributions automatically mount external storage devices such as USB drives under the /media/ phone book.

Here, the storage device that we want to format is mounted in the directory / media / mwiza / CORSAIR, where CORSAIR is the label of the storage device.

Some other important properties include:

  • The physical mount address of the storage device, / dev / sda1 in that case.

  • The size of the drive, including free space available and the amount used in both percentage and gigabytes.

  • Finally, the directory in which the USB key is mounted; / media / mwiza in that case.

Format your storage device

When your storage device is mounted on your system, Linux assumes that the drive is a fixed size and a specific format. For best efficiency when formatting, it is important that you first unmount your storage device.

To unmount the storage device, you can use the to disassemble order as below.

sudo umount /dev/sda1

To note: In that case, / dev / sda1 is the physical address on which the storage device we want to format is mounted. Make sure you have the correct mount point for your device on your system.

To format your storage device, use the mkfs (Create filesystem) order. The mkfs command creates a file system on a storage device according to the options specified.

sudo mkfs.vfat -n 'MUO' -I /dev/sda1

The aforementioned command formats the specified drive using the FAT32 file format. You can also specify the new name or label of the USB drive. In this case it will be MUO and the mount point of the physical address / dev / sda1. The FAT32 file system is compatible with all popular operating systems.

Besides FAT32 file system, other file system formats that you can use to format your storage device include ext, Minix, MS-DOS, etc.

When formatting is complete, physically unplug the storage device from your computer and then plug it back in. The system will mount your newly formatted drive with the name you specified in the command.

You can also check the name of the storage device by running the df -h order.

Format an external drive on other operating systems

This guide has looked at how to format an external storage device on Linux using the mkfs order. As with everything Linux, there are many other command line tools for formatting storage devices; you can even use the GUI if you want.

If you are using another operating system such as Windows, you have the option to graphically format your internal or external storage devices.


How to format a USB flash drive (and why you would need it)

Formatting a USB drive is easy. Our guide explains the easiest and fastest ways to format USB flash drive on Windows computer.

Read more

About the Author


Comments are closed.