if:就是input file,也能夠是某設備文件
of:就是output file,也支持是設備文件
bs:規劃的一個block大小,若未指定則默認爲512byte
count:指定bs的數量
skip=n,指 if 後面的原文件跳過 n bytes 再開始讀取;
seek=n,指 of 後面的目標文件跳過 n bytes 再開始寫入;
oflag=direct,真實磁盤io ssh
~# time dd if=/dev/zero of=1.db bs=8k count=30000 30000+0 records in 30000+0 records out 245760000 bytes (246 MB) copied, 0.731931 s, 336 MB/s real 0m0.735s user 0m0.001s sys 0m0.151s
~# dd if=test.dbf bs=8k count=300000 of=/dev/null 30000+0 records in 30000+0 records out 245760000 bytes (246 MB) copied, 0.0342157 s, 7.2 GB/s
root@aikeru:~# fdisk -u -l /dev/sdb Disk /dev/sdb: 50 MiB, 52428800 bytes, 102400 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 Disklabel type: gpt Disk identifier: C94E55EA-A4D2-4E78-9D73-46CBAE7A03EF Device Start End Sectors Size Type /dev/sdb1 2048 32767 30720 15M EFI System /dev/sdb2 32768 94207 61440 30M Linux filesystem /dev/sdb3 94208 102366 8159 4M BIOS boot
備份爲文件ide
dd bs=512 count=102367 if=/dev/sdb of=./nas.img
dd bs=512 count=102367 if=/dev/sdb | ssh 192.168.2.2 "of=./nas.img"
partprobe for i in `seq 0 32`; do echo "- - -" > /sys/class/scsi_host/host$i/scan;done
dd bs=512 count=102367 if=./nas.img of=/dev/sdc
dd bs=512 count=102367 if=/dev/sdb of=/dev/sdc
dd bs=512 count=102367 if=/dev/sdb | ssh 192.168.2.2 "of=./dev/sdc"
dd if=/dev/zero of=/swapfile bs=1M count=4000 mkswap /swapfile chmod 600 /swapfile swapon /swapfile