Format USB Drive in Linux – Command Line

Formatting USB drives in Linux from the command line (terminal) is very easy.

In this note i will show how to format an external HDD, SSD or USB flash drive in Linux from the command line using mkfs utility.

I will provide the examples of disk formatting to the most popular file system types: FAT32, exFAT, NTFS, EXT4, XFS and will show how to list the all supported file systems.

Cool Tip: Check the real actual size of USB flash drive or SD card! Read More →

Format USB Drive in Linux

Execute the lsblk command to identify the name of the partition on the USB drive you want to format:

$ lsblk -fp
NAME                            FSTYPE      LABEL       UUID     MOUNTPOINT
└─/dev/sda1                     LVM2_member             c52... 
  ├─/dev/mapper/mint--vg-root   ext4                    183...   /
  └─/dev/mapper/mint--vg-swap_1 swap                    337...   [SWAP]
└─/dev/sdb1                     vfat        USB Drive   345...   /media/user/usb0

In the example above, the USB drive is recognized by the operating system as a disk named /dev/sdb with a single partition /dev/sdb1 mounted on /media/user/usb0.

Unmount the USB drive if it is mounted:

$ sudo umount /media/user/usb0

Warning: Formatting the USB drive will cause the loose of data on it!

Format a USB drive to the desired format and create a label (optionally):

Format To Command
$ sudo mkfs.fat -F 32 /dev/sdb1 -n "USB Drive"
$ sudo mkfs.exfat /dev/sdb1 -n "USB Drive"
$ sudo mkfs.ntfs /dev/sdb1 -L "USB Drive"
$ sudo mkfs.ext4 /dev/sdb1 -L "USB Drive"
$ sudo mkfs.xfs -f /dev/sdb1 -L "USB Drive"

List all supported filesystem types:

$ mkfs.<TAB>
mkfs.bfs       mkfs.ext2      mkfs.hfs       mkfs.msdos     mkfs.xfs
mkfs.btrfs     mkfs.ext3      mkfs.hfsplus   mkfs.ntfs      
mkfs.cramfs    mkfs.ext4      mkfs.jfs       mkfs.reiserfs  
mkfs.exfat     mkfs.fat       mkfs.minix     mkfs.vfat      

Cool Tip: Test performance of HDD, SSD, USB Flash Drive, SD card! Read more →

Was it useful? Share this post with the world!

Leave a Reply