{"id":5611,"date":"2022-06-13T10:47:40","date_gmt":"2022-06-13T02:47:40","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=5611"},"modified":"2022-06-14T05:15:38","modified_gmt":"2022-06-13T21:15:38","slug":"6-examples-to-backup-linux-using-dd-command","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/6-examples-to-backup-linux-using-dd-command.html","title":{"rendered":"6\u4e2a\u5173\u4e8edd\u547d\u4ee4\u5907\u4efdLinux\u7cfb\u7edf\u7684\u4f8b\u5b50"},"content":{"rendered":"
\u672c\u6587\u7531lrxjmw.cn\u56e2\u961f\u6210\u5458\u70e8\u5b50<\/span>\u6574\u7406\u53d1\u5e03\uff0c\u70b9\u6b64\u67e5\u770b\u6700\u65b0Linux\u8d44\u8baf<\/a><\/span><\/strong>\u3002<\/p>\n<\/div>\n \u6570\u636e\u4e22\u5931\u5e26\u6765\u7684\u635f\u5931\u662f\u76f8\u5f53\u6602\u8d35\u7684\u3002\u5173\u952e\u6570\u636e\u7684\u4e22\u5931\u4f1a\u5bf9\u5404\u79cd\u89c4\u6a21\u7684\u4f01\u4e1a\u5e26\u6765\u5f71\u54cd\u3002\u6709\u51e0\u79cd\u65b9\u6cd5\u6765\u5907\u4efdLinux\u7cfb\u7edf\uff0c\u5305\u62ecrsync\u7684\u548crsnapshot\u7b49\u3002\u672c\u6587\u63d0\u4f9b\u6709\u5173\u4f7f\u7528dd\u547d\u4ee4\u5907\u4efdLinux\u7cfb\u7edf\u76846\u4e2a\u5b9e\u4f8b\u3002 dd\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684UNIX\u5de5\u5177\uff0c\u7531Linux\u5185\u6838\u7684makefile\u8fdb\u884c\u5f15\u5bfc\u6620\u50cf\uff0c\u5b83\u4e5f\u53ef\u4ee5\u7528\u6765\u590d\u5236\u6570\u636e\u3002<\/p>\n \u4f8b 1\uff1a\u5907\u4efd\u6574\u4e2a\u786c\u76d8<\/strong> \u5728\u5907\u4efd\u6574\u4e2a\u786c\u76d8\u65f6\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u52a0\u5165sync\u53c2\u6570\u6765\u540c\u6b65I\/O\u3002 \u5982\u4e0b\u6240\u793a\uff1a<\/p>\n \u4f8b 2\uff1a\u521b\u5efa\u786c\u76d8\u7684\u6620\u50cf<\/strong> \u4f8b 3\uff1a\u6062\u590d\u786c\u76d8\u6620\u50cf\u6587\u4ef6\u6062\u590d\u6570\u636e<\/strong> Sdadisk.img\u6587\u4ef6\u662f\/dev\/sda\u7684\u6620\u50cf\uff0c\u6240\u4ee5\u4e0a\u9762\u7684\u547d\u4ee4\u5c06\u6062\u590d\/dev\/had\u7684\u6620\u50cf\u5230\/dev\/sdb<\/p>\n \u4f8b 4\uff1a\u521b\u5efa\u8f6f\u76d8\u6620\u50cf<\/strong> \u4f8b 5\uff1a\u5907\u4efd\u5206\u533a<\/strong> \u4f8b 6\uff1a\u5149\u76d8\u5907\u4efd<\/strong> dd\u547d\u4ee4\u4ece\u8f93\u5165\u4e2d\u8bfb\u53d6\u4e00\u4e2a\u5757\u5e76\u5c06\u5176\u5199\u5165\u8f93\u51fa\u6587\u4ef6\u3002\u4f60\u53ef\u4ee5\u6307\u5b9a\u8f93\u5165\u548c\u8f93\u51fa\u6587\u4ef6\u7684\u5757\u5927\u5c0f\u3002\u53c2\u6570\u201cbs\u201d\u6307\u5b9a\u8f93\u5165\u548c\u8f93\u51fa\u6587\u4ef6\u7684\u5757\u5927\u5c0f\u3002\u4e0a\u9762\u7684dd\u547d\u4ee4\u4f7f\u7528\u7684\u5757\u5927\u5c0f\u4e3a2048 bytes. \u539f\u6587\u6765\u81ea\uff1ahttp:\/\/www.thegeekstuff.com\/2010\/10\/dd-command-examples\/<\/a>\u7ffb\u8bd1\uff1a\u70e8\u5b50<\/span><\/p>\n
\n\u4f7f\u7528dd\u547d\u4ee4\u5907\u4efd\u6574\u4e2a\u786c\u76d8\u3002\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6e90\u786c\u76d8\u7684\u8bbe\u5907\u540d\u4e3a\/ dev\/ sda\u7684\uff0c\u76ee\u6807\u786c\u76d8\u7684\u8bbe\u5907\u540d\u662f\/ dev\/ sdb\u3002\u6267\u884cdd\u547d\u4ee4\uff0c\u5907\u4efd\u6574\u4e2a\u786c\u76d8\/dev\/sha\u5230\u540c\u4e00\u7cfb\u7edf\u7684\u53e6\u4e00\u4e2a\u786c\u76d8\/dev\/sdb\u3002\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n[root@linuxprobe ~]# dd if=\/dev\/sda of=\/dev\/sdb\r\n- \"if\"\u540e\u8ddf\u8f93\u5165\u6587\u4ef6\uff0c\u201cof\u201d\u540e\u8ddf\u8f93\u51fa\u6587\u4ef6\u3002\r\n- \u4e0a\u8ff0\u547d\u4ee4\u5728\u6267\u884c\u8fc7\u7a0b\u4e2d\u5982\u6709\u4efb\u4f55\u9519\u8bef\u90fd\u4f1a\u5931\u8d25\u3002\u4f46\u82e5\u52a0\u5165\u53c2\u6570\u201cCONV= NOERROR\u201d\uff0c\u5219\u5373\u4f7f\u6267\u884c\u8fc7\u7a0b\u4e2d\u6709\u9519\u8bef\uff0c\u5b83\u4e5f\u4f1a\u7ee7\u7eed\u590d\u5236\u3002\r\n- \u8f93\u5165\u6587\u4ef6\u548c\u8f93\u51fa\u6587\u4ef6\u5728\u6267\u884c\u524d\u5fc5\u987b\u68c0\u67e5\u518d\u4e09\uff0c\u5982\u679c\u4e24\u8005\u987a\u5e8f\u98a0\u5012\uff0c\u4f60\u53ef\u80fd\u4f1a\u635f\u5931\u6240\u6709\u6570\u636e\u3002\r\n<\/span><\/pre>\n
[root@linuxprobe ~]# dd if=\/dev\/sda of=\/dev\/sdb conv=noerror,sync\r\n<\/pre>\n
\n\u4f7f\u7528dd\u547d\u4ee4\u4e3a\u786c\u76d8\u521b\u5efa\u4e00\u4e2a\u56fe\u50cf\u6587\u4ef6\u5e76\u5c06\u5176\u4fdd\u5b58\u5728\u5176\u4ed6\u5b58\u50a8\u8bbe\u5907\u3002\u8fd9\u79cd\u5907\u4efd\u65b9\u5f0f\u6709\u5f88\u591a\u597d\u5904\uff1a\u4e00\u662f\u6613\u4e8e\u4f7f\u7528\uff0c\u4e8c\u662f\u8fd9\u79cd\u5907\u4efd\u65b9\u6cd5\u7684\u901f\u5ea6\u5feb\u4e8e\u5176\u4ed6\u65b9\u6cd5\u7684\u5907\u4efd\uff0c\u4e5f\u80fd\u8ba9\u4f60\u66f4\u5feb\u901f\u7684\u6062\u590d\u6570\u636e\u3002
\n\u521b\u5efa\u4e00\u4e2a\u786c\u76d8\/dev\/sda\u7684image\u547d\u4ee4\uff1a<\/p>\n[root@linuxprobe ~]# dd if=\/dev\/sda of=~\/sdadisk.img\r\n<\/pre>\n
\n\u4f7f\u7528dd\u547d\u4ee4\u5c06\u786c\u76d8\u7684\u6620\u50cf\u6587\u4ef6\u6062\u590d\u6570\u636e\u5230\u53e6\u4e00\u4e2a\u786c\u76d8\u3002\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n[root@linuxprobe ~]# dd if=sdadisk.img of=\/dev\/sdb\r\n<\/pre>\n
\n\u4f7f\u7528dd\u547d\u4ee4\u521b\u5efa\u8f6f\u76d8\u7684\u6620\u50cf\u5907\u4efd\u3002\u8f93\u5165\u6587\u4ef6\u586b\u5199\u8f6f\u76d8\u673a\u8bbe\u5907\u7684\u4f4d\u7f6e\uff0c\u8f93\u51fa\u6587\u4ef6\u5199\u8f6f\u76d8\u6620\u50cf\u6587\u4ef6\u7684\u540d\u79f0\uff0c\u5982\u4e0b\u6240\u793a\u3002<\/p>\n[root@linuxprobe ~]# dd if=\/dev\/fd0 of=myfloppy.img\r\n<\/pre>\n
\n\u4f7f\u7528dd\u547d\u4ee4\u5907\u4efd\u786c\u76d8\u5206\u533a\u3002\u8f93\u5165\u6587\u4ef6\u586b\u5199\u5206\u533a\u7684\u8bbe\u5907\u540d\u79f0\uff0c\u8f93\u51fa\u6587\u4ef6\u586b\u5199\u4f60\u6307\u5b9a\u7684\u76ee\u6807\u8def\u5f84\u6216\u6620\u50cf\u6587\u4ef6\u3002 dd\u547d\u4ee4\u793a\u4f8b\u6240\u793a\u5982\u4e0b\uff1a<\/p>\n[root@linuxprobe ~]# dd if=\/dev\/sda1 of=~\/partition1.img\r\n<\/pre>\n
\ndd\u547d\u4ee4\u5141\u8bb8\u6211\u4eec\u521b\u5efa\u6e90\u6587\u4ef6\u7684iso\u6587\u4ef6\uff0c\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u63d2\u5165CD\uff0c\u8f93\u5165dd\u547d\u4ee4\u6765\u521b\u5efa\u4e00\u4e2aCD\u7684iso\u6587\u4ef6\u5185\u5bb9\u3002<\/p>\n[root@linuxprobe ~]# dd if=\/dev\/cdrom of=tgsservice.iso bs=2048\r\n<\/pre>\n
\n\u6ce8\u610f:\u5982\u679c\u5149\u76d8\u662f\u81ea\u52a8\u6302\u8f7d\u7684\uff0c\u5728\u4f7f\u7528dd\u547d\u4ee4\u521b\u5efaiso\u6620\u50cf\u4e4b\u524d\u6700\u597dumount\u6389\u4ee5\u907f\u514d\u9020\u6210\u5bf9CD ROM\u4e0d\u5fc5\u8981\u7684\u8bbf\u95ee\u3002<\/p>\n\n