dd命令功能:文件複製
例:dd if=源文件 of=目標文件 bs=512(字節) count=2(數量)
MBR備份:
[root@localhost tmp]#dd if=/dev/hda1 of=/root/hda1_MBR.back bs=512 count=1 1+0 records in 1+0 records out 512 bytes (512 B) copied, 0.000122136 seconds, 4.2 MB/s
/dev/hda1 有可能是sda之類的,可以使用命令df 命令查看
[root@localhost ~]# df -h 文件系統 容量 已用 可用 已用% 掛載點 /dev/mapper/VolGroup00-LogVol00 7.2G 3.9G 2.9G 58% / /dev/hda1 99M 19M 76M 20% /boot tmpfs 125M 0 125M 0% /dev/shm
恢復MBR:
dd if=/root/hda1_MBR.back of=/dev/hda1 bs=512 count=1
磁盤填充,使用/dev/zero(類似一個冒泡器)
[root@localhost tmp]#dd if=/dev/zero of=/tmp/test bs=4k count=1024 #生成一個文件test,然後填充4K*1024的大小
測試
[root@localhost tmp]# dd if=/dev/zero of=/dev/null 7635912+0 records in 7635912+0 records out 3909586944 bytes (3.9 GB) copied, 7.92285 seconds, 493 MB/s