How to erase (or clean) a disk using Ubuntu

Sometimes you just want to clean a USB stick, SD Card or USB disk, and the only thing you’ve got is Ubuntu running on your system.

Well that is no problem, I’ll explain how simple it is…

Cleaning, erasing, wiping a USB stick, SD Card or USB disk can be done in just 3 simple steps:

  • Connect your disk
  • Identify the disk on your system
  • Clean / wipe your disk

Step 1 – Connect your disk
Connect your USB stick, SD Card or USB disk to your computer and mount your disk (you can do that by double clicking its icon on your desktop).

 

Step 2 – Identify the disk on your system
Open a terminal:

df -h

or, you can use

sudo fdisk -l

Identify your disk (you can look at it’s size or partition scheme)

 

Step 3 – Clean / wipe your disk
The following command is a simple example to understand the use of dd. Do not simply copy it and use it in a terminal !!! Remember the order of the options “input file (if=)“ and “output file (of=)” , DO NOT reverse them !!!

In my case (the example below), I identified my disk that I wanted to clean as /dev/sdg.
So my output file (or of) will be /dev/sdg this will result in of=/dev/sdg

Open a terminal:

sudo dd if=/dev/zero of=/dev/sdg

 

When the dd command is issued and ready, make sure all data is written to disk by typing the folowing in your terminal:

sync

 

Suggestions for improving this article are welcome, please let me know and drop me a line .