How to format an SD card in Linux – PCWorld

March 5, 2017 Facebook Twitter LinkedIn Google+ Linux

As I was working on a tutorial about installing Raspbian on Raspberry Pi 3, I realized that I had to format the Micro SD card with fat32 partition. Another tutorial was in order!

Since different desktop environments use different tools to perform the same task, I resorted to one method that can be consistent across desktop environments: command line.

So here is how you format an SD card, USB drive or Micro SD card with fat32 file system from the command line in Linux.

1. Plug in your removable flash drive and run the ‘lsblk’ command to identify the device.

Here is the output of the ‘lsblk’ command on my system where ‘sdb’ is the removable flash storage:

sdb    8:16   1  3.8G  0 disk
├─sdb2   8:18   1  2.4M  0 part
└─sdb1   8:17   1  1.5G  0 part /media/sandisk

2. There are many command line tools to do the job, but lately I started using ‘parted’ more, so that’s the utility I will be using for this tutorial. Run the ‘parted’ command with the name of the block device that you want to format. In this case, it’s ‘sdb’. (Be careful with the name of the block device because you might end up formatting the wrong drive.)

3. Exchange ‘sdb’ with the name of your block device in the following command: