- 備份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 遇到錯誤繼續