In this guide, we go through the steps to format an SD or USB disk in Linux. This can be done via GUI or command line, and we'll cover the process for both. The guide will be applicable regardless of what Linux distribution you've decided to use, especially the command line method.

This will wipe all the data from your USB or SD disk and get it ready for use under Linux or another system. It's also used to clear the device before creating a bootable live USB drive.

In this tutorial you will learn:
  • How to format an SD or USB disk via GUI
  • How to format an SD or USB disk via command line
Formatting SD or USB disk on Linux
Formatting SD or USB disk on Linux
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software N/A
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ - requires given linux commands to be executed as a regular non-privileged user

Format SD or USB disk via GUI

Depending on what Linux distribution you're using, the screenshots below may not match up with exactly what you see on your own screen. We're using Ubuntu Linux in these steps, but the process should be mostly the same no matter what distro you're on. The key point is that you'll need to find and open your operating system's disk utility software.

  1. Once you have inserted the SD or USB disk into the computer, get started by opening your system's disk management application.

    Open the disk utility software from the application launcher
    Open the disk utility software from the application launcher

  2. SUBSCRIBE TO NEWSLETTER
    Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


  3. You should see your SD or USB disk listed among the other storage devices on your system. Make sure you select the one that you wish to format.

    The disk is listed among the other storarge devices on the system
    The disk is listed among the other storarge devices on the system
  4. You'll have several options on what to do with this drive. Click the one that says "Format Disk" or something similar.

    Select to format disk
    Select to format disk
  5. On our test system, we have a few different options for erasing and partitioning our USB thumb drive. A quick format won't securely erase the current data on the disk but it will perform the formatting very quickly, as the name implies. The other option is to rewrite the disk with all zeros (not necessary in the majority of situations). You can also create a MBR or GPT table, or apply no partitioning. If you're not sure, just leave the defaults selected and click "Format."

    Choose formatting options
    Choose formatting options
  6. As mentioned earlier in the guide, this process will completely erase the contents in your SD or USB disk. The formatting software warns us once again to make sure we're aware, then it wipes the drive completely.

    Confirmation box about wiping the SD or USB disk
    Confirmation box about wiping the SD or USB disk


That's all there is to it. If you chose the quick format option, the whole process should only take a matter of seconds. If you'd like to learn how to do this via command line, which is more universal across all Linux systems, we cover that in the next section.

Format SD or USB disk via command line

Once you've inserted the SB or USB disk into your computer, open a terminal and type the following commands to format it:

  1. First, let's figure out how to identify the media we wish to format. The name should start with /dev/sd and then a letter. Type the following command in terminal to see:
    $ sudo fdisk -l
    


    Find your device name in the fdisk output
    Find your device name in the fdisk output
  2. In our example, the USB disk has been assigned /dev/sdb. Use the mkfs command to format the disk with any file system you'd like. In this example, we're using ext3:
    $ sudo mkfs -t ext3 /deb/sdb
    


    Formatting disk via command line
    Formatting disk via command line

That's all there is to it. You can also specify things like ext2, ext3, ext4, fat32, ntfs, etc. If no file system is specified with -t, the device will be formatted as ext2.

Conclusion

In this guide, we saw how to format an SD or USB stick on Linux. The process is simple and can be done either via GUI or command line. The steps are pretty much the same on any Linux distro, though each disk utility may have a different name and have some different looking menus.

FIND LATEST LINUX JOBS on LinuxCareers.com
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in:



Comments and Discussions