How to Use the dd Command
The dd utility is an all-purpose tool for manipulating data. It is capable of copying, converting, compressing, extracting, and un archiving files. This utility can be employed in various scenarios, such as writing an image to an SD card or transferring files between devices.
dd if={{input_file}} of={{output_file}} bs={{block_size}} count={{count}} conv={{conversion_flags}}
- 指定输入文件或设备的位置:{{input_file}}
- 指定输出文件或设备的位置:{{output_file}}
- 配置读写块大小:{{block_size}}, 其中大小可表示为字节、千字节(K)、兆字节(M)或吉字节(G)。
- 指定要复制的块数:{{count}}, 若无此参数则会复制至输入文件之末尾。
- 配置转换标志:{{conversion_flags}}, 包含如同步写入(
fsync)、不截断输出文件(notrunc)及填充末尾空白(sync)等常见选项。
Here are a few examples of how to use the dd command:
To create a copy of a file:
dd if={{input_file}} of={{output_file}}
To create a copy of a file with a specific block size:
dd if={{input_file}} of={{output_file}} bs=4K
Generate copies of the file by defining its specific block dimensions and setting a fixed maximum count.
dd if={{input_file}} of={{output_file}} bs=1M count=10
To write an image to an SD card:
dd if={{image_file}} of=/dev/sdX bs=4M conv=fsync
Replace /dev/sdX with the actual device name of your SD card.
Please be mindful of using the dd command, since it may overwrite data if improperly employed. Carefully review the input files or devices and make sure you have the correct permissions before executing the command.
