I am trying to use dd to wipe a usb drive using Cygwin on Windows. What should I use for the of argument?

dd if=/dev/null of=?
  • 1
    don't forget to use the sync command when your done to flush any OS buffers out to disk. – user3338098 Mar 30 '16 at 15:47

It should be noted that writing /dev/null to a block device will do nothing. Block device meaning /dev/sdc not /dev/sdc1 sdc1 refers to the first partition, not the entire device.

You want to use:




Cygwin uses following device mapping for harddisk-like devices:

POSIX device name     Internal NT device name

/dev/sda          \device\harddisk0\partition0  (whole disk)
/dev/sda1         \device\harddisk0\partition1  (first partition)
/dev/sda15        \device\harddisk0\partition15 (fifteenth partition)

/dev/sdb          \device\harddisk1\partition0
/dev/sdb1         \device\harddisk1\partition1

[up to]

/dev/sddx         \device\harddisk127\partition0
/dev/sddx1        \device\harddisk127\partition1
/dev/sddx15       \device\harddisk127\partition15

You can see NT device names in Disk Management in Management Console.

Also use /dev/zero instead of /dev/null as input.

  • 3
    cat /proc/partitions will give you Win-Drive <--> /dev/* mapping. – ilyaigpetrov Sep 19 '15 at 13:19

Assuming Cygwin has the same core commands as a Unix/Linux install, you can us df—which tells you how much free space (disk free) is available on your devices but also gives you nice filesystem data—you can use for situations like this.

For example, here is the output of df from my Mac OS X terminal:

Filesystem    512-blocks       Used  Available Capacity   iused     ifree %iused  Mounted on
/dev/disk0s2   975093952  135358704  839223248    14%  16983836 104902906   14%   /
devfs                381        381          0   100%       660         0  100%   /dev
map -hosts             0          0          0   100%         0         0  100%   /net
map auto_home          0          0          0   100%         0         0  100%   /home
/dev/disk2s2  3906357344 2097411968 1808945376    54% 262176494 226118172   54%   /Volumes/Moe
/dev/disk1s2   235154168  118616008  116538160    51%  14826999  14567270   50%   /Volumes/Larry
/dev/disk1s3  3670941032 2100018304 1570922728    58% 262502286 196365341   57%   /Volumes/Curly

Note the last three entries that show mount points as well as the file system you are connected to. So let’s say I want to erase /Volumes/Curly to replace him at some point with data from a place called /Volumes/Shemp, I would erase all of the data on the drive and then run this dd command:

dd if=/dev/zero of=/dev/disk1s3/wipe_file.txt

And just so you understand what that command does, if indicates what the input file is (get it, if) and of indicates the output file (similarly… get it, of) and that’s that. And I am using /dev/zero instead of /dev/null since /dev/null is an input destination for data you don’t need while /dev/zero is an output source for a stream of 0 characters.

So when you run that dd command the contents of /dev/zero (which is just an endless stream of 0 characters) will be copied to wipe_file.txt on /dev/disk1s3/. Meaning a new file named wipe_file.txt will be created that grows & grows until it fills the full capacity of /dev/disk1s3/.

But depending on how paranoid you are about data, you can also change if to be random like this:

dd if=/dev/random of=/dev/disk1s3/wipe_file.txt

Using zero will explicitly just fill wipe_file.txt with 0 characters while random will fill the file with random characters. Note that filling a file with random data will require more computing power than just filling the file with nothing, so the random method will take longer. But if you are worried about prying eyes recovering data that might be the best thing to assuredly destroy already erased data on a drive.

  • 1
    This is a brilliant answer, seriously informative. – Hashim Aziz Aug 14 '17 at 2:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.