How do you wipe unpartitioned disk space?

I can wipe a single partition:

dd if="/dev/zero" of="/dev/sdaX"

or I can wipe the whole disk along with all partitions on it:

dd if="/dev/zero" of="/dev/sda"

But what if I wanted to keep my current partitions and wipe any data on the unpartitioned space which may have been used by a previous partition scheme?


Solution 1:

There is an easy way and a hard way.

The hard way is to identify the beginning and end of your unpartitioned space, and do

dd if=/dev/zero of=/dev/sda seek=10000 obs=512 count=20000 bs=512

This is saying, skip the first 10000x512 bytes and then write zeros for 20000x512 bytes.

You need to make sure you get your sector math correct to ensure you are targetting the right portion of the disk, otherwise there is risk of overwriting real data. Which leads me to the easy way:

  1. Create a partition in the unpartitioned space
  2. dd as normal for a partition
  3. Delete the partition