{"id":2408,"date":"2018-03-14T14:22:18","date_gmt":"2018-03-14T06:22:18","guid":{"rendered":"http:\/\/learn-house.idv.tw\/?p=2408"},"modified":"2018-03-28T11:30:18","modified_gmt":"2018-03-28T03:30:18","slug":"%e8%bd%89amdisk%e3%80%81ramfs%e3%80%81tmpfs%e5%b7%ae%e7%95%b0","status":"publish","type":"post","link":"https:\/\/learn-house.idv.tw\/?p=2408","title":{"rendered":"[\u8f49]ramdisk\u3001ramfs\u3001tmpfs\u5dee\u7570"},"content":{"rendered":"<p>\u8cc7\u6599\u4f86\u6e90\uff1ahttp:\/\/blog.twtnn.com\/2013\/12\/ramdiskramfstmpfs.html<\/p>\n<p>\u5728Linux\u4e2d\u53ef\u4ee5\u5c07\u4e00\u90e8\u5206\u8a18\u61b6\u9ad4\u639b\u8f09\u6210\u78c1\u789f\u4f86\u4f7f\u7528\uff0c\u5206\u5225\u70ba\uff1aramdisk\u3001ramfs\u3001tmpfs\u3002<br \/>\n\u800c\u5728\u5c07\u8a18\u61b6\u9ad4\u639b\u8f09\u6210\u78c1\u789f\u4e4b\u5f8c\uff0c\u5c31\u53ef\u4ee5\u628a\u5b83\u4f9d\u78c1\u789f\u4e00\u822c\u7684\u5b58\u53d6\u5b83\uff0c\u56e0\u70ba\u662f\u8a18\u61b6\u9ad4\u5b58\u53d6\uff0c<br \/>\n\u6240\u4ee5\u901f\u5ea6\u6bd4\u4e00\u822c\u7684\u786c\u789f\u8981\u5feb\u4e0a\u975e\u5e38\u591a\uff0c\u4f46\u662f\u95dc\u6a5f\u5f8c\uff0c\u88e1\u9762\u7684\u8cc7\u6599\u4e5f\u5c31\u8ddf\u8457\u6d88\u5931\u4e86\u3002<!--more--><\/p>\n<p>ramdisk\u53ef\u4ee5\u88abLinux\u683c\u5f0f\u5316\u4e14\u639b\u8f09\uff0c\u5b83\u5728Kernel 2.0\/2.2\u5c31\u5df2\u7d93\u88ab\u652f\u63f4\u4e86\uff0c<br \/>\n\u53ef\u662framdisk\u7684\u5927\u5c0f\u56fa\u5b9a\uff0c\u4e14\u7121\u6cd5\u5728\u639b\u8f09\u6642\u52d5\u614b\u66f4\u6539\u5b83\u3002<br \/>\n1\u3001\u5efa\u7acb\u4e00\u500b\u8981\u88ab\u639b\u8f09\u7684\u76ee\u9304<br \/>\n# mkdir \/mnt\/ramdisk<br \/>\n2\u3001\u683c\u5f0f\u5316ramdisk\uff0c\u5047\u8a2d\u7b49\u6703\u8981\u639b\u8f09\u7684\u662fram0<br \/>\n#mke2fs \/dev\/ram0<br \/>\n3\u3001\u639b\u8f09 \/dev\/ram0<br \/>\n# mount \/dev\/ram0 \/mnt\/ramdisk<\/p>\n<p>ramfs\u8655\u65bc\u865b\u64ec\u6a94\u6848\u7cfb\u7d71(VFS)\u5c64\uff0c\u800c\u4e0d\u662f\u50cframdisk\u90a3\u6a23\u57fa\u65bc\u865b\u64ec\u5728\u8a18\u61b6\u9ad4\u4e2d\u7684\u6a94\u6848\u7cfb\u7d71(ex2fs)\u3002<br \/>\n\u56e0\u800c\u7121\u9700\u683c\u5f0f\u5316\u4e14\u53ef\u4ee5\u5275\u5efa\u5f88\u591a\u500b\uff0c\u53ea\u8981\u8a18\u61b6\u9ad4\u8db3\u5920\uff0c\u5728\u5efa\u7acb\u6642\u53ef\u4ee5\u6307\u5b9a\u5176\u6700\u5927\u4f7f\u7528\u7684\u8a18\u61b6\u9ad4\u5927\u5c0f\u3002<br \/>\n\u800c\u4e14\u7528\u8d77\u4f86\u9748\u6d3b\uff0c\u5176\u5927\u5c0f\u96a8\u6240\u9700\u8981\u7684\u7a7a\u9593\u800c\u589e\u52a0\u6216\u6e1b\u5c11\u3002<br \/>\n# mkdir \/mnt\/ramfs<br \/>\n# mount -t ramfs ramfs \/mnt\/ramfs<br \/>\n\u9810\u8a2dramfs\u6700\u591a\u53ef\u4f7f\u7528\u8a18\u61b6\u9ad4\u5927\u5c0f\u7684\u4e00\u534a\u3002\u53ef\u4ee5\u901a\u904emaxsize(\u4ee5kbyte\u70ba\u55ae\u4f4d)\u9078\u9805\u4f86\u6539\u8b8a\uff0c\u5982\u4e0b\uff1a<br \/>\n# mount -t ramfs none \/testRAM -o maxsize=2000<br \/>\n\u6216\u662f\u4ee5size\u9078\u9805\u4f86\u6539\u8b8a\u5927\u5c0f\uff0c\u5982\u4e0b\uff1a<br \/>\nmount -t ramfs ramfs \/mnt\/ramfs -o size=200m<\/p>\n<p>tmpfs\u662f\u4e00\u500b\u865b\u64ec\u8a18\u61b6\u9ad4\u6a94\u6848\u7cfb\u7d71\uff0c\u5b83\u53ef\u4ee5\u4f7f\u7528\u5be6\u9ad4\u8a18\u61b6\u9ad4\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u4ea4\u63db\u5206\u5340\uff08SWAP\uff09\u3002<br \/>\n\u7576tmpfs\u5411\u865b\u64ec\u8a18\u61b6\u9ad4\u5b50\u7cfb\u7d71\u8acb\u6c42\u9801\u4f86\u5b58\u53d6\u6a94\u6848\u6642\uff0c\u5982\u540c\u5176\u5b83\u8acb\u6c42\u9801\u7684\u4e00\u6a23\uff0c<br \/>\n\u4e0d\u6703\u77e5\u9053\u5206\u914d\u7d66\u81ea\u5df1\u7684\u9801\u662f\u5728\u8a18\u61b6\u9ad4\u4e2d\u9084\u662f\u5728\u4ea4\u63db\u5206\u5340\u4e2d\u3002<br \/>\n\u8207ramfs\u4e00\u6a23\uff0c\u5176\u5927\u5c0f\u53ef\u4ee5\u96a8\u8457\u6240\u9700\u8981\u7684\u7a7a\u9593\u800c\u52d5\u614b\u7684\u589e\u6e1b\u3002<br \/>\n# mkdir -p \/mnt\/tmpfs<br \/>\n# mount tmpfs \/mnt\/tmpfs -t tmpfs<br \/>\n\u540c\u6a23\u53ef\u4ee5\u5728\u639b\u8f09\u6642\u6307\u5b9a\u6700\u5927\u9650\u5236<br \/>\n# mount tmpfs \/mnt\/tmpfs -t tmpfs -o size=16m<\/p>\n<p>\u4ee5\u4e0a\u90fd\u53ef\u4ee5\u7531\u6307\u4ee4mout\u4f86\u67e5\u8a62\u639b\u8f09\u7684\u60c5\u5f62<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8cc7\u6599\u4f86\u6e90\uff1ahttp:\/\/blog.twtnn.com\/2013\/12\/ramdiskramfstmpfs.ht<span class=\"post-excerpt-end\">&hellip;<\/span><\/p>\n<p class=\"more-link\"><a href=\"https:\/\/learn-house.idv.tw\/?p=2408\" class=\"themebutton\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-2408","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/2408","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2408"}],"version-history":[{"count":0,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/2408\/revisions"}],"wp:attachment":[{"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2408"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2408"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2408"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}