dd命令清除磁盘数据

1.先查看扇区数量和大小

root@ds3617xs:~# fdisk -l /dev/sda
Disk /dev/sda: 10 GiB, 10737418240 bytes, 20971520 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

2.用DD写入数据0或随机值

root@ds3617xs:~# dd if=/dev/urandom of=/dev/sda bs=512 count=20971520
20971520+0 records in
20971520+0 records out
10737418240 bytes (11 GB) copied, 1793.47 s, 6.0 MB/s
root@ds3617xs:~#

/dev/urandom随机很慢,/dev/zero快一点。

评论已关闭