parasurv's webspace@writer13 ~ $

Format SD card or USB from terminal

Date: 2024-04-22

Made this note, after Gotbletu's video: mkfs - Format USB Stick / Hard Drive - Linux CLI.

Sometimes you need a quick way to format an USB stick or memory card to use. Luckily we have a terminal utility called mkfs, which does the job really well.

Start your favorite terminal and first we are going to search for the device we want to format:

$ sudo fdisk -l

Depending on your machine you will get a short or long list of devices. You have to be very careful, which device you choose, since we are going to format it, and loose the data that was on it.

After identifying the device, we will use the mkfs command to format it. But before formating, you have to unmount the drive. If you didn't unmount it will tell you to do it.

$ sudo mkfs.type -n "Label" /dev/something

Yes, that's a dot after mkfs. If you are not familiar with the different options, you can use Tab after the dot for completion. Next is the Label, which is probably better to start with a Capital letter. This label which will see in a file manager, a good identifier. Then comes the device location itself. Again, please be careful, because you can easily format your main drive or partition with this.

Here is an example, I have recently used:

$ sudo mkfs.fat -n "Reader" /dev/sdd

This is an SD card, I formatted to fat, named it Reader, because I will use this in a e-book reader.


This website doesn't track you. I don't use any javascript or other scripts. I don't store any information about the visitors. It's just pure old fashioned HTML and some CSS. Hosted on Neocities and created with Emacs.