2018-11-27 13:35:53 +08:00
|
|
|
|
# DD 命令的使用
|
|
|
|
|
|
2020-12-22 10:43:59 +08:00
|
|
|
|
## 1.一般使用
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
# 不固定长度,读到文件结尾自动停止
|
2019-10-15 10:47:10 +08:00
|
|
|
|
dd if=\<in file name\> of=/dev/\<out file name\> bs=4M status=progress
|
2020-12-22 10:43:59 +08:00
|
|
|
|
# 指定长度(4Mx1024=4G)
|
|
|
|
|
dd if=\<in file name\> of=/dev/\<out file name\> bs=4M count=1024 status=progress
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 2.指定 Flag
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
# iflag 指定 input flag
|
|
|
|
|
# iflag 指定 output flag
|
|
|
|
|
dd iflag=direct,nonblock if=\<in file name\> oflag=direct,nonblock of=/dev/\<out file name\> bs=4M status=progress
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
多个 Flag 之间可以用逗号分割,含义如下表。
|
|
|
|
|
|
|
|
|
|
| flags | Description |
|
|
|
|
|
|-----------|----------------------------------------------|
|
|
|
|
|
| direct | 读写数据采用直接 IO 方式 |
|
|
|
|
|
| directory | 读写失败除非是 directory |
|
|
|
|
|
| dsync | 读写数据采用同步 IO |
|
|
|
|
|
| sync | 同上,但是针对元数据 |
|
|
|
|
|
| fullblock | accumulate full blocks of input |
|
|
|
|
|
| nonblock | 读写数据采用非阻塞 IO 方式 |
|
|
|
|
|
| noatime | 读写数据不更新访问时间 |
|
|
|
|
|
| noctty | do not assign controlling terminal from file |
|
|
|
|
|
| nofollow | do not follow symlinks |
|