Linux Format USB Stick Command Explained For New Users

Linux Format USB Stick Command

Table of Contents

Get up to 50% off now

Become a partner with CyberPanel and gain access to an incredible offer of up to 50% off on CyberPanel add-ons. Plus, as a partner, you’ll also benefit from comprehensive marketing support and a whole lot more. Join us on this journey today!

Formatting a USB drive prepares it for different file systems and ensures compatibility with various platforms. In Linux, formatting a USB drive requires an understanding of the commands and tools used to manage storage devices. This process involves erasing all data on the drive and setting it up for future use.

This is a Linux-format USB stick help guide that teaches you formatting basics, with each step explained in detail.

How to Format a USB Drive for Linux

The following tools can be used to format a USB drive in Linux:

  • The terminal
  • Disk Utility
  • GParted

The sections below outline the steps for each tool.

Method 1: Linux Format USB Stick Using the Terminal

The terminal is the easiest and fastest way to format a USB drive Linux. The procedure consists of three steps:

  1. Locating the USB drive.
  2. Unmounting and formatting the USB drive.
  3. Verifying the process was successful.

Follow the instructions below to format a USB drive using the terminal.

Tech Delivered to Your Inbox!

Get exclusive access to all things tech-savvy, and be the first to receive 

the latest updates directly in your inbox.

Step 1: Locate USB Drive

Open the terminal and run the following command:

df

The terminal prints out a list of all mounted partitions and relevant information: used space, available space, used space percentage, and the path.

Locate the USB in the list and find the corresponding device. In this example, the USB drive is /dev/sdb1:

Listing all partitions in Linux with df command.

Note: If you are unsure of the drive designation, unplug the USB drive temporarily before running the df command again. The device that is now gone from the list is your USB device. You can also spot it by inspecting the total drive capacity.

Step 2: Unmount and Format USB Drive

Unmount the USB drives before formatting. To do so, use the following command:

sudo umount /dev/[device_name]


Replace [device_name] with the USB device name found in the previous step. For example:

Unmounting the USB drive.

After unmounting, format the USB drive by running a command or using a Bash script.

Format Using a Command

Use one of the commands below to format a USB stick Linux drive. Depending on your preferred file system, choose one of the following:

FAT32:

Enhance Your CyerPanel Experience Today!
Discover a world of enhanced features and show your support for our ongoing development with CyberPanel add-ons. Elevate your experience today!

sudo mkfs.vfat /dev/[device_name]

NTFS:

sudo mkfs.ntfs /dev/[device_name]

exFAT:

sudo mkfs.exfat /dev/[device_name]

Create a Bash script to simplify formatting USB drives that require frequent formatting. Using a script is simpler than memorizing Linux commands – just run the script to format the drive. Note that the following

Follow these steps:

  1. Execute the command below to install the necessary packages for the script:
sudo apt install udftools coreutils vim-common<br>
  1. Open a web browser, go to the script’s GitHub page, and download the Bash script.
  2. Change the script’s permissions to make it executable using chmod:
chmod +x format-udf.sh<br>
  1. Use df to identify your USB device name. Then, apply the following syntax to format the device:
./format-udf.sh /dev/[device_name]

Method 3: Format USB Using GParted Tool

Formatting with GParted takes longer because it requires an extra step, installing the tool. Nevertheless, it is a useful tool that you can use even after formatting the USB drive.

Follow these steps to format a USB drive using the GParted tool.

Step 1: Install GParted Tool

  1. Open the terminal and install the GParted tool:
sudo apt install gparted -y

Installing the GParted tool.
Wait for the installation to finish.

  1. Launch GParted with:
sudo gparted

The terminal opens the GParted program.

The GParted home screen.

Step 2: Select the USB Device and File System

  1. Choose your device from the drop-down menu at the top of the GParted home screen.

Select the USB drive in the GParted tool.

  1. Right-click the partition and select Format. Pick your desired file system from the list to proceed.

Selecting formatting settings in GParted tool.

Step 3: Start the Process

  1. Click the green checkmark button to apply all changes.

Applying formatting operation.

  1. A pop-up appears with a warning about data deletion. Click Apply to proceed.

A pop-up containing a warning message.
The GParted program formats the drive. The time it takes to format depends on the size and type of the USB drive.

  1. Click the Close button to exit the menu once the operation is done.

Using dd to Zero or Blank a USB Stick Before Formatting

dd (data duplicator/disk dump) is a tool that can transfer data between locations and also erase data.

By default, it is included in most Linux distributions. Therefore, we can easily use it to erase the data on a USB partition:

$ sudo dd if=/dev/zero of=/dev/sdb1 bs=1M


It is crucial to verify the output file. After executing the command, recovering the lost data becomes very challenging.

shred

Shred is a tool that repeatedly overwrites files and devices with random data, making it more difficult to recover the original data.

Similar to dd, it is commonly found on most Linux distributions:

$ sudo shred -n 3 -z /dev/sdb1<br>

Now, let’s explain this command:

-n indicates how many times to overwrite
-z fills the partition with zeros to conceal the shredding process

Key Takeaways

I just made the Linux format USB Stick process less complicated for you, so if you’re a beginner, this guide is everything you need to know. I’ll summarize it one more time for you.

To format a USB drive Linux, you can use Terminal, Disk Utility, and GParted. First, find the device name, then unmount the drive. Next, format the drive with your preferred file system. In Disk Utility, select the USB drive, pick the file system you want, and start the formatting. With GParted, create a partition table and save the changes.

FAQ’s

1. How can I format a USB stick in Linux using the command line?

Use the mkfs command. For example:

sudo mkfs.vfat /dev/sdX

This will format your USB to FAT32.

2. What is the ideal file system for a USB stick in Linux?

  • FAT32 for general use
  • exFAT for larger files
  • ext4 for Linux-only use.

3. Is it possible to format a USB without losing data in Linux?

No. Linux format USB stick will always erase data. Make sure to back up your files first.

4. How can I find out which device is my USB in Linux?

Use lsblk or fdisk -l and identify it by its size.

5. Is there a graphical way to format USB sticks in Linux?

Yes. You can use GNOME Disks or KDE Partition Manager.

Areeba Nauman
Areeba is a Content Writer with expertise in web content and social media, she can simplify complex concepts to engage diverse audiences. Fueled by creativity and driven by results, she brings a unique perspective and a keen attention to detail to every project she undertakes with her creativity and passion for delivering impactful content strategies for success. Let's connect on Linkedin: https://www.linkedin.com/in/areeba-bhatti/
Unlock Benefits

Become a Community Member

SIMPLIFY SETUP, MAXIMIZE EFFICIENCY!
Setting up CyberPanel is a breeze. We’ll handle the installation so you can concentrate on your website. Start now for a secure, stable, and blazing-fast performance!