1

The idea is to wipe all partitions with a terminal command. I found these:

 dd if=/dev/zero of=/dev/sda bs=1M count=8 && sync

and

dd if=/dev/zero of=/dev/sda bs=512 count=1 conv=notrunc

The sources are here and here.

Edit after comments:

What about this:

dd if=/dev/zero of=/dev/sdXXX bs=512 count=1

from here


I have this problem. The mbr is already lost I think. I just want a virgin hdd on which to create new partitions and to install new systems.

  • The second wipes out the MBR data, which sits on the initial 512 bytes, thus wiping out partition table records. The first writes in 8MB, for what reason, I don't know. – muru Feb 20 '15 at 13:34
  • This explains most of it rather nicely: http://unix.stackexchange.com/a/134313/10017 – Rinzwind Feb 20 '15 at 13:34
  • And BOTH seem fishy to me. "conv=notrunc" does NOT work on partitions only on files. "count=8" seems fishy. – Rinzwind Feb 20 '15 at 13:36
  • @Rinzwind It is 8MB (just tested on a temp file), notrunc shouldn't affect block devices one way or the other - but maybe useful for disk images. – muru Feb 20 '15 at 13:37
  • @Rinzwind - I have overlapping partitions and gparted sees all empty space (here), hard to fix and I want to reinstall windows etc anyway along ubuntu and more, I have saved my data now I just want to get a new empty hdd in which to install win7 then ubuntu. what is preferable? –  Feb 20 '15 at 13:45
  • If you really are specifying, say sda1 instead of sda (as indicated by sdXXX), only that partition will be affected. personally, I'd just stick with the 512-byte ones. – muru Feb 20 '15 at 13:50
  • Yeah the 512 is default on Ubuntu (and with dd). Stick with that. And listen to @muru :-D – Rinzwind Feb 20 '15 at 14:18
  • @Rinzwind - :) well, already did something else dd if=/dev/urandom of=/dev/sda bs=1M from @Mitch. it's already running: how long such a procedure should take on a 500 GB hdd? –  Feb 20 '15 at 14:24
  • 1
    @cipricus probably a while. Depends on the harddisk I would assume so a perfect answer I wont have. And yes that command is similar to what I tend to use ;) – Rinzwind Feb 20 '15 at 14:27

3 Answers3

2

The value provided for block size options is base 10. The default value for both input and output block sizes is 512 bytes. A larger block size results in more memory being used by dd, and is usually faster.

count=BLOCKS
      Copy BLOCKS `ibs'-byte blocks from the input file, instead of
      everything until the end of the file.
notrunc'  Do not truncate the output file.
sync'     Pad every input block to size of `ibs' with trailing zero bytes.

dd Manpage

Mitch
  • 107,631
  • 1
    I normally use dd if=/dev/urandom of=/dev/sda bs=1M – Mitch Feb 20 '15 at 13:51
  • I have overlapping partitions and gparted sees all empty space (here), hard to fix and I want to reinstall windows etc anyway along ubuntu and more, I have saved my data now I just want to get a new empty hdd in which to install win7 then ubuntu. what is preferable? )),. what is preferable? –  Feb 20 '15 at 13:53
  • You can add the count=sector_number to the above command. – Mitch Feb 20 '15 at 14:06
1

The first and second commands will overwrite the MBR of your device but they are different concerning GPT.

The first command writes 8MB of zeros and flushes the file system buffers. In case there is a GPT parts of the primary GPT are overwritten.

The second command writes 512B of zeros. In case there is a GPT the primary table will still be intact. (The conv=notrunc option does not make any difference because all data on the disk are lost anyways.)

Any secondary GPT at the end of the disc is left untouched by these commands.

The third command starts writing at the partition XX and does not remove the partition table.

This should erase your MBR or GPT.

sgdisk -Z /dev/sdX

After that you should be able to create a new MBR or GTP.

  • I have overlapping partitions and gparted sees all empty space (here), hard to fix and I want to reinstall windows etc anyway along ubuntu and more, I have saved my data now I just want to get a new empty hdd in which to install win7 then ubuntu. what is preferable? )),. what is preferable? –  Feb 20 '15 at 13:52
  • you know, gparted would not run, giving error that the partitions are overlapping. - isn't parted the program behind gparted? –  Feb 20 '15 at 14:14
  • I don`t think so, although the naming suggests that. –  Feb 20 '15 at 14:26
0

Booted in a live usb session and did

sudo dd if=/dev/urandom of=/dev/sda bs=1M

But that didn't seem o work as I wanted, as the light for the processor working was mostly off (or is it the hdd light?), while the cooler was very loud.

Then I read that the urandom command is very slow as it is really trying to produce really random numbers. I was not interested in wiping all the data for security, but just in clearing off all partitions (something was wrong with them), so I stopped the procedure and did:

sudo dd if=/dev/zero of=/dev/sda bs=1M

With this the cooler calmed down while that "working light" was there permanently.

And to see the progress of this, I opened a separate terminal window and did

watch -n5 'sudo kill -USR1 `pgrep ^dd`'

which every 5 secs reports the progress in the initial terminal window (source)

245423407104 bytes (245 GB) copied, 3430.82 s, 71.5 MB/s
234354+0 records in
234354+0 records out
245737979904 bytes (246 GB) copied, 3435.84 s, 71.5 MB/s
234655+0 records in
234655+0 records out
246053601280 bytes (246 GB) copied, 3440.88 s, 71.5 MB/s
234956+0 records in
234956+0 records out
246369222656 bytes (246 GB) copied, 3445.91 s, 71.5 MB/s

... it took 2 hours and thirty minutes for a 500GB HDD on a 4-year average laptop with 4GB ram.