0
In this tip we will see some commands that allow users to erase (blank) a disk partition or any other external disk via the terminal under Ubuntu / Linux. Before starting, you should know that we are not liable for any misuse of these commands, you have to execute them very carefully to avoid deleting accidentally your main system disk (the disk hosting the OS).

There are many commands for listing information about system installed hard drives and partitions, here are some of them:

cat /proc/partitions

sudo fdisk -l

sudo parted /dev/sda print

df -h

Getting Started

The first command for erasing a disk consists of using the dd Linux / Unix command. After deciding which partition or external disk you want to erase, open the terminal and run this command:

sudo dd if=/dev/urandom of=/dev/sdaX

Or, you can zero all disk data with this command:

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

    - Note: Replace sdaX with your own disk name (sda2, sda3, etc.).

The next command consists of using the shred command line tool. You can erase a disk with this command:

sudo shred --iterations=3 /dev/sdaX

That's it!

Post a Comment

 
Top