There are plenty of how-to pages on formatting a thumb drive on Linux, but most don’t show the fool proof way of doing it. After using a thumb drive in the Nintendo Wii, my son was convinced that it could not be reused, because Windows couldn’t see it when he plugged it in. A lot of Linux how-tos have the same problem. Others rely on tools that you may not have installed. This how-to avoids both problems.
To reformat any USB thumb drive for use on Linux or Windows:
- Be 100% sure that there is nothing you want on the thumb drive
- Run the following command: sudo fdisk -l
- When prompted [sudo] password for uname, enter your password
- You should see something like:
Disk /dev/sda: 500.1 GB, 500107862016 bytes 255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk identifier: 0x00004e9a Device Boot Start End Blocks Id System /dev/sda1 * 2048 960366591 480182272 83 Linux /dev/sda2 960368638 976771071 8201217 5 Extended Partition 2 does not start on physical sector boundary. /dev/sda5 960368640 976771071 8201216 82 Linux swap / Solaris
- Plug in the thumb drive
- Run sudo fdisk -l again
- You should see a new Disk /dev in the output, which is the device Linux has assigned to your thumb drive:
Disk /dev/sdb: 7876 MB, 7876902912 bytes 256 heads, 39 sectors/track, 1540 cylinders, total 15384576 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 Disk identifier: 0xc3072e18
- If the thumb drive has a valid partition table, you can skip to the last step. If it has one, you should see something like:
Device Boot Start End Blocks Id System /dev/sdb1 * 63 15384575 7692256+ c W95 FAT32 (LBA)
- Otherwise, substituting the device displayed in step 7 for /dev/sdb, run:
sudo fdisk /dev/sdb - If the thumb drive has no usable file system on it (like the thumb drive written by the Nintendo Wii), you’ll see something like this:
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0x219a4410. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) Command (m for help):
- Enter: w
- You should see:
The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
- Run: sudo fdisk /dev/sdb
- At the Command prompt, enter: p
- You should see something like:
Disk /dev/sdb: 4244 MB, 4244647936 bytes 131 heads, 62 sectors/track, 1020 cylinders, total 8290328 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 Disk identifier: 0x219a4410
- At the Command promt, enter: n
- When prompted for the Partition type, enter: p
- For the Partition number, enter: 1
- For the First sector, enter the lowest number in the range given (e.g. 2048)
- For the Last sector, use the largest number in the range given (e.g. 8290327), assuming you want to have only one big partition on your thumb drive
- At the Command prompt, enter: w
- Run the following command to create an empty filesystem on the thumb drive:
sudo mkdosfs -F 32 -I /dev/sdb1
Note: You have to be careful to get the device names correct. /dev/sdb is the device name of the drive (the whole thumb drive), whereas /dev/sdb1 is the device name of the first (and possibly only) file system partition on the drive.