
On 2 September 2013 14:56, David Zuccaro <zuccaro.david@gmail.com> wrote:
What is the best way to wash a disk?
I tried this but it is taking forever. dd if=/dev/zero of=/dev/sdg1
Hi David There may be better ways to erase a disk, see for example https://ata.wiki.kernel.org/index.php/ATA_Secure_Erase but the topic of this message is just how you might be able to get dd to run faster. In my experience dd runs slowly in this situation due to using its outdated default blocksize of 512 bytes/block. It is easy to check this. Here is a demo of how to do it. I used of=/dev/null to test these commands here without writing to an actual disk. You could do that to, and then to get valid data you will need to change that to of=your_actual_device so that data gets written to a physical disk. (Something like the /dev/sdg1 you mentioned above, but be sure to confirm your desired target partition yourself carefully as it will be specific to your system, and you don't want to wash the wrong partition, as you probably know already!). First run dd in the background with the default blocksize, and save its PID in a shell variable: # dd if=/dev/zero of=/dev/null & pid=$! Then immediately (ie while the previous dd command is running in the background) run this # while true ; do kill -USR1 $pid ; sleep 10 ; done which will send the USR1 signal to the running dd process every 10 seconds, and it will display a progress report and average data transfer rate on the terminal, that will look something like this: 8957122+0 records in 8957121+0 records out 4586045952 bytes (4.6 GB) copied, 11.8519 s, 387 MB/s so you can see the data rate, here 387 MB/s for the meaningless demo exercise of writng zeros to /dev/null. Writing to an actual disk will have a more realistic slower MB/s as the zeros actually traverse your SATA bus to the physical disk. When you have seen enough of that, press control-C to abort the "while" command. And then to stop the dd background process, you must do this, otherwise it will run forever because /dev/null will never fill up: # kill -s TERM $pid That completes test #1. Next run a second test, with a bigger blocksize. In my experience larger than 4k gives no benefit so I use bs=4k. Again, for useful data you will need to change of=/dev/null to your actual disk, but you can do a practice run with of=/dev/null so long as you don't forget that the number you get is meaningless. You would start dd like this: # dd if=/dev/zero of=/dev/null bs=4k & pid=$! and the rest of the commands would be the same as above. Try this with your physical disk as a target, and compare the MB/s values to see if the larger block size gives any improvement.