LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-03-2003, 11:12 PM   #1
zebra90210
Member
 
Registered: Aug 2003
Location: Chicago suburbs
Distribution: Kubuntu
Posts: 96

Rep: Reputation: 15
Question how to format the hard drive from a console window


Hi.
Can somebody tell me how to format the hard drive from a console window?
I mean - I'm trying to completely wipe it out with zeros (or ones) and I know I'd have to be in root to do it. I saw a thread on this subject, on this forum but I just couldn't find it anymore.
I'm using Mandrake 9.0
thanks
AL

Last edited by zebra90210; 09-03-2003 at 11:14 PM.
 
Old 09-03-2003, 11:27 PM   #2
MasterC
LQ Guru
 
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613

Rep: Reputation: 69
Sure, you'll have to be root (so BE VERY SURE AND VERY CAREFUL) and then:
dd if=/dev/zero of=/dev/hdx
Where /dev/hdx is the drive and partition you wanna wipe zeros to.

Then you can fomat to a linux filesystem with:
mke2fs -j /dev/hdx

After making partitions with fdisk or cfdisk.

Cool
 
Old 09-04-2003, 05:10 AM   #3
Cerbere
Member
 
Registered: Dec 2002
Location: California
Distribution: Slackware & LFS
Posts: 799

Rep: Reputation: 33
You can also use the 'shred' command. Check the man page, and in case you didn't notice when MasterC said it, be VERY, VERY CAREFUL. Think about it before you type the command, then type the command VERY CAREFULLY, then read the command (need I say VERY CAREFULLY), then think about it some more, then hit enter. Then say, 'Oh 5#|7!!!' when you realize that you didn't save a copy of that critical file that you really, really needed ;-)

Enjoy!
--- Cerbere
 
Old 09-04-2003, 05:39 PM   #4
zebra90210
Member
 
Registered: Aug 2003
Location: Chicago suburbs
Distribution: Kubuntu
Posts: 96

Original Poster
Rep: Reputation: 15
Thanks guys,
I know I'd have to VERY careful about executing that command but what I meant was - I was trying to format the ENTIRE DRIVE, including root and everything else.
I'm running a 3-disk system. I have three 20Gb hard drives in my PC, one for Win98, used only occasoinally, mostly for games and some stuff that only exists in the Windows (THANK YOU, MR. GATES). The other drive is my primary Linux system, Mandrake 9.0 and finally the third drive is my 'battlefield' where I can experiment with new stuff without any worries about lost data.
I use a Trios switch to select a drive I want to use.
So, coming back to my question - I wanted a quick, final, 'no questions asked just F%$*#N do it NOW!' format command.
Cerbere - how exactly do I execute the 'shred' command?
Forgive me for asking this question again, I'm not a Linux guru, just a user who knows the system, but is not exactly familiarized with the back door commands.

ttyl

AL
 
Old 09-04-2003, 07:25 PM   #5
Cerbere
Member
 
Registered: Dec 2002
Location: California
Distribution: Slackware & LFS
Posts: 799

Rep: Reputation: 33
Well, if you're keeping the hard drive, then I wouldn't worry about using the shred command. It's generally for wiping out data so that it can't be recovered, even with state of the art tools (think national security). If you're just looking to wipe out the drive so you can install a new OS or store new data, then just use the fdisk command.

For example:

fdisk /dev/hda

This will bring up an interactive program which is used to add, delete and set the properties of partitions. The first thing you'll want to do once you're in fdisk, is hit the 'm' key to show what options are available.

To list the partitions that are already on your drive, hit 'p'.

To delete a partition, hit 'd' then it will ask what partition you want to delete.

To add a partition, hit 'n', then it will ask if you want to add a primary or extended partition. Stick with primary as long as you can (you're allowed up to four). Then it will ask what number you want to assign to the partition (just count up from one).

To set the filesystem type for a partition, hit 't'. It will ask which partition you want to set, then which filesystem you want. Hit 'L' to see a list of the filesystem types (83 is the native Linux filesystem, 82 is swap, c is FAT32).

Finally, when you have the disk set up as you like, hit 'w' to save the changes you've made and exit fdisk. If you decide you don't want to save the changes, then hit 'q' to quit without saving.

After you've finished setting up the partitions with fdisk, you'll want to format the partition(s) for your filesystem(s) of choice. If you want a standard ext2 Linux filesystem, then use 'mke2fs /dev/hda'.

Now you'll have a nice fresh partition all ready to be mounted and used in Linux.

Enjoy!
--- Cerbere

p.s. If you do want to destroy all the data so no one will ever be able to read it (if you're giving away the disk, for example), then the usage of shred would be:

shred -n 1 -z /dev/hda

The '-n 1' means that it will make one pass of filling the drive with random gibberish. The -z means that it will then fill the drive with zeros.
 
Old 09-04-2003, 10:58 PM   #6
zebra90210
Member
 
Registered: Aug 2003
Location: Chicago suburbs
Distribution: Kubuntu
Posts: 96

Original Poster
Rep: Reputation: 15
Thanks Cerbere!

It's worked like a charm.
As the format progressed the things started disappearing from the desktop,
I was clicking on the icons and they would disappear or freeze.
Finally I couldn't even move a mouse.
Of course, it was all done on my 'battle-field' drive. LOL

ttyl

AL

 
Old 09-05-2003, 04:25 AM   #7
Cerbere
Member
 
Registered: Dec 2002
Location: California
Distribution: Slackware & LFS
Posts: 799

Rep: Reputation: 33
Wow, it never occured to me that you'd be formatting the drive that you were running on! That 'disappearing icon' business is easily the weirdest thing I've heard in at least two hours ;-)

I should have told you to work from a rescue disk. My personal favorite is Tom's root/boot:

http://www.toms.net/rb/

It might be a good idea to get this, then repeat the process. Since you were erasing data from the drive that the computer was using to run the format, it almost certainly didn't complete.

Sorry, I didn't mention that before.

Enjoy!
--- Cerbere

Last edited by Cerbere; 09-05-2003 at 04:26 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
format a hard drive (/dev/hda1) in Reiser fs format Linh Linux - General 7 06-17-2009 06:30 AM
format hard drive mav69_1999 Linux - Newbie 5 07-08-2004 04:53 PM
Can't format hard drive aisphording Linux - Hardware 5 06-14-2004 04:02 PM
I can't format my hard drive! help! justin9 Linux - Newbie 9 07-09-2003 07:42 AM
How do I format a hard disk under console? lectraplayer Linux - Newbie 21 04-05-2003 11:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:55 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