{"id":90,"date":"2017-07-07T14:16:54","date_gmt":"2017-07-07T06:16:54","guid":{"rendered":"\/\/hqidi.com\/?p=90"},"modified":"2017-07-07T14:16:54","modified_gmt":"2017-07-07T06:16:54","slug":"linux%e8%af%af%e5%88%a0%e6%95%b0%e6%8d%ae%e6%81%a2%e5%a4%8d","status":"publish","type":"post","link":"https:\/\/hqidi.com\/90.html","title":{"rendered":"Linux\u8bef\u5220\u6570\u636e\u6062\u590d"},"content":{"rendered":"<h2><span style=\"color: #FF6347;\">\u5f15\u5b50<\/span><\/h2>\n<p>\u6307\u5728\u952e\u4e0a\u98d8\uff0c\u96be\u514d\u4f1a\u6e7f\u624b\u5957\u3002\u5f53\u4f60\u6309\u4e0bshift+del\u952e\u540e\uff0c\u4f1a\u4e0d\u4f1a\u7a81\u7136\u5fc3\u91cc\u51c9\u900f\uff0c\u5f53\u4f60\u6267\u884crm -rf\u540e\uff0c\u4f1a\u4e0d\u4f1a\u9a6c\u4e0a\u53bb\u641c\u7d22\u54ea\u4e2a\u56fd\u5bb6\u5165\u5883\u4e0d\u9700\u8981\u7b7e\u8bc1\u3002\u6216\u8005\u4f60\u8fd8\u4f1a\u9047\u5230\u5982\u4e0b\u7684\u60c5\u51b5\uff1a<\/p>\n<pre class=\"prettyprint\" >\r\nroot@4xem7:~# alias\r\nalias cd='rm -rf'\r\nalias d='docker'\r\n<\/pre>\n<h2>\u6570\u636e\u6062\u590d\u539f\u7406\u6d45\u6790<\/h2>\n<p><img decoding=\"async\" src=\"\/\/hqidi.com\/img\/90\/1.jpg\" alt=\"\" \/><br \/>\n\u5982\u56fe\u6240\u793a\uff0c\u786c\u76d8\u4e0a\u6570\u636e\u7684\u5b58\u653e\u6709\u4e00\u4e2a\u7c7b\u4f3c\u4e8e\u4e66\u672c\u76ee\u5f55\u7684\u4e1c\u897f\u5b58\u5728\uff0c\u5c31\u662f\u56fe\u4e2d\u6700\u4e0a\u9762\u90a3\u4e00\u6392\u5706\u5f62\u3002\u786c\u76d8\u683c\u5f0f\u5316\u540e\uff0c\u88ab\u5206\u5272\u6210\u4e86\u5f88\u591a\u4e2a\u5c0f\u5757\uff0c\u5c31\u50cf\u8702\u5de2\u4e00\u6837\uff0c\u4e00\u4e2a\u4e2a\u7684\u5c0f\u623f\u95f4\uff0c\u5c31\u662f\u4e0a\u56fe\u4e2d\u95f4\u90e8\u5206\u7684\u957f\u65b9\u5757\uff0c\u8fd9\u4e2a\u5c0f\u623f\u95f4\u624d\u662f\u771f\u6b63\u5b58\u653e\u6570\u636e\u7684\u5730\u65b9\uff0c\u6700\u4e0b\u9762\u7684\u6570\u5b57\uff0c\u662f\u623f\u95f4\u53f7\uff0c\u4e5f\u5c31\u662finode\u53f7\u3002\u5982\u679c\u6211\u4eec\u8981\u4f7f\u7528\u6587\u4ef6A\uff0c\u5728\u6700\u4e0a\u9762\u7684\u76ee\u5f55\u91cc\u9762\u5c31\u80fd\u5f88\u5feb\u7684\u77e5\u9053\u6587\u4ef6A\u57281\u53f7\u623f\u95f4\u3002<br \/>\n\u27a4<strong>\u4ec0\u4e48\u60c5\u51b5\u4e0b\uff0c\u88ab\u8bef\u5220\u7684\u6570\u636e\u80fd\u6062\u590d<\/strong><br \/>\n\u8bef\u5220\u60c5\u51b5\u53d1\u751f\u540e\uff0c\u7b2c\u4e00\u91cd\u8981\u7684\u4e8b\u60c5\u5c31\u662f\u5378\u8f7d\u8bef\u5220\u6570\u636e\u6240\u5728\u7684\u5206\u533a\uff0c<span style=\"color: #ff0000;\">\u800c\u4e0d\u662f\u5173\u673a\uff0c<\/span>\u7edd\u5bf9\u4e0d\u80fd\u5173\u673a\uff0c\u4e3a\u4ec0\u4e48\uff1f\u73b0\u5728\u6240\u6709\u7684\u7cfb\u7edf\u4f18\u5316\uff0c\u5176\u672c\u8d28\u5c31\u662f\u628a\u786c\u76d8IO\u8f6c\u6362\u6210\u5185\u5b58IO\uff0c\u5c31\u662f\u628a\u672c\u8be5\u5230\u786c\u76d8\u91cc\u9762\u53bb\u8bfb\u5199\u7684\u5185\u5bb9\uff0c\u63d0\u524d\u9884\u8f7d\u5230\u5185\u5b58\u91cc\u9762\u53bb\u3002\u4f60\u82e5\u6b63\u5e38\u5173\u673a\uff0credis\u6301\u4e45\u5316\u7684\u6570\u636e\uff0c\u53ef\u80fd\u6709\u597d\u51e0\u4e2aG\uff0cmysql\u7684InnoDB_Buffer_Pool\u7f13\u51b2\u6c60\u91cc\u9762\u7684\u4e1c\u897f\uff08\u53ef\u80fd\u6709\u597d\u51e0\u5341\u4e2aG\uff09\uff0c\u8fd9\u4e9b\u4e1c\u897f\u5f80\u786c\u76d8\u91cc\u9762\u4e00\u5199\uff0c\u4f60\u8fd8\u60f3\u6062\u590d\u6570\u636e\uff0c\u7b49\u6211\u53d1\u660e\u65f6\u5149\u673a\u5427\u3002\u4e3a\u4ec0\u4e48\u8bf4\u9a6c\u4e0a\u5378\u8f7d\u5206\u533a\uff0c\u6570\u636e\u5c31\u80fd\u6062\u590d\u3002\u770b\u4e0b\u56fe\uff0crm -rf\u5220\u9664\u4e86A\u6587\u4ef6\u3002<br \/>\n<img decoding=\"async\" src=\"\/\/hqidi.com\/img\/90\/2.jpg\" alt=\"\" \/><br \/>\n\u5176\u5b9e\uff0c\u7cfb\u7edf\u53ea\u662f\u5220\u9664\u4e86\u76ee\u5f55\u91cc\u9762\u7684\u6587\u4ef6\u6307\u5411\uff0c\u6587\u4ef6A\u8fd8\u597d\u597d\u7684\u8d9f\u57281\u53f7\u623f\u95f4\u91cc\u9762\u3002\u6240\u4ee5\u8fd9\u79cd\u60c5\u51b5\uff0c\u6587\u4ef6\u662f\u80fd\u5f88\u8f7b\u677e\u7684\u6062\u590d\u7684\u3002<br \/>\n\u27a4<strong>\u4ec0\u4e48\u60c5\u51b5\u4e0b\uff0c\u88ab\u8bef\u5220\u7684\u6570\u636e\u4e0d\u80fd\u6062\u590d<\/strong><br \/>\n\u627f\u63a5\u4e0a\u4e00\u5f20\u56fe\uff0c\u76ee\u5f55\u91cc\u9762\u663e\u793a1\u53f7\u623f\u95f4\u662f\u7a7a\u7684\uff0c\u53ef\u4ee5\u91cd\u65b0\u653e\u6570\u636e\u8fdb\u53bb\uff0c\u82e5\u6b64\u65f6\uff0c\u786c\u76d8\u53c8\u63a5\u6536\u5230\u5199\u5165\u8bf7\u6c42(\u6bd4\u65b9\u8bf4\u4f60\u8111\u62bd\uff0c\u628a\u6570\u636e\u6062\u590d\u8f6f\u4ef6\u5b89\u88c5\u5230\u4e86\u8bef\u5220\u6570\u636e\u6240\u5728\u7684\u5206\u533a)\uff0c\u5c31\u4f1a\u628a\u6570\u636e\u5199\u51651\u53f7\u623f\u95f4\uff1a<br \/>\n<img decoding=\"async\" src=\"\/\/hqidi.com\/img\/90\/3.jpg\" alt=\"\" \/><br \/>\n\u6b64\u65f6\uff0c\u4f60\u82e5\u8fd8\u60f3\u6062\u590d\u6570\u636e\uff0c\u53ea\u80fd\u7b49\u6211\u53d1\u660e\u65f6\u5149\u673a\u4e86\u3002<\/p>\n<h2>extundelete\u6062\u590d\u4e3e\u4f8b<\/h2>\n<p>extundelete\u53ef\u4ee5\u6062\u590dext3\u3001ext4\u6587\u4ef6\u7cfb\u7edf\u4e0b\u88ab\u8bef\u5220\u7684\u6587\u4ef6\uff0c\u770b\u5176\u6062\u590d\u539f\u7406xfs\u6587\u4ef6\u7cfb\u7edf\u5e94\u8be5\u4e5f\u662f\u53ef\u4ee5\u6062\u590d\u7684\u3002<\/p>\n<h3>\u5b89\u88c5extundelete<\/h3>\n<p>\u5728\u5b89\u88c5extundelete\u524d\uff0c\u9700\u8981\u5b89\u88c5e2fsprogs\u548ce2fsprogs-libs\uff0c\u81ea\u884c\u7528yum\u5b89\u88c5\u5c31\u53ef\u4ee5\u3002<\/p>\n<pre class=\"prettyprint\" >\r\n[root@dish ~]# rpm -qa |grep e2fsprogs\r\ne2fsprogs-libs-1.41.12-22.el6.x86_64\r\ne2fsprogs-1.41.12-22.el6.x86_64\r\n<\/pre>\n<p>epel\u6e90\u91cc\u9762\u6709extundelete\uff0c\u76f4\u63a5\u5b89\u88c5\u5c31\u884c\u3002<\/p>\n<pre class=\"prettyprint\" >\r\n[root@dish ~]# yum install extundelete -y\r\n[root@dish ~]# rpm -ql extundelete\r\n\/usr\/bin\/extundelete\r\n\/usr\/share\/doc\/extundelete-0.2.4\r\n\/usr\/share\/doc\/extundelete-0.2.4\/LICENSE\r\n\/usr\/share\/doc\/extundelete-0.2.4\/README\r\n<\/pre>\n<h3>extundelete\u5e38\u7528\u53c2\u6570\u89e3\u91ca<\/h3>\n<pre class=\"prettyprint\" >\r\nOptions:\r\n\r\n  --superblock           \u663e\u793a\u8d85\u7ea7\u5757\u4fe1\u606f\uff0c\u9ed8\u8ba4\u9009\u9879.\r\n                         \r\n  --journal              \u663e\u793a\u65e5\u5fd7\u4fe1\u606f.\r\n  --after dtime         \u8868\u793a\u5728\u67d0\u6bb5\u65f6\u95f4\u4e4b\u540e\u88ab\u5220\u9664\u7684\u6587\u4ef6\u6216\u76ee\u5f55.\r\n  --before dtime         \u8868\u793a\u5728\u67d0\u6bb5\u65f6\u95f4\u4e4b\u524d\u88ab\u5220\u9664\u7684\u6587\u4ef6\u6216\u76ee\u5f55.\r\nActions:\r\n  --inode ino            Show info on inode 'ino'.\r\n  --block blk            Show info on block 'blk'.\r\n  --restore-inode ino[,ino,...]\r\n                         \u6062\u590d\u6307\u5b9ainode\u53f7\u7684\u6587\u4ef6\uff0c\u6062\u590d\u51fa\u6765\u7684\u6587\u4ef6\u4f1a\u653e\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u7684RECOVERED_FILES\u6587\u4ef6\u5939\u4e2d\r\n  --restore-file 'path'  \u6062\u590d\u6307\u5b9a\u8def\u5f84\u7684\u6587\u4ef6\r\n  --restore-files 'path' \u6062\u590d\u5728\u8def\u5f84\u4e2d\u5217\u51fa\u7684\u6240\u6709\u6587\u4ef6\r\n \r\n  --restore-all          \u5c1d\u8bd5\u6062\u590d\u6240\u6709\u76ee\u5f55\u548c\u6587\u4ef6\r\n <\/pre>\n<h3>\u6062\u590d\u6587\u4ef6<\/h3>\n<p>\u27a4\u6d4b\u8bd5\u6587\u4ef6<\/p>\n<pre class=\"prettyprint\" >\r\n[root@dish reco]# for i in A B C D;do echo \"this is file$i\">$i;done\r\n[root@dish reco]# cat A B C D\r\nthis is fileA\r\nthis is fileB\r\nthis is fileC\r\nthis is fileD\r\n[root@dish reco]# find .\/ -type f |xargs md5sum >.\/file.md5\r\n[root@dish reco]# cat file.md5 \r\nd41d8cd98f00b204e9800998ecf8427e  .\/file.md5\r\nc2f9bc9edb959d08dc838af14c5cd8ff  .\/C\r\nafc688bfcd0666302ed55da472ecfbb8  .\/B\r\n0a540f40e1e8c3e5ad50571f1621d5b3  .\/A\r\n2c3fdd8c8e23a1ba2d0381981f337348  .\/D\r\n[root@dish reco]# rm -rf A B C D\r\n[root@dish reco]# ls\r\nfile.md5\r\n<\/pre>\n<p>\u27a4\u5378\u8f7d\u78c1\u76d8\u5206\u533a<br \/>\n\u53d1\u73b0\u6570\u636e\u8bef\u5220\u540e\uff0c\u53ea\u505a\u4e00\u4ef6\u4e8b\uff0c\u5378\u8f7d\u6570\u636e\u6240\u5728\u5206\u533a<\/p>\n<pre class=\"prettyprint\" >\r\n[root@dish reco]# cd\r\n[root@dish ~]# umount \/dev\/vdb1\r\n<\/pre>\n<p>\u27a4\u67e5\u8be2\u53ef\u6062\u590d\u7684\u6570\u636e<br \/>\n\u9996\u5148\u67e5\u770b\u6570\u636e\u6240\u5728\u76ee\u5f55reco\u7684inode\u53f7<\/p>\n<pre class=\"prettyprint\" >\r\n[root@dish ~]# extundelete \/dev\/vdb1 --inode 2 |grep reco\r\nreco                                              131073\r\n<\/pre>\n<p>reco\u76ee\u5f55\u7684inode\u53f7131073<\/p>\n<pre class=\"prettyprint\" >\r\n[root@dish ~]# extundelete \/dev\/vdb1 --inode 131073 |tail\r\nTriple indirect block: 0\r\n\r\nFile name                                       | Inode number | Deleted status\r\n.                                                 131073\r\n..                                                2\r\nA                                                 131074         Deleted\r\nB                                                 131075         Deleted\r\nC                                                 131076         Deleted\r\nD                                                 131077         Deleted\r\nfile.md5                                          131078\r\n<\/pre>\n<p>\u5982\u4e0a\u6240\u793a\uff0c\u6807\u8bb0\u4e3aDeleted\u72b6\u6001\u7684\u5c31\u662f\u8bef\u5220\u7684\u6587\u4ef6\uff0c\u540c\u65f6\u8fd8\u80fd\u770b\u5230\u5bf9\u5e94\u6587\u4ef6\u7684inode\u503c\uff0c\u6709\u4e86\u8fd9\u4e9b\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u6062\u590d\u6587\u4ef6\u4e86\u3002<\/p>\n<pre class=\"prettyprint\" >\r\n[root@dish ~]# extundelete \/dev\/vdb1 --restore-file reco\/C\r\nNOTICE: Extended attributes are not restored.\r\nLoading filesystem metadata ... 160 groups loaded.\r\nLoading journal descriptors ... 2858 descriptors loaded.\r\nSuccessfully restored file reco\/C\r\n[root@dish ~]# extundelete \/dev\/vdb1 --restore-file reco\/D\r\nNOTICE: Extended attributes are not restored.\r\nLoading filesystem metadata ... 160 groups loaded.\r\nLoading journal descriptors ... 2858 descriptors loaded.\r\nSuccessfully restored file reco\/D\r\n<\/pre>\n<p>--restore-file \u540e\u9762\u7684reco\/C\u662f\u4e2a\u76f8\u5bf9\u8def\u5f84\uff0c\u5176\u539f\u672c\u7684\u8def\u5f84\u662f\/bak\/reco\/C\uff0c\u800cbak\u76ee\u5f55\u6302\u8f7d\u7684\u5c31\u662f\/dev\/vdb1\u3002\u6587\u4ef6\u6062\u590d\u6210\u529f\u540e\uff0c\u4f1a\u5728\u4f60\u6267\u884c\u6062\u590d\u547d\u4ee4\u7684\u5f53\u524d\u76ee\u5f55\u751f\u6210\u4e00\u4e2aRECOVERED_FILES\u76ee\u5f55\uff0c\u6062\u590d\u51fa\u6765\u7684\u6587\u4ef6\u5c31\u5728\u91cc\u9762\u3002<\/p>\n<pre class=\"prettyprint\" >\r\n[root@dish ~]# cd RECOVERED_FILES\/reco\/\r\n[root@dish reco]# md5sum -c file.md5 \r\n.\/C: OK\r\n.\/B: OK\r\n.\/A: OK\r\n.\/D: OK\r\n<\/pre>\n<p>\u6062\u590d\u51fa\u6765\u7684\u6587\u4ef6\u7ecf\u8fc7MD5\u6821\u9a8c\u5168\u901a\u8fc7\u3002\u6062\u590d\u6210\u529f\u3002<\/p>\n<h3>\u6062\u590d\u76ee\u5f55<\/h3>\n<pre class=\"prettyprint\" >\r\n[root@dish reco]# mkdir mulu\r\n[root@dish reco]# cd !$\r\ncd mulu\r\n[root@dish mulu]# touch {01..09}\r\n[root@dish mulu]# ls\r\n01  02  03  04  05  06  07  08  09 \r\n[root@dish mulu]# cd ..\r\n[root@dish reco]# rm -rf mulu\r\n[root@dish reco]# cd\r\n[root@dish ~]# r umount\r\numount \/dev\/vdb1\r\n[root@dish ~]# extundelete \/dev\/vdb1 --restore-directory \/reco\/mulu\r\nNOTICE: Extended attributes are not restored.\r\nLoading filesystem metadata ... 160 groups loaded.\r\nLoading journal descriptors ... 2857 descriptors loaded.\r\nSearching for recoverable inodes in directory \/reco\/mulu ... \r\n10 recoverable inodes found.\r\nLooking through the directory structure for deleted files ... \r\n2 recoverable inodes still lost.\r\n[root@dish reco]# ls mulu\/\r\n01  02  03  04  05  06  07  08\r\n<\/pre>\n<p>\u76ee\u5f55\u88ab\u6210\u529f\u6062\u590d\uff0c\u6ce8\u610f\uff0c\u76ee\u5f55\u91cc\u9762\u7684\u7a7a\u6587\u4ef6\u662f\u65e0\u6cd5\u6062\u590d\u7684\uff0c09\u5c31\u662f\u4e00\u4e2a\u7a7a\u6587\u4ef6\u3002<\/p>\n<h3>\u6062\u590d\u6240\u6709\u6587\u4ef6<\/h3>\n<p>\u9700\u8981\u6062\u590d\u7684\u6587\u4ef6\u6570\u91cf\u8fc7\u591a\u7684\u65f6\u5019\uff0c\u53ef\u4ee5\u7528\u8fd9\u4e2a\u9009\u9879\u3002<\/p>\n<pre class=\"prettyprint\" >\r\n[root@dish tmp]# extundelete \/dev\/vdb1 --restore-all\r\n<\/pre>\n<h3>\u6062\u590d\u67d0\u4e2a\u65f6\u95f4\u70b9\u4e4b\u540e\u5220\u9664\u7684\u6587\u4ef6<\/h3>\n<p>\u8fd9\u4e2a\u5e94\u8be5\u662f\u7528\u7684\u6700\u591a\u7684\u573a\u666f\u4e86\uff0c\u6bd4\u65b9\u8bf4\u9700\u8981\u6062\u590d\u4e00\u4e2a\u5c0f\u65f6\u5185\u88ab\u5220\u9664\u7684\u6587\u4ef6\u3002<\/p>\n<pre class=\"prettyprint\" >\r\nextundelete --after `echo $(date +%s)-3600 |bc` --restore-all \/dev\/vdb1\r\n<\/pre>\n<p>\u4e00\u4e2a\u5c0f\u65f63600\u79d2\uff0c\u6839\u636e\u81ea\u5df1\u9700\u6c42\u4fee\u6539\u4e0a\u9762\u7684\u51cf\u6570\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f15\u5b50 \u6307\u5728\u952e\u4e0a\u98d8\uff0c\u96be\u514d\u4f1a\u6e7f\u624b\u5957\u3002\u5f53\u4f60\u6309\u4e0bshift+del\u952e\u540e\uff0c\u4f1a\u4e0d\u4f1a\u7a81\u7136\u5fc3\u91cc\u51c9\u900f\uff0c\u5f53\u4f60\u6267\u884crm -rf\u540e\uff0c\u4f1a\u4e0d\u4f1a\u9a6c\u4e0a\u53bb\u641c\u7d22\u54ea\u4e2a\u56fd\u5bb6\u5165\u5883\u4e0d\u9700\u8981\u7b7e\u8bc1\u3002\u6216\u8005\u4f60\u8fd8\u4f1a\u9047\u5230\u5982\u4e0b\u7684\u60c5\u51b5\uff1a root@4xem7:~# alias alias cd='rm -rf' alias d='docker' \u6570\u636e\u6062\u590d\u539f\u7406\u6d45\u6790 \u5982\u56fe\u6240\u793a\uff0c\u786c\u76d8\u4e0a\u6570\u636e\u7684\u5b58\u653e\u6709\u4e00\u4e2a\u7c7b\u4f3c\u4e8e\u4e66\u672c\u76ee\u5f55\u7684\u4e1c\u897f\u5b58\u5728...<\/p>\n<a class=\"read-more\" href=\"https:\/\/hqidi.com\/90.html\">\u9605\u8bfb\u5168\u6587 &raquo;<\/a>","protected":false},"author":1,"featured_media":3015,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[68],"class_list":["post-90","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-study","tag-68"],"_links":{"self":[{"href":"https:\/\/hqidi.com\/wp-json\/wp\/v2\/posts\/90"}],"collection":[{"href":"https:\/\/hqidi.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hqidi.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hqidi.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hqidi.com\/wp-json\/wp\/v2\/comments?post=90"}],"version-history":[{"count":2,"href":"https:\/\/hqidi.com\/wp-json\/wp\/v2\/posts\/90\/revisions"}],"predecessor-version":[{"id":3107,"href":"https:\/\/hqidi.com\/wp-json\/wp\/v2\/posts\/90\/revisions\/3107"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hqidi.com\/wp-json\/wp\/v2\/media\/3015"}],"wp:attachment":[{"href":"https:\/\/hqidi.com\/wp-json\/wp\/v2\/media?parent=90"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hqidi.com\/wp-json\/wp\/v2\/categories?post=90"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hqidi.com\/wp-json\/wp\/v2\/tags?post=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}