Linux dd命令 鄙视各种坑爹错误教程

 

 

  1. 备份MBR
    dd if=/dev/sda of=/opt/mbr.img bs=512 count=1 status=progress

     

  2. 恢复MBR
    dd if=/opt/mbr.img of=/dev/sdb status=progress

     

  3. 恢复bootloader
    dd if=/opt/mbr.img of=/dev/sdb bs=446 count=1 status=progress

     

  4. 恢复分区表
    dd if=/opt/mbr.img of=/dev/sdb bs=1 skip=446 seek=446 count=64 conv=notrunc

     

  5. skip是跳过ibs, 为if指定的文件

     

     发现跳过if文件两个字节,b文件被覆盖

    原文件b是有换行, 本人使用vim编辑,默认在每行末尾加 '\n'

     

     

     

     ASCII:

    10: LF '\n'
    13: CR '\r'

    Linux默认换行使用ASCII码 10, 即 '\n' (Windows使用 '\r\n')

     

  6. 如果不想覆盖目标文件,即 of指定的文件,需使用选项 conv=notrunc
    notrunc     do not truncate the output file

     

     

  7. 如果of文件很重要,不能被覆盖,则使用 conv=excl, dd默认会把目标文件覆盖,错误操作极其危险
    excl      fail if the output file already exists

     

     

  8. lcase     change upper case to lower case
    ucase    change lower case to upper case

     

     

  9. seek 操作 of 文件

     

  10.  

     conv=swab swap every pair of input bytes

     

     

     '\n' 也被交换了,按字节交换,不难理解

     

     notrunc不起作用

     

  11. conv=noerror 遇到错误继续
posted @ 2021-03-29 11:26  ascertain  阅读(1406)  评论(0编辑  收藏  举报