Format USB drives in FAT32 or NTFS format in Arch Linux

Today, we will see how to format an USB drive in FAT or NTFS file system in Arch Linux. There are many GUI tools out there to format a drive, but I always prefer command line mode which is very easy, fast and effective.

These are the two commands that I use to get this job done.

  • mkfs.vfat
  • mkfs.ntfs

As the name implies, mkfs.vfat will format an USB drive in FAT, and mkfs.ntfs will format the USB drive in NTFS format.

Almost all Linux distributions comes with these two commands by default. But, these commands are not available in Arch Linux minimal installation. We must install the following packages in order to use these commands.

  1. dosfstools
  2. ntfsprogs

To install dosfstools package, run:

sudo pacman -S dosfstools

Sample output:

resolving dependencies...
 looking for conflicting packages...

Packages (1) dosfstools-4.0-3

Total Download Size: 0.05 MiB
 Total Installed Size: 0.16 MiB

:: Proceed with installation? [Y/n] y
 :: Retrieving packages...
 dosfstools-4.0-3-x86_64 56.0 KiB 61.6K/s 00:01 [#####################################################] 100%
 (1/1) checking keys in keyring [#####################################################] 100%
 (1/1) checking package integrity [#####################################################] 100%
 (1/1) loading package files [#####################################################] 100%
 (1/1) checking for file conflicts [#####################################################] 100%
 (1/1) checking available disk space [#####################################################] 100%
 :: Processing package changes...
 (1/1) installing dosfstools [#####################################################] 100%
 :: Running post-transaction hooks...
 (1/1) Updating manpage index...

To install ntfsprogs, run:

sudo pacman -S ntfsprogs

Sample output:

resolving dependencies...
 looking for conflicting packages...

Packages (1) ntfs-3g-2016.2.22-1

Total Download Size: 0.48 MiB
 Total Installed Size: 1.54 MiB

:: Proceed with installation? [Y/n] y
 :: Retrieving packages...
 ntfs-3g-2016.2.22-1-x86_64 490.7 KiB 77.6K/s 00:06 [#####################################################] 100%
 (1/1) checking keys in keyring [#####################################################] 100%
 (1/1) checking package integrity [#####################################################] 100%
 (1/1) loading package files [#####################################################] 100%
 (1/1) checking for file conflicts [#####################################################] 100%
 (1/1) checking available disk space [#####################################################] 100%
 :: Processing package changes...
 (1/1) installing ntfs-3g [#####################################################] 100%
 :: Running post-transaction hooks...
 (1/1) Updating manpage index...

Now, let us see how to format an USB drive in MSDOS file system. This method is same for almost all Linux distributions.

Format USB drive in FAT32

First we will find out the USB drive name (This is what we say Drive letter in Windows OS).

It’s very simple, but at the same time you should be very careful if you are using dual-booting with Windows. If you don’t be careful, you might format one of your windows partitions accidentally.

We can easily find out our disk drive letters using fdisk command.

Plug your USB drive and run the following command to display the partition table.

sudo fdisk -l

Sample output:

Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
 Units: sectors of 1 * 512 = 512 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disklabel type: dos
 Disk identifier: 0x4c986a38

Device Boot Start End Sectors Size Id Type
 /dev/sda1 2048 206847 204800 100M 83 Linux
 /dev/sda2 4401152 976773167 972372016 463.7G 83 Linux
 /dev/sda3 206848 4401151 4194304 2G 82 Linux swap / Solaris

Partition table entries are not in disk order.
 Disk /dev/sdb: 7.5 GiB, 8053063680 bytes, 15728640 sectors
 Units: sectors of 1 * 512 = 512 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disklabel type: dos
 Disk identifier: 0xfdc01076

Device Boot Start End Sectors Size Id Type
 /dev/sdb1 * 63 15728639 15728577 7.5G c W95 FAT32 (LBA)
List out partition table

List out partition table

As you see in the above output, I have two disks. One is my local hard disk (500 GB), and another one is my USB drive (8 GB).

Again, I warn you please be careful if you are using dual boot with Windows or if you have multiple OSs in the single hard drive. If you use dual boot, this command will also display the Windows drives names like /dev/sdb1, /dev/sdc1 etc., in the above result. Just make sure you are formatting the correct drive.

As I mentioned in the above screenshot, my USB drive name is /dev/sdb1.

Once you find out the USB drive name, unmount it. Because you can’t format a mounted drive. Do not un-plug, just unmount the USB drive.

To unmount the drive, run:

sudo umount /dev/sdb1

Sample output:

Deepin Terminal_004

Unmount USB drive

Finally, format the USB drive in FAT32 using command:

sudo mkfs.vfat /dev/sdb1

Sample output:

mkfs.fat 4.0 (2016-05-06)
Format USB drive in FAT format.

Format USB drive in FAT format.

After formatting the drive, just unmount using it command:

sudo umount /dev/sdb1

Again, re-plug the USB drive to start using the it.

For further details, refer man pages.

man mkfs.vfat

Format USB drive in NTFS

Similarly, To format the drive in NTFS, just run:

sudo mkfs.ntfs /dev/sdb1

For more options, refer man pages.

man mkfs.ntfs

Set label name to USB drives

To set drive label name use ‘-n’ flag.

For example, the following command will format my USB drive in FAT32 format and set label name for my USB drive as “sk”.

sudo mkfs.vfat /dev/sdb1 -n sk

Please note that lowercase labels might not work properly with DOS or Windows. So, use upper case label name.

That’s all for today. You know now how to format an USB drive in MSDOS filesystem in Arch Linux.

Hope this helps. If you find this guide helpful, please share it on your social networks and support OSTechNix.

Cheers!