How to Format Storage Drives Using the Linux Terminal – MUO – MakeUseOf

You don’t need to install a dedicated app to format external storage devices on Linux. Here’s how to do it from the terminal.
A storage device is an integral part of your computer hardware and computing in general. Used for storing processed data, storage devices come in many different forms. Some of the most common ones include external or internal hard drives, flash disks, CDs, etc.
This guide will show you how to format a storage device right from the Linux terminal.
When you format a storage device, you are essentially deleting all data or information stored on that device, more like restoring it back to its default factory settings. Some reasons you might want to do this include: to get rid of malicious software, improving performance, or removing sensitive data before handing over the storage device to another person.
Note: Always exercise caution when formatting drives to avoid losing important information.
If you wish to follow along, the best way is to practice using a USB flash drive. Note that the steps are the same for other storage devices as well. Just make sure that you backup your data before formatting the device.
Plugin your USB flash drive to your PC. Most Linux desktops will automatically mount your storage device once you connect it to your computer.
If for some reason, the device is not automatically mounted, here is how you can mount the drive in Linux.
Your USB flash drive will be listed under the files menu or on the desktop depending on your desktop environment. Most Debian-based distros like Ubuntu will list the drive on the files menu.
Before you can proceed to format your storage device, it is important that you are able to list and get the properties of the connected devices on your PC so that you 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:
The command lists all the storage devices available on your system. The -h option lists the storage devices in a human-readable format.
Most Linux distros automatically mount external storage devices such as USB flash drives under the /media/ directory.
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:
When your storage device is mounted on your system, Linux assumes the drive to be of a fixed size and specific format. For optimal efficiency when formatting, it is important you unmount your storage device first.
To unmount the storage device, you can use the umount command as below.
Note: In this case, /dev/sda1 is the physical address on which the storage device that we want to format is mounted. Make sure to get the correct mount point of your device on your system.
To format your storage device, use the mkfs (Make filesystem) command. The mkfs command builds a file system on a storage device according to the options specified.
The aforementioned command formats the specified drive using the FAT32 file format. Also, you can specify the new name or label of the USB flash drive. In this case, it will be MUO and the physical address mount point /dev/sda1. The FAT32 file system is compatible with all mainstream operating systems.
Apart from the FAT32 file system, other file system formats you can use for formatting your storage device include ext, Minix, MS-DOS, etc.
Once the formatting is complete, physically unplug the storage device from your computer and then plug it in again. 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 command.
This guide has looked at how to format an external storage device on Linux using the mkfs command. As with all things Linux, there are many other command-line tools for formatting storage devices; you can even use the GUI if you like.
If you are using another operating such as Windows, you get the option to format your internal or external storage devices graphically.
Formatting a USB drive is easy. Our guide explains the easiest and fastest ways to format a USB drive on a Windows computer.
Mwiza develops software by profession and writes extensively on Linux and front-end programming. Some of his interests include history, economics, politics & enterprise-architecture.
Join our newsletter for tech tips, reviews, free ebooks, and exclusive deals!

source

Share this post:

Leave a Reply