LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-22-2017, 04:48 PM   #1
cousinlucky
Member
 
Registered: Nov 2005
Location: Staten Island N.Y.
Distribution: Antix 16 and PCLinuxOS Mate
Posts: 303

Rep: Reputation: 515Reputation: 515Reputation: 515Reputation: 515Reputation: 515Reputation: 515
Terminal commands to erase partitions and hard drives please!!


Could any LQ members please provide me with the terminal commands that will completely erase everything within a hard drive partition and completely erase everything on a entire hard drive?? Thanks!!
 
Old 03-22-2017, 04:58 PM   #2
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
dd if=/dev/zero of=/dev/devicename

For example, devicename = sda1 erases the partition sda1, devicename = sda erases the disk sda.

You could also use if=/dev/random if you prefer, but I'm not sure it would make much difference.

The command requires root privileges. Use with caution.
 
Old 03-22-2017, 05:22 PM   #3
cousinlucky
Member
 
Registered: Nov 2005
Location: Staten Island N.Y.
Distribution: Antix 16 and PCLinuxOS Mate
Posts: 303

Original Poster
Rep: Reputation: 515Reputation: 515Reputation: 515Reputation: 515Reputation: 515Reputation: 515
Thanks Hydrurga!!
 
Old 03-22-2017, 07:18 PM   #4
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,993

Rep: Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628
You would normally use that on a non-boot drive. If a boot drive then I'd boot from some live media.

Don't forget to triple check that your /dev/name is the one you want. Trust me on that.
 
Old 03-23-2017, 04:44 AM   #5
cousinlucky
Member
 
Registered: Nov 2005
Location: Staten Island N.Y.
Distribution: Antix 16 and PCLinuxOS Mate
Posts: 303

Original Poster
Rep: Reputation: 515Reputation: 515Reputation: 515Reputation: 515Reputation: 515Reputation: 515
Is there a terminal command that will reveal the exact designation of the hard drive inside of my computer?
 
Old 03-23-2017, 05:46 AM   #6
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Quote:
Originally Posted by cousinlucky View Post
Is there a terminal command that will reveal the exact designation of the hard drive inside of my computer?
lsblk -f should give you what you need.

Can I ask what you're trying to do here? If you're trying to erase the whole hard disk in your computer, you need to boot from another medium. In that case, you could also look at something like Darik's Boot and Nuke (https://dban.org/).
 
Old 03-23-2017, 05:59 AM   #7
jamiebbbb
Member
 
Registered: Mar 2017
Location: Victoria, Australia
Distribution: Debian Wheezy
Posts: 34

Rep: Reputation: Disabled
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


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

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
 
Old 03-23-2017, 10:28 AM   #8
cousinlucky
Member
 
Registered: Nov 2005
Location: Staten Island N.Y.
Distribution: Antix 16 and PCLinuxOS Mate
Posts: 303

Original Poster
Rep: Reputation: 515Reputation: 515Reputation: 515Reputation: 515Reputation: 515Reputation: 515
Thank You All Very Much!! I messed up one of my two old computers and I am trying to get the mistakes out of the hard drive!!
 
Old 03-23-2017, 01:45 PM   #9
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Quote:
Originally Posted by cousinlucky View Post
Thank You All Very Much!! I messed up one of my two old computers and I am trying to get the mistakes out of the hard drive!!
In that case you shouldn't really need to erase a partition or disk, just initialise a filesystem in it, either by using a bootable tool such as GParted Live or by simply installing another distro over an older one.

What mistakes do you have?
 
Old 03-23-2017, 03:34 PM   #10
cousinlucky
Member
 
Registered: Nov 2005
Location: Staten Island N.Y.
Distribution: Antix 16 and PCLinuxOS Mate
Posts: 303

Original Poster
Rep: Reputation: 515Reputation: 515Reputation: 515Reputation: 515Reputation: 515Reputation: 515
I bought the repository discs for an old PCLinuxOS system and, as usual, I messed the install up. There were others, much more experienced Linux users, who stated the discs also messed up their computers!! At any rate I have never been able to get rid of all of that junk. I hope to finally get it all out now!!
 
Old 03-23-2017, 03:38 PM   #11
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Ok. What did lsblk -f give you?
 
Old 03-23-2017, 04:05 PM   #12
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,993

Rep: Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628Reputation: 3628
Side notes.
Every once in a while you may have to nuke or dd it or wipe a drive. Many newer installer programs refuse to destroy what they think to be a working linux.
 
Old 03-23-2017, 07:37 PM   #13
cousinlucky
Member
 
Registered: Nov 2005
Location: Staten Island N.Y.
Distribution: Antix 16 and PCLinuxOS Mate
Posts: 303

Original Poster
Rep: Reputation: 515Reputation: 515Reputation: 515Reputation: 515Reputation: 515Reputation: 515
Quote:
Originally Posted by hydrurga View Post
Ok. What did lsblk -f give you?
It gave me sda.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to list All Mounted Drives and their Partitions from the Terminal in opensuse sayhello_to_the_world Linux - Newbie 6 12-17-2013 04:10 AM
Erase hard drives jefro General 16 11-25-2012 11:45 AM
Partitions with 2 Hard Drives gblasius Linux - Newbie 6 09-27-2005 09:40 AM
How to erase your hard disk with Linux partitions on it 357mag Mandriva 10 03-16-2005 08:53 AM
new partitions on new hard drives Sticktendo Linux - Newbie 18 01-01-2005 04:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration