This is an old question, but here is a solution for Ubuntu since the only complete answer here is for Windows (on AskUbuntu...).
This CLI solution uses fdisk on Ubuntu 18.04. In this example, I am using a drive that has 64 GB total space, but displays only 512MB as available.
- Open up a terminal using
Ctrl + Alt + t. Identify the USB drive using the command
sudo fdisk -l. This will output all of your mounted disks and devices, with an individual entry looking something like:
Disk /dev/sda: 57.8 GiB, 62058921984 bytes, 121208832 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: 0xbbd6109c
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 1050623 1048576 512M c W95 FAT32 (LBA)
- Find your USB drive from the list based on the expected size in bytes. You will likely see two entries for your one USB drive like above: one for
Disk (a portion of the drive which is accessible to you) and one for
Device (the total space on the drive). In the original question, the
Disk entry would show 2 MB of space, and
Device would show 16 GB.
We can now reclaim this space so that all of it is accessible to you (instead of just the 2 MB in
Make a note of the
Disk's name; in this example, this would be
/dev/sda. NOTE: it is very important the identify the name for your drive correctly since we will be erasing the data on it -- you don't want to accidentally choose your hard drive and erase personal data!
Load the drive into fdisk with the command
sudo fdisk /drive/name, replacing
/drive/name with the name you from Step 3 (like
/dev/sda). This will start up the
fdisk CLI interface (not your normal terminal); you can show available commands by entering
p to confirm that this is the drive you found in Step 3. Enter
d to delete the existing
n to create a new partition. Press enter for each option to get the defaults (one partition that is the max size of your USB drive). You can enter in other values, e.g. if you want more than one partition. Enter
p again to check the new partition, which should be different than in Step 5.
w to save these changes and return to the normal terminal.
Add a file system -- if you don't know about file systems but want to use this drive with both Ubuntu and Windows, a good choice is NTFS. Enter
mkfs.ntfs -f /drive/name to format the drive. See below* for more info.
Mount the drive. A good walkthrough is here, but one quick way to do this is:
sudo mkdir /media/your_drive
sudo mount /drive/name /media/your_drive
The full space of your drive should now be accessible!
*About file systems: NTFS is compatible with both Ubuntu and Windows, but there are better options such as ext4 (Linux), exFAT (Win), FAT32 (both), etc. that you can/should use if you don't need the drive for both Linux and Windows -- I defer discussion of file systems to other questions.