How to Format a USB Drive on Arch Linux

How to Format a USB Drive on Arch Linux

Formatting a USB drive is a common task for anyone working with removable media—whether you’re preparing a bootable installer, clearing data, or switching between file systems. On Arch Linux, this task is typically done via the command line, offering flexibility and control. While GUI tools are available, mastering the command-line process deepens your understanding of storage management on Linux.

This article walks you through the entire process of formatting a USB drive on Arch Linux—from identifying the device, unmounting it safely, and choosing the appropriate file system, to creating a new partition table and formatting it properly.


Why Format a USB Drive?

Formatting a USB drive does several things:

  • Erases existing data (make sure to back up anything important)
  • Prepares the drive with a new file system (e.g., FAT32, NTFS, ext4)
  • Makes it compatible with a specific operating system or purpose (e.g., bootable media, shared file storage)

Depending on your needs, the file system and partition scheme may vary.


Step 1: Insert the USB Drive and Identify the Device

Once you plug your USB drive into the system, the first step is identifying its device path. This can be done using several tools:

Using lsblk

lsblk

Sample output:

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda      8:0    0 465.8G  0 disk
├─sda1   8:1    0   512M  0 part /boot
├─sda2   8:2    0 464.3G  0 part /
sdb      8:16   1  14.6G  0 disk
└─sdb1   8:17   1  14.6G  0 part /run/media/user/MyUSB

In this example, sdb is the USB drive. Make a note of it—but double-check to avoid wiping the wrong disk.

You can also use:

dmesg | tail

to confirm the device when it’s plugged in.


Step 2: Unmount the USB Drive

Before formatting, you need to unmount the device (not to be confused with ejecting it). For example:

sudo umount /dev/sdb1

If you see multiple partitions, unmount them all:

sudo umount /dev/sdb*

If the device is in use, try closing any file manager or terminal session accessing it. You can also use lsof:

lsof | grep /dev/sdb

Kill the related process if needed.


Step 3: Create a New Partition Table

To wipe the USB drive and start fresh, you can create a new partition table using parted, gdisk, or fdisk. We’ll use parted for this guide.

Launch parted

sudo parted /dev/sdb

At the prompt:

(parted) mklabel msdos

You can also use gpt instead of msdos if you’re planning to use modern systems and need UEFI boot support.

Now create a primary partition:

(parted) mkpart primary fat32 1MiB 100%

The first 1MiB is left free to avoid alignment issues, especially for bootable media.

When done:

(parted) quit

Step 4: Format the Partition with a File System

Now that you have a fresh partition (let’s say /dev/sdb1), you can format it with your desired file system.

Common choices

FAT32 (good for compatibility)

sudo mkfs.vfat -F32 /dev/sdb1

NTFS (good for large files and Windows)

sudo mkfs.ntfs /dev/sdb1

ext4 (best for Linux use only)

sudo mkfs.ext4 /dev/sdb1

exFAT (good for large files and cross-platform use)

sudo mkfs.exfat /dev/sdb1

Tip: If mkfs.exfat or mkfs.ntfs is not found, install the respective utilities:

sudo pacman -S exfatprogs ntfs-3g

Step 5: Label the Drive (Optional)

You can assign a label to help recognize your USB drive easily.

For FAT32 or exFAT

sudo fatlabel /dev/sdb1 MYUSB

For NTFS

sudo ntfslabel /dev/sdb1 MYUSB

For ext4

sudo e2label /dev/sdb1 MYUSB

You can check labels and UUIDs using:

lsblk -o NAME,SIZE,FSTYPE,LABEL,UUID

Step 6: Mount the Drive (Optional)

If you want to mount the drive manually:

sudo mkdir -p /mnt/usb
sudo mount /dev/sdb1 /mnt/usb

After you’re done:

sudo umount /mnt/usb

Or, simply remove the USB drive safely.


Step 7: Make the USB Bootable (If Needed)

To make the USB bootable (e.g., for installing Linux), you’ll often need to write an ISO image to it rather than just formatting. Use dd with caution:

sudo dd if=archlinux.iso of=/dev/sdb bs=4M status=progress oflag=sync

⚠️ This will overwrite the entire USB drive including the partition table.

After the process is done, you won’t see traditional partitions until you format it again.


Bonus: Use gparted (GUI Alternative)

For users who prefer a GUI, install gparted:

sudo pacman -S gparted

Then launch it with:

sudo gparted

From there, select your USB device and use the graphical interface to create, delete, or format partitions. It’s user-friendly and great for visual learners.


Common Troubleshooting Tips

  • Permission denied: Use sudo.
  • Device busy: Unmount the drive, close open processes, or reboot if necessary.
  • Wrong device formatted: Always double-check lsblk before proceeding. There’s no undo after dd or formatting.
  • File system not supported: Install necessary utilities (ntfs-3g, exfatprogs, etc.)
  • USB not detected: Try dmesg, or check if the port is working using another USB device.

Conclusion

Formatting a USB drive on Arch Linux is straightforward once you’re comfortable with basic terminal commands. Whether you’re preparing a clean drive for general use, creating bootable media, or wiping data securely, knowing how to handle disks on the command line is an essential Linux skill.

Here’s a quick recap of the steps:

  1. Identify the USB device using lsblk
  2. Unmount any mounted partitions
  3. Create a new partition table using parted
  4. Format the partition with your desired file system
  5. Label it for convenience (optional)
  6. Mount and use, or safely remove

If you’re doing this regularly, consider scripting some of the steps or using gparted for quick jobs. Arch Linux gives you the tools—you just need to wield them smartly.