If you’re anything like me, you love experimenting with various Linux distributions. However, constantly creating bootable live USB drives for different distros can leave you with a cluttered and confusing USB drive. To avoid this mess and restore your USB drive to its original state, I’ve got a simple solution for you using fdisk in Linux.
Let’s dive into the step-by-step process to wipe all partitions and restore your USB drive, thanks to a helpful tip from PenDriveLinux.com.
Note: Before proceeding, ensure you’ve backed up any important data on the USB drive, as the following steps will completely erase its contents.
sudo su
fdisk -l
fdisk /dev/sdx
Type d
to delete a partition.
Type 1
to select the 1st partition and press Enter.
d
again to delete another partition. Don’t worry; fdisk should automatically select the second partition.To create a new partition, type n
.
Next, make this partition primary by typing p
and press Enter.
Type 1
to make this the first partition, and then press Enter.
Press Enter twice to accept the default first and last cylinder.
Write the new partition information to the USB drive by typing w
.
Unmount the USB drive by typing:
umount /dev/sdx
mkfs.vfat -F 32 /dev/sdx1
And there you have it! Your USB drive is now restored to a single FAT 32 partition, ready to be read from any computer.