linux - How to wipe one sector with DD?
2014-04
What is the dd
command in Linux for securely wiping sector 62 of a hard drive. This sector lies in track zero, begins at offset 31744 and is 512 bytes long.
I'd like to know how to wipe it over 1000 times with ultra random data and then wipe over it say 100 times with zeros.
My computer has only one hard drive and I'll be doing this from an Ubuntu live CD using the terminal.
run the following command however times you want: warning: this has its share of risk of damaging your valuable files & data. don't run unless you understand it...
$ sudo su [enter] # dd if=/dev/random of=/dev/sda bs=512 count=1 seek=62 [enter] # dd if=/dev/zero of=/dev/sda bs=512 count=1 seek=62 [enter]
note that
repeat [times] [command]
would repeat the command [command] for [times].
EDIT1:
substitute urandom with random if you want more randomness
substitute random with urandom if you want more speed
EDIT2:
add the zeroing back
I'm trying to figure out the optimal size for a large copy from my hard drive using dd. I'm trying to figure out what the best blocksize to use it, which I would assume is the hardware block size for that drive.
Linux exposes the physical sector size in files /sys/block/sdX/queue/physical_block_size
. Although, to get the best performance you should probably do a little testing with different sizes and meassure. I could not find a clear answer in that using exactly the physical block size would get the optimal result (although I assume it cannot be a bad choice).
The lsblk command is great for this:
lsblk -o NAME,PHY-SeC
The results:
NAME PHY-SEC
sda 512
├─sda1 512
├─sda2 512
└─sda5 512
$ sudo hdparm -I /dev/sda | grep -i physical
Physical Sector size: 4096 bytes
http://nxadm.wordpress.com/2010/04/30/4096-physical-block-size-drives/
Each disk transfer generates an interrupt that processor must handle. Typical 50Mb/s disk will want to generate 100000 of them each second at 512b block size Normal processor would handle 10s of thousands of those, thus bigger (2^x) block size would be more handy (4k as default FS block size in most systems up to 64k ISA DMA size) would be more practical...