Skip to content

Instantly share code, notes, and snippets.

@sageworksstudio
Last active May 25, 2020 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sageworksstudio/1a22338302db7dd467e9c56b725d41dd to your computer and use it in GitHub Desktop.
Save sageworksstudio/1a22338302db7dd467e9c56b725d41dd to your computer and use it in GitHub Desktop.
Format USB FAT32

Format USB Fat32

List your block devices to find the location of the device:

$ lsblk

Unmount the drive. Replace dev/sdb1 with your drive location.

$ sudo umount /dev/sdb1

An optional, but practical step is to erase the drive:

Make double-damn sure you are selecting the correct device (this example is /dev/sdb). Replace /dev/sdb with your device. This can take a while depending on how large your device is. You may get an error dd: error writing '/dev/sdb': No space left on device but be patient it will finish writing.

$ sudo dd status=progress if=/dev/zero of=/dev/sdb bs=4k && sync

Create a new partition map. Again, change dev/sdb to your device:

$ sudo fdisk /dev/sdb

This next part is interactive:

  • Type o then enter to create a new DOS disklabel
  • Type n then enter to add a new partition
  • Type p then enter to make it a primary partition
  • Type 1 then enter to set the partition as the first partition
  • Press enter again to accept the default first sector
  • Press enter again to accept the default last sector (whole disk)
  • Type w then enter to write the partition label and exit

Now you need to format the drive. Replace mydrive of the label/name you want to use for your drive.

$ sudo mkfs.vfat -F 32 -n 'mydrive' /dev/sdb1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment