Как мне стереть USB-накопитель с помощью dd на cygwin в Windows?

4302
user674669

Я пытаюсь использовать, ddчтобы стереть USB-накопитель с помощью Cygwin на Windows. Что я должен использовать для ofаргумента?

dd if=/dev/null of=? 
1
не забудьте использовать команду `sync`, когда все готово для сброса любых буферов ОС на диск. user3338098 8 лет назад 0

3 ответа на вопрос

3
Cheeto

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:

/dev/zero 

Or:

/dev/urandom 
2
JakeGould

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.

Это блестящий ответ, серьезно информативный. Hashim 7 лет назад 1
1
kolen

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.

`cat / proc / partitions` даст вам отображение` Win-Drive <-> / dev / * `. TheNamelessOne 9 лет назад 1