lsblk
and check the mount point, e.g.,/dev/sda
which might have different partitions like/dev/sda1
etcsudo umount /dev/sda*
. Usesudo umount -l /dev/sda*
if something refuses to unmountsudo fdisk /dev/sda
to delete all partitions one-by-one:- Press
p
to print the current partitions - Press
d
to delete each partition (repeat for all). - Press
w
to write changes and exit. - HINT: just keep doing
d
until you getno partitions remaining to be deleted
, then dow
and exit.
- Press
sudo parted /dev/sda mklabel gpt
to create a new GPT partition tablesudo parted -a optimal /dev/sda mkpart primary 0% 100%
creates a new parition (/dev/sda1
)- Format the partition (
/dev/sda1
) with your preferred file system (belowUSB_DRIVE
is just the assigned name, anything works):sudo mkfs.exfat -n USB_DRIVE /dev/sda1
for exFAT (Best for universal use); Works on Windows, Mac, Linuxsudo mkfs.ntfs -f -L USB_DRIVE /dev/sda1
for NTFS; Originally only for Windows, but now withntfs-3g
, also works on Linuxsudo mkfs.vfat -F 32 -n USB_DRIVE /dev/sda1
for FAT32; Works everywhere but has a 4GB file size limitsudo mkfs.ext4 -L USB_DRIVE /dev/sda1
for ext4; Linux-only
- Safely eject and remove.
Last active
January 31, 2025 00:30
-
-
Save sadanand1120/c7c7c0c247bd937c5a2201a4a4a623fc to your computer and use it in GitHub Desktop.
Steps to cleanly format a usb/ssd to any filesystem (ext4, ntfs, exfat, fat32) on Ubuntu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment