3

I am new to Linux. Can any one give me a suggestion on how to format hard disk. That is I need to clean the data, data should not be recoverable again. It should be permanently deleted.

Chindraba
  • 1,963
  • 1
  • 11
  • 25

3 Answers3

5
dd if=/dev/zero of=/dev/<target device>

this will write an endless stream of zeros to your device.This will make the recovery impossible. It's somewhat slow though.

You can also try dcfldd, but you have to install it first, and than run:

dcfldd if=/dev/zero of=/dev/<target device>

Some people claim it's faster than dd.

A Note: I am talking about low-level-format here, please be sure it's exactly what you need in your case.

hovanessyan
  • 509
  • 4
  • 9
  • Thanx for a suggestion, i will explain u a scenario i have taken a system for rent to my firm i am giving back to them, so i need to format everything i will give them a plain hard disk the data should be totally wiped out –  Jul 09 '12 at 08:23
  • Well, than simple format should be enough I think. I doubt they will start recovering data. Though if you want to be sure no recovery is possible, the above will do the trick. – hovanessyan Jul 09 '12 at 08:29
  • 1
    Keep in mind it would be best, if you can plug the hard disk you want to format, to another computer or use a Linux Live CD to execute the commands. – hovanessyan Jul 09 '12 at 08:32
  • dcfldd actually uses dd and it's faster, but requires you to install it. A side from that, they are equivalent in the result. – hovanessyan Jul 09 '12 at 08:42
  • Instead of `/dev/zero` (or in addition two, for a subsequent run) you could also use `/dev/random` -- as the name suggests, instead of zeros this delivers random values. Some tools (e.g. shred AFAIK) use these two in conjunction (subsequent runs) to ensure complete data destruction. For above example, this would look like `dd if=/dev/random of=/dev/`. – Izzy Jul 09 '12 at 13:01
  • dcfldd is a seperate build with patches, actually as opposed to 'using' dd - there's an answer [to this question](http://superuser.com/questions/355310/dd-rescue-vs-dcfldd-vs-dd) where i talk about the difference between three 'common' flavours of dd – Journeyman Geek Jul 09 '12 at 14:39
5

Two options come to mind.

If its a partition, use the shred command shred -n 2 -z /dev/sdxX should do the trick for a partition. -n 2 will do 2 overwrites with random data, and -z will finish it off by overwriting it with zeros. Slightly overkill, and will also works with files

If its a drive run dban - this should result in the contents of the entire drive being irrecoverably overwritten using a algorithm of your choice.

That said, even zeroing out SHOULD prevent recovery on modern hard drives, but both of these are simple, direct ways of getting data erased.

Journeyman Geek
  • 127,463
  • 52
  • 260
  • 430
0

If you delete the data, and then write new data to the same place in hard disc the previous is impossible to recover. That's because only the beginning of file is deleted. I think it works for all OS and computers.