Reformatting USB
This is a quick and concise guide on reformatting to ext4.
In this post, you will learn how to quickly reformat USB, deleting all former files and making it ready for usage on Linux.
Reformatting a USB Drive to ext4 on Linux
Warning: Before proceeding, make sure you have backed up any important files on the USB drive, as this process will delete all data.
Step 1: Unmount the USB Drive
It’s essential to unmount it before reformating. You can do this by running the following command:
sudo umount <path/to/usb>
You can find the current mount point on you’re file system by running the following command:
lsblk -f
| Output command:
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
sda vfat FAT16 4D7E-AA1B 945.4M 2% /home/external_usb
nvme0n1
├─nvme0n1p1 ext4 1.0 ab1f17cd-c678-492c-aa06-804167a313c3 63.7G 1% /
├─nvme0n1p2 vfat FAT32 6007-A7E9 7.4G 0% /boot/efi
├─nvme0n1p3 ext4 1.0 9aa9ed83-2856-415e-87db-4a9d37ae21af 28.7G 32% /var
├─nvme0n1p4 ext4 1.0 5936b6b3-40e9-4bdd-a80c-49ae542290be 8.6G 0% /tmp
├─nvme0n1p5 swap 1 31eb519b-3c67-4528-ba36-e6657e9b75c8 [SWAP]
├─nvme0n1p6 ext4 1.0 49afc867-054f-47d0-aa0f-d3954bf4f43b 53.6G 36% /home
├─nvme0n1p7 ext4 1.0 e74b44a5-f583-42e2-bb48-7ae339c2c5c3 82.1G 5% /home/coding
├─nvme0n1p8 ext4 1.0 94265f42-44ee-4508-9dfa-2e7cc1e74729 38.7G 10% /home/software
├─nvme0n1p9 ext4 1.0 ff223ba2-af99-4794-97c8-06ffcbfe8a3b 42.7G 1% /home/custom_configs
├─nvme0n1p10 ext4 1.0 b4d509d4-6f57-451d-a598-a61dda635728 12.9G 0% /home/contact_notme
├─nvme0n1p11 ext4 1.0 60000054-79f8-4bae-8899-53a9720ac042 14.5G 15% /opt
├─nvme0n1p12 ext4 1.0 e9d06757-056d-48d8-aa5e-1e523d04e959 8.7G 47% /usr
├─nvme0n1p13 ext4 1.0 1da4f1d3-f366-4614-b907-0d639f9555cf 945.4M 2% /home/external_usb
└─nvme0n1p14 ext4 1.0 544d9a00-f941-4fbe-ab62-eab0353c7f02 1.7G 0% /home/external_ssd
For me the usb is currently mounted on; /home/external_usb
, altough for you the USB will probably be mounted on; /media/username/usbname
.
If you are unsure about you’re USB mount path, run the lsblk -f
command once before plugging USB in, and then crossreference after plugging USB in.
Since I have the USB mounted on; /home/external_usb
, ill unmount is like so;
sudo umount /home/external_usb
Step 2: Check the Device Name
After you have umounted the USB, you will most likely see the USB within you’re file system when running lsblk -f
but now it should be mounted to nothing:
| Output command
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
sda vfat FAT16 4D7E-AA1B
( It could be you’re USB has a different name like sdX1
, sdb1
or something )
Step 3: Reformat the USB Drive to ext4
In Linux, the /dev
directory is a special directory that contains device files, which are used to interact with hardware devices. The /dev
directory is a virtual file system that provides a way for the operating system to communicate with hardware devices.
Now, you can reformat the USB drive to ext4, this is the linux file system using the mkfs.ext4
command:
Again, replace /dev/sda
with the actual device name of your USB drive.
sudo mkfs.ext4 /dev/<usbinterface>>
For me it will be the following command:
sudo mkfs.ext4 /dev/sda
| Output command
mke2fs 1.47.0 (5-Feb-2023)
/dev/sda contains a vfat file system
Proceed anyway? (y,N) y
Creating filesystem with 247296 4k blocks and 61824 inodes
Filesystem UUID: 2968b05e-b773-479c-aabc-1e3c6fa58311
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
Step 4: Create a New File System Label (Optional)
If you want to assign a label to your USB drive, you can use the e2label
command:
Replace myusb
with your desired label name.
sudo e2label /dev/sda myusb
| _Run lsblk -f
to confirm label applied:
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
sda ext4 1.0 financeRecords 2968b05e-b773-479c-aabc-1e3c6fa58311
Step 5: Mount the USB Drive
Finally, you can mount the reformatted USB drive:
Replace /mnt
with your desired mount point.
sudo mount /dev/usbname /mnt
For me it will be the following command:
sudo mount /dev/sda /home/external_usb
That’s it! Your USB drive should now be reformatted to ext4 and ready for use on Linux.