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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
09-03-2003, 11:12 PM
|
#1
|
Member
Registered: Aug 2003
Location: Chicago suburbs
Distribution: Kubuntu
Posts: 96
Rep:
|
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.
|
|
|
09-03-2003, 11:27 PM
|
#2
|
LQ Guru
Registered: Mar 2002
Location: Salt Lake City, UT - USA
Distribution: Gentoo ; LFS ; Kubuntu ; CentOS ; Raspbian
Posts: 12,613
Rep:
|
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
|
|
|
09-04-2003, 05:10 AM
|
#3
|
Member
Registered: Dec 2002
Location: California
Distribution: Slackware & LFS
Posts: 799
Rep:
|
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
|
|
|
09-04-2003, 05:39 PM
|
#4
|
Member
Registered: Aug 2003
Location: Chicago suburbs
Distribution: Kubuntu
Posts: 96
Original Poster
Rep:
|
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
|
|
|
09-04-2003, 07:25 PM
|
#5
|
Member
Registered: Dec 2002
Location: California
Distribution: Slackware & LFS
Posts: 799
Rep:
|
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.
|
|
|
09-04-2003, 10:58 PM
|
#6
|
Member
Registered: Aug 2003
Location: Chicago suburbs
Distribution: Kubuntu
Posts: 96
Original Poster
Rep:
|
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

|
|
|
09-05-2003, 04:25 AM
|
#7
|
Member
Registered: Dec 2002
Location: California
Distribution: Slackware & LFS
Posts: 799
Rep:
|
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.
|
|
|
All times are GMT -5. The time now is 10:55 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|