- 备份MBR
dd if=/dev/sda of=/opt/mbr.img bs=512 count=1 status=progress
- 恢复MBR
dd if=/opt/mbr.img of=/dev/sdb status=progress
- 恢复bootloader
dd if=/opt/mbr.img of=/dev/sdb bs=446 count=1 status=progress
- 恢复分区表
dd if=/opt/mbr.img of=/dev/sdb bs=1 skip=446 seek=446 count=64 conv=notrunc
- skip是跳过ibs, 为if指定的文件
发现跳过if文件两个字节,b文件被覆盖
原文件b是有换行, 本人使用vim编辑,默认在每行末尾加 '\n'
ASCII:
10: LF '\n'
13: CR '\r'Linux默认换行使用ASCII码 10, 即 '\n' (Windows使用 '\r\n')
- 如果不想覆盖目标文件,即 of指定的文件,需使用选项 conv=notrunc
notrunc do not truncate the output file
- 如果of文件很重要,不能被覆盖,则使用 conv=excl, dd默认会把目标文件覆盖,错误操作极其危险
excl fail if the output file already exists
-
lcase change upper case to lower case ucase change lower case to upper case
- seek 操作 of 文件
-
conv=swab swap every pair of input bytes
'\n' 也被交换了,按字节交换,不难理解
notrunc不起作用
- conv=noerror 遇到错误继续