Format USB Drive as FAT32

How to format a USB Drive for FAT32.

See USB drives

Plug your USB drive in, and you'll see a new device show up. Run lsblk and see something like:

NAME                  MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINTS
...
sda                     8:0    1   961M  0 disk

There it is. /dev/sda is our USB drive.

Format FAT32

Fat32 is a pretty good filesystem for a usb drive because it's cross-platform compatible. Form with this command:

sudo mkfs.vfat /dev/sda

But if you were doing a harddrive format for Linux, you could choose another filesystem format, like Ext4:

sudo mkfs -t ext4 /dev/sda

(or even NTFS).

Your drive is now formatted.

Check and repar

To check the health of your filesystem and make any needed repairs, run:

sudo fsck.vfat -a /dev/sda

-a for auto write fixes

Mount the drive

To now use the drive, you need to mount it so you can write files to it. Make a directory to mount to, like:

sudo mkdir -p /mnt/jtdrv

Then mount:

sudo mount -t vfat /dev/sda /mnt/jtdrv -o uid=1000,gid=1000,utf8,dmask=027,fmask=137

All these options are to mount as as a non-root user and allow writing. Here's an ubuntu.com explanation of the options.

Use the drive

You can see the drive now mounted with lsblk:

NAME                  MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINTS
...
sda                    8:0    1   961M  0 disk  /mnt/jtdrv

And you're ready to cd /mnt/jtdrv or cp files.txt /mnt/jtdrv/.

And when you're done, unmount:

sudo unmount /mnt/jtdrv