今天在开发板上sd卡烧写uboot时遇到一个脚本;
p
a
r
t
i
t
i
o
n
1
−
partition1 -
partition1−partition4表示sd卡的四个盘符:
做了如下操作
umount $partition1 2> /dev/null
umount $partition2 2> /dev/null
umount $partition3 2> /dev/null
umount $partition4 2> /dev/null
卸载sd卡盘符后执行了dd命令:
echo "$2 fusing..."
dd iflag=dsync oflag=dsync if=../$2 of=$1 seek=1 && \
echo "$2 image has been fused successfully."
通过搜索和man 查看
dd命令的作用(功能)
主用功能是用于拷贝文件,也就是用指定大小的块去拷贝一个文件,并在拷贝的同时进行指定的转换(默认从标准输入拷贝到标准输出,这意味dd可以在管道中使用)。这个拷贝过程简单理解就是读取,转换并输出数据。
语 法:dd [bs=<字节数>][cbs=<字节数>][conv=<关键字>][count=<区块数>][ibs=<字节数>][if=<文件>][obs=<字节数>][of=<文件>][seek=<区块数>][skip=<区块数>][–help][–version]
补充说明:dd可从标准输入或文件读取数据,依指定的格式来转换数据,再输出到文件,设备或标准输出
man文档举例:
Sending a USR1 signal to a running `dd' process makes it print I/O statistics to standard error and then resume
copying.
$ dd if=/dev/zero of=/dev/null& pid=$!
$ kill -USR1 $pid; sleep 1; kill $pid
18335302+0 records in 18335302+0 records out 9387674624 bytes (9.4 GB) copied, 34.6279 seconds, 271 MB/s
发送0 到空设备中,查看发送的字节数;
linux执行如下
dd if=/dev/zero of=/dev/null& pid=$!
cj123@ubuntu:~$ kill -USR1 $pid; sleep 1; kill $pid
1912351+0 records in
1912351+0 records out
979123712 bytes (979 MB) copied, 2.1037 s, 465 MB/s
=================================================================================================
#dd确实实现了拷贝功能但是下面脚本含义是什么呢?
dd iflag=dsync oflag=dsync if=../$2 of=$1 seek=1 && \
echo "$2 image has been fused successfully."
ifag =dsync -------------------------------- 表示读取时使用同步io数据存储
oflag=dsync -------------------------------- 表示输出时使用同步io数据存储
if=…$2 -------------------------------- 是要读取的文件
of=$1 --------------------------------输出的文件
seek=1--------------------------------表示从第1个扇区开始读取,跳过第0个扇区