How to format a USB flash drive?

Solution 1:

You can use Disks. It's installed by default and easy to use.

Disks application appears in Dash search

  • Click on the Dash icon
  • Search for "Disks"
  • Click on Disks

The application will show up:

choose device in Disks interface left bar

  • 1st: Choose the USB flash drive
  • 2nd: Click on the "gear" icon and choose "Format"

This little window will appear, just choose the option you want and click on Format:

Erase option, filesystem type option, and Name field shown in Format Volume dialog

Solution 2:

Use GParted

GParted screenshot

see the video

You can install it

  • from Ubuntu Software Center or

  • on the command-line:

    sudo apt install gparted
    

Use the command line

see the video

  1. To show the USB drive among all storage partitions and volumes on your computer use:

    lsblk
    

    You can also use:

    df
    
  2. Suppose it may be /dev/sdy1. Unmount it with:

    sudo umount /dev/sdy1
    
  3. To format drive with the FAT32 file system format:

    sudo mkfs.vfat -F 32 /dev/sdy1
    

    To set a file system label for your pen drive in the process:

    sudo mkfs.vfat -F 32 -n 'name_for_your_pendrive' /dev/sdy1
    

    You must include the -F 32 part to specify the FAT size, it is not 32 by default in ubuntu 19.10. For more info see man mkfs.fat.

Solution 3:

The Command-Line Way

In case you can't get your device formatted from the GUI, try this way.

  1. Open the Terminal (Ctrl+Alt+T)

  2. List your block storage devices by issuing the command lsblk
    Then identify your pen drive by it's SIZE. In my case its /dev/sdb

    enter image description here

  3. Erase everything in the pen drive (This step is Optional):

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

    Replace /dev/sdb with your corresponding device.

    Type very carefully this name or your may end up erasing one of your other disks. This will take some time. (option status=progress is not mandatory but provide you some feedback)

    It will pretend to be stuck. Just be patient.

    for example:

    dd if=/dev/zero of=/dev/sdb bs=4k && sync
    dd: error writing '/dev/sdb': No space left on device
    
    1984257+0 records in
    1984256+0 records out
    8127512576 bytes (8.1 GB) copied, 1236.37 s, 6.6 MB/s
    
  4. Make a new partition table in the device:

    sudo fdisk /dev/sdb
    

    Then press letter o to create a new empty DOS partition table.

  5. Make a new partition:

    • Press letter n to add a new partition. You will be prompted for the size of the partition. Making a primary partition when prompted, if you are not sure.

    • Then press letter w to write table to disk and exit.

  6. Format your new partition.

    • See your new partition label with the command lsblk
      In my case it is /dev/sdb1. Once again pay attention to this name as there will not be any protection to prevent you to erase an other disk.

    lsblk output

    • Issue the command below to format the new volume:

      sudo mkfs.vfat /dev/sdb1  
      

      Please replace /dev/sdb1 with your corresponding device.

    • Eject the device:

      sudo eject /dev/sdb