Format USB flash drive using dd

Published on February 19, 2020

This is a tutorial on how to format a USB flash drive using the dd command.

USB drive

You can format a flash drive using a number of GUI tools - such as Disk Utility. Unfortunately, this does not work properly all the time. If you have a flash drive which has some kind of Linux installed on it and it is split into various partitions, Disk Utility may not detect all partitions. In such scenarios, it's best to use the command line tool called dd.

Table of Contents

Linux

First, find the flash drive mounted in the system:

fdisk -l

Assume the flash drive is mounted on /dev/sdb. Now, unmount the device:

umount /dev/sdb

Format the flash drive:

sudo dd if=/dev/zero of=/dev/sdb bs=1m

After several minutes, the formatting will be completed.

macOS

First, find the device:

diskutil list

Assume the flash drive is mounted on /dev/disk2. Now, unmount it:

diskutil unmountDisk /dev/disk2

Format the flash drive (note the rdisk2 instead of disk2):

sudo dd if=/dev/zero of=/dev/rdisk2 bs=1m

After several minutes, the formatting will be completed.

urandom instead of zero

You may also use this command to fill the filesystem with random numbers instead of 0s.

sudo dd if=/dev/urandom of=/dev/rdisk2 bs=1m

Related Posts

If you have any questions, please contact me at arulbOsutkNiqlzziyties@gNqmaizl.bkcom. You can also post questions in our Facebook group. Thank you.

Disclaimer: Our website is supported by our users. We sometimes earn affiliate links when you click through the affiliate links on our website.

Published on February 19, 2020