2021-07-06 10:04:58 +08:00
|
|
|
|
# DD 命令说明
|
2018-11-27 13:35:53 +08:00
|
|
|
|
|
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 之间可以用逗号分割,含义如下表。
|
|
|
|
|
|
2020-12-22 11:02:29 +08:00
|
|
|
|
| Flag | Description |
|
|
|
|
|
|-------------|-------------------------------------------------------------------|
|
|
|
|
|
| append | append mode (makes sense only for output; conv=notrunc suggested) |
|
|
|
|
|
| direct | use direct I/O for data |
|
|
|
|
|
| directory | fail unless a directory |
|
|
|
|
|
| dsync | use synchronized I/O for data |
|
|
|
|
|
| sync | likewise, but also for metadata |
|
|
|
|
|
| fullblock | accumulate full blocks of input (iflag only) |
|
|
|
|
|
| nonblock | use non-blocking I/O |
|
|
|
|
|
| noatime | do not update access time |
|
|
|
|
|
| nocache | Request to drop cache. See also oflag=sync |
|
|
|
|
|
| noctty | do not assign controlling terminal from file |
|
|
|
|
|
| nofollow | do not follow symlinks |
|
|
|
|
|
| count_bytes | treat 'count=N' as a byte count (iflag only) |
|
|
|
|
|
| skip_bytes | treat 'skip=N' as a byte count (iflag only) |
|
|
|
|
|
| seek_bytes | treat 'seek=N' as a byte count (oflag only) |
|