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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM