{"id":9903,"date":"2023-06-29T15:36:14","date_gmt":"2023-06-29T07:36:14","guid":{"rendered":"http:\/\/xinyiworld.top\/wordpress_it\/?p=9903"},"modified":"2024-08-12T09:45:11","modified_gmt":"2024-08-12T01:45:11","slug":"lxc%e7%9a%84%e5%9f%ba%e6%9c%ac%e5%91%bd%e4%bb%a4%e5%8f%8a%e4%bd%bf%e7%94%a8","status":"publish","type":"post","link":"http:\/\/xinyiworld.top\/wordpress_it\/?p=9903","title":{"rendered":"lxc\u7684\u57fa\u672c\u547d\u4ee4\u53ca\u4f7f\u7528"},"content":{"rendered":"<p><a href=\"http:\/\/www.360doc.com\/content\/22\/0609\/09\/474846_1035269866.shtml\">http:\/\/www.360doc.com\/content\/22\/0609\/09\/474846_1035269866.shtml<\/a><br \/>\n<a href=\"https:\/\/www.myinqi.com\/zixun\/996935.html\">https:\/\/www.myinqi.com\/zixun\/996935.html<\/a><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_16 counter-hierarchy counter-decimal ez-toc-grey\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\">\u76ee\u5f55<\/p>\n<span class=\"ez-toc-title-toggle\"><a class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" style=\"display: none;\"><i class=\"ez-toc-glyphicon ez-toc-icon-toggle\"><\/i><\/a><\/span><\/div>\n<nav><ul class=\"ez-toc-list ez-toc-list-level-1\"><ul class=\"ez-toc-list-level-2\"><li class=\"ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-1\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=9903\/#%E6%BA%90%E7%A0%81\" title=\"\u6e90\u7801\">\u6e90\u7801<\/a><ul class=\"ez-toc-list-level-3\"><li class=\"ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-2\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=9903\/#android%E5%B9%B3%E5%8F%B0%E7%BC%96%E8%AF%91\" title=\"android\u5e73\u53f0\u7f16\u8bd1\">android\u5e73\u53f0\u7f16\u8bd1<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-3\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=9903\/#configure%E7%BC%96%E8%AF%91%E5%8F%82%E6%95%B0%E8%AF%B4%E6%98%8E\" title=\"configure\u7f16\u8bd1\u53c2\u6570\u8bf4\u660e\">configure\u7f16\u8bd1\u53c2\u6570\u8bf4\u660e<\/a><ul class=\"ez-toc-list-level-4\"><li class=\"ez-toc-heading-level-4\"><a class=\"ez-toc-link ez-toc-heading-4\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=9903\/#%E5%8F%82%E6%95%B0%E4%BC%A0%E9%80%92%E7%9A%84%E5%8E%9F%E7%90%86\" title=\"\u53c2\u6570\u4f20\u9012\u7684\u539f\u7406\">\u53c2\u6570\u4f20\u9012\u7684\u539f\u7406<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-4\"><a class=\"ez-toc-link ez-toc-heading-5\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=9903\/#%E5%90%84%E4%B8%AA%E5%8F%82%E6%95%B0%E8%AF%B4%E6%98%8E\" title=\"\u5404\u4e2a\u53c2\u6570\u8bf4\u660e\">\u5404\u4e2a\u53c2\u6570\u8bf4\u660e<\/a><ul class=\"ez-toc-list-level-5\"><li class=\"ez-toc-heading-level-5\"><a class=\"ez-toc-link ez-toc-heading-6\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=9903\/#%E5%B7%A5%E7%A8%8B%E5%8F%82%E6%95%B0\" title=\"\u5de5\u7a0b\u53c2\u6570\">\u5de5\u7a0b\u53c2\u6570<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-5\"><a class=\"ez-toc-link ez-toc-heading-7\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=9903\/#%E5%AE%B9%E5%99%A8%E5%8F%82%E6%95%B0\" title=\"\u5bb9\u5668\u53c2\u6570\">\u5bb9\u5668\u53c2\u6570<\/a><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-8\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=9903\/#%E5%8E%9F%E7%90%86\" title=\"\u539f\u7406\">\u539f\u7406<\/a><ul class=\"ez-toc-list-level-3\"><li class=\"ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-9\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=9903\/#lxc%E8%BF%9B%E5%8C%96%E5%8E%86%E5%8F%B2\" title=\"lxc\u8fdb\u5316\u5386\u53f2\">lxc\u8fdb\u5316\u5386\u53f2<\/a><ul class=\"ez-toc-list-level-4\"><li class=\"ez-toc-heading-level-4\"><a class=\"ez-toc-link ez-toc-heading-10\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=9903\/#Chroot%EF%BC%88%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%E5%B1%82%E6%AC%A1%E7%9A%84%E8%B5%84%E6%BA%90%E9%9A%94%E7%A6%BB%EF%BC%89\" title=\"Chroot\uff08\u6587\u4ef6\u7cfb\u7edf\u5c42\u6b21\u7684\u8d44\u6e90\u9694\u79bb\uff09\">Chroot\uff08\u6587\u4ef6\u7cfb\u7edf\u5c42\u6b21\u7684\u8d44\u6e90\u9694\u79bb\uff09<\/a><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-11\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=9903\/#lxc%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86\" title=\"lxc\u57fa\u672c\u539f\u7406\">lxc\u57fa\u672c\u539f\u7406<\/a><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-12\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=9903\/#%E6%8C%87%E4%BB%A4\" title=\"\u6307\u4ee4\">\u6307\u4ee4<\/a><ul class=\"ez-toc-list-level-3\"><li class=\"ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-13\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=9903\/#lxc%E7%8E%AF%E5%A2%83%E6%A3%80%E6%9F%A5\" title=\"lxc\u73af\u5883\u68c0\u67e5\">lxc\u73af\u5883\u68c0\u67e5<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-14\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=9903\/#%E5%8F%82%E6%95%B0%E8%AE%BE%E7%BD%AE\" title=\"\u53c2\u6570\u8bbe\u7f6e\">\u53c2\u6570\u8bbe\u7f6e<\/a><ul class=\"ez-toc-list-level-4\"><li class=\"ez-toc-heading-level-4\"><a class=\"ez-toc-link ez-toc-heading-15\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=9903\/#%E6%97%A5%E5%BF%97%E8%AE%BE%E7%BD%AE\" title=\"\u65e5\u5fd7\u8bbe\u7f6e\">\u65e5\u5fd7\u8bbe\u7f6e<\/a><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-16\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=9903\/#%E6%8C%87%E4%BB%A4%E9%9B%86\" title=\"\u6307\u4ee4\u96c6\">\u6307\u4ee4\u96c6<\/a><\/li><\/ul><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-1\"><a class=\"ez-toc-link ez-toc-heading-17\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=9903\/#%E5%85%88%E5%81%9C%E6%8E%89%E5%AE%B9%E5%99%A8%E7%84%B6%E5%90%8E%E8%BF%9B%E8%A1%8C%E5%88%A0%E9%99%A4\" title=\"\u5148\u505c\u6389\u5bb9\u5668\u7136\u540e\u8fdb\u884c\u5220\u9664\">\u5148\u505c\u6389\u5bb9\u5668\u7136\u540e\u8fdb\u884c\u5220\u9664<\/a><ul class=\"ez-toc-list-level-3\"><li class=\"ez-toc-heading-level-3\"><ul class=\"ez-toc-list-level-3\"><li class=\"ez-toc-heading-level-3\"><a class=\"ez-toc-link ez-toc-heading-18\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=9903\/#hook\" title=\"hook\">hook<\/a><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"%E6%BA%90%E7%A0%81\"><\/span>\u6e90\u7801<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u4e0b\u8f7d\u5730\u5740\uff1a<a href=\"https:\/\/gitee.com\/mirrors\/lxc\">https:\/\/gitee.com\/mirrors\/lxc<\/a><\/p>\n<p>\u5b98\u7f51\u5730\u5740\uff1a<a href=\"https:\/\/linuxcontainers.org\/lxc\/downloads\/\">https:\/\/linuxcontainers.org\/lxc\/downloads\/<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"android%E5%B9%B3%E5%8F%B0%E7%BC%96%E8%AF%91\"><\/span>android\u5e73\u53f0\u7f16\u8bd1<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u6ce8\u610f\uff1a<br \/>\n1.lxc5\uff0c6\u90fd\u7f3a\u5c11Makefile.am\u6587\u4ef6\uff0c\u65e0\u6cd5\u6267\u884cautotool\u751f\u6210configure\u6587\u4ef6\u3002<br \/>\n2.ndk\u4e00\u5b9a\u8981\u4f7f\u752817\u7248\u672c\uff0c\u5176\u5b83\u7684\u9ad8\u7248\u672c\u8bd5\u4e86\u597d\u51e0\u4e2a\u90fd\u65e0\u6cd5\u7f16\u8bd1\u3002<\/p>\n<pre><code class=\"language-bash\">  1 #make clean\n  2 #sudo rm -rf out\/\n  3 #mkdir out\n  4 NDK_ROOT=\/etc\/opt\/pkg\/android-ndk-r17c\n  5 SYSROOT=&quot;$NDK_ROOT\/platforms\/android-28\/arch-arm64&quot;\n  6 SI=&quot;$NDK_ROOT\/sysroot\/usr\/include&quot;\n  7 FLAGS=&quot;-isystem $SI -isystem $SI\/aarch64-linux-android&quot;\n  8 \n  9 export CC=&quot;$NDK_ROOT\/toolchains\/aarch64-linux-android-4.9\/prebuilt\/linux-x86_64\/bin\/aarch64-linux-android-gcc&quot;\n 10 export CFLAGS=&quot;--sysroot=$SYSROOT $FLAGS -pie&quot;\n 11 export LDFLAGS=&quot;-L\/home\/xinyi\/code\/lxc-4.0.0\/out\/lib&quot;\n 12 #export LIBS=&quot;-llxc&quot;\n 13 #export LD_LIBRARY_PATH=\/home\/pxl\/lxc-4.0.12\/out\/lib:$LD_LIBRARY_PATH\n 14 #export LD_LIBRARY_PATH=\/home\/pxl\/lxc-4.0.12\/out\/lib\/\n 15 \n 16 #echo $LD_LIBRARY_PATH\n 17 #exit 1\n 18 pre=`pwd`\n 19 .\/configure --prefix=${pre}\/out \\\n 20             --host=aarch64-linux-android\n 21           #  --enable-configpath-log\n 22 \n 23 #make\n 24 sudo make install<\/code><\/pre>\n<p>3.\u9879\u76ee\u672c\u8eab\u5c31\u6709configure.ac\u6587\u4ef6\uff0c\u65e0\u9700\u7528 autoscan\u518d\u751f\u6210configure.in\u6216\u8005configure.scan\u6587\u4ef6\u3002<\/p>\n<h3><span class=\"ez-toc-section\" id=\"configure%E7%BC%96%E8%AF%91%E5%8F%82%E6%95%B0%E8%AF%B4%E6%98%8E\"><\/span>configure\u7f16\u8bd1\u53c2\u6570\u8bf4\u660e<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<h4><span class=\"ez-toc-section\" id=\"%E5%8F%82%E6%95%B0%E4%BC%A0%E9%80%92%E7%9A%84%E5%8E%9F%E7%90%86\"><\/span>\u53c2\u6570\u4f20\u9012\u7684\u539f\u7406<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>\u4ee5<code>--with-rootfs-path<\/code>\u4e3a\u4f8b<br \/>\n\u5728configure.ac\u4e2d\uff1a<\/p>\n<pre><code class=\"language-bash\"># Rootfs path, where the container mount structure is assembled\nAC_ARG_WITH([rootfs-path],\n    [AS_HELP_STRING([--with-rootfs-path=dir], [lxc rootfs mount point])],\n    [with_rootfs_path=$withval], [with_rootfs_path=[&#039;${libdir}\/lxc\/rootfs&#039;]])\n\nAS_AC_EXPAND(LXCROOTFSMOUNT, &quot;$with_rootfs_path&quot;)<\/code><\/pre>\n<p>\u6700\u7ec8\u7f16\u8bd1\u6210\u5b8fLXCROOTFSMOUNT\u901a\u8fc7-DLXCROOTFSMOUNT\u4f20\u9012\u7ed9\u4ee3\u7801\u7a0b\u5e8f\u3002<\/p>\n<p>\u5728lxc_conf_init\u65b9\u6cd5\u4e2d\uff1a<\/p>\n<pre><code class=\"language-c\">static char *default_rootfs_mount = LXCROOTFSMOUNT;\n\nnew-&gt;rootfs.mount = strdup(default_rootfs_mount);<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"%E5%90%84%E4%B8%AA%E5%8F%82%E6%95%B0%E8%AF%B4%E6%98%8E\"><\/span>\u5404\u4e2a\u53c2\u6570\u8bf4\u660e<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<h5><span class=\"ez-toc-section\" id=\"%E5%B7%A5%E7%A8%8B%E5%8F%82%E6%95%B0\"><\/span>\u5de5\u7a0b\u53c2\u6570<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<ul>\n<li><code>--with-config-path<\/code><br \/>\n\u6307\u5b9a\u914d\u7f6e\u6587\u4ef6\u7684\u6839\u76ee\u5f55<\/li>\n<\/ul>\n<h5><span class=\"ez-toc-section\" id=\"%E5%AE%B9%E5%99%A8%E5%8F%82%E6%95%B0\"><\/span>\u5bb9\u5668\u53c2\u6570<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<ul>\n<li><code>--with-rootfs-path<\/code><br \/>\n\u6307\u5b9a\u5bb9\u5668\u6839\u6587\u4ef6\u7cfb\u7edf\u7684\u6302\u8f7d\u76ee\u5f55<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"%E5%8E%9F%E7%90%86\"><\/span>\u539f\u7406<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"lxc%E8%BF%9B%E5%8C%96%E5%8E%86%E5%8F%B2\"><\/span>lxc\u8fdb\u5316\u5386\u53f2<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><a href=\"https:\/\/zhuanlan.zhihu.com\/p\/634176688\">https:\/\/zhuanlan.zhihu.com\/p\/634176688<\/a><\/p>\n<h4><span class=\"ez-toc-section\" id=\"Chroot%EF%BC%88%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%E5%B1%82%E6%AC%A1%E7%9A%84%E8%B5%84%E6%BA%90%E9%9A%94%E7%A6%BB%EF%BC%89\"><\/span>Chroot\uff08\u6587\u4ef6\u7cfb\u7edf\u5c42\u6b21\u7684\u8d44\u6e90\u9694\u79bb\uff09<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>Chroot \u662f\u4e00\u4e2a\u53ef\u4f9b User Process \u8c03\u7528\u7684 System Call \u63a5\u53e3\uff0c\u53ef\u4ee5\u8ba9\u4e00\u4e2a Process \u628a\u6307\u5b9a\u7684\u76ee\u5f55\u4f5c\u4e3a\u6839\u76ee\u5f55\uff08Root Directory\uff09\uff0c\u968f\u540e Process \u6240\u6709\u7684\u6587\u4ef6\u7cfb\u7edf\u64cd\u4f5c\u90fd\u53ea\u80fd\u5728\u8fd9\u4e2a\u6307\u5b9a\u76ee\u5f55\u4e2d\u8fdb\u884c\u3002\u6545\u79f0\u4e4b\u4e3a Change Root\u3002<\/p>\n<ul>\n<li>\n<p>chroot\uff0cpivot_root\u548cswitch_root \u533a\u522b\uff1a<br \/>\n<a href=\"https:\/\/blog.csdn.net\/u012385733\/article\/details\/102565591\">https:\/\/blog.csdn.net\/u012385733\/article\/details\/102565591<\/a><\/p>\n<\/li>\n<li>\n<p>pivot_root\u51fd\u6570\uff08\u6539\u53d8\u547d\u540d\u7a7a\u95f4\u4e0b\u8fdb\u7a0b\u7684\u6839\u6587\u4ef6\u7cfb\u7edf\uff09\uff1a<br \/>\n<a href=\"https:\/\/blog.csdn.net\/m0_62969222\/article\/details\/132039479\">https:\/\/blog.csdn.net\/m0_62969222\/article\/details\/132039479<\/a><br \/>\n<a href=\"https:\/\/blog.csdn.net\/liuyij3430448\/article\/details\/128283244\">https:\/\/blog.csdn.net\/liuyij3430448\/article\/details\/128283244<\/a><br \/>\n<a href=\"https:\/\/zhuanlan.zhihu.com\/p\/101096040\">https:\/\/zhuanlan.zhihu.com\/p\/101096040<\/a><\/p>\n<\/li>\n<\/ul>\n<p>1\uff09 pivot_root\u53c2\u6570\u8bf4\u660e<\/p>\n<pre><code class=\"language-bash\">1 new_root \u4e0e put_old \u5fc5\u987b\u662f\u6587\u4ef6\u5939\n2 new_root\u6587\u4ef6\u5939\u5fc5\u987b\u662f\u4e00\u4e2a\u6302\u8f7d\u70b9 \uff0c\u5e76\u4e14new_root\u6587\u4ef6\u5939\u91cc\u9762\u6709\u5b8c\u6574rootfs\u7684\u5404\u79cd\u6587\u4ef6\n3 new_root \u6587\u4ef6\u5939\u6302\u8f7d\u5e94\u8be5\u662f\u4e00\u4e2a\u4e0e\u4e3b\u673a\u4e0d\u540c\u7684name space\n4 put_old\u6587\u4ef6\u5939\u5fc5\u987b\u5728new_root\u6587\u4ef6\u5939\u5185<\/code><\/pre>\n<p>2\uff09\u5173\u4e8epivot_root(&quot;.&quot;,&quot;.&quot;)<br \/>\n\u907f\u514d\u4f7f\u7528\u4e34\u65f6\u76ee\u5f55\uff0c\u5c06\u5f53\u524d\u201c\/\u201d\u4f5c\u4e3arootfs\uff0c\u5c06\/proc\/self\/cwd\u4f5c\u4e3aput_old\uff0c\u4ece\u800c\u907f\u514d\u5fc5\u987b\u521b\u5efa\u5b50\u76ee\u5f55\uff0c\u4f46\u8fd9\u65f6\u9700\u8981\u5148unmount(&quot;.&quot;)\u518dchdir(&quot;\/&quot;)<\/p>\n<h3><span class=\"ez-toc-section\" id=\"lxc%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86\"><\/span>lxc\u57fa\u672c\u539f\u7406<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>LXC \u4e5f\u662f\u5229\u7528\u4e86 Linux \u5185\u6838\u7684 <strong>cgroup<\/strong> \u548c <strong>namespace<\/strong> \u7279\u6027\u6765\u5b9e\u73b0\u5bb9\u5668\u7684\u8d44\u6e90\u9694\u79bb\uff0cnamespace\u4e3b\u8d44\u6e90\u9694\u79bb\uff0ccgroup\u4e3b\u8d44\u6e90\u914d\u7f6e\u3002<\/p>\n<p><a href=\"https:\/\/www.jianshu.com\/p\/63fea471bc43?utm_campaign=maleskine&amp;utm_content=note&amp;utm_medium=seo_notes\">https:\/\/www.jianshu.com\/p\/63fea471bc43?utm_campaign=maleskine&amp;utm_content=note&amp;utm_medium=seo_notes<\/a> (**)<br \/>\n<a href=\"https:\/\/www.cnblogs.com\/frankltf\/p\/11681312.html\">https:\/\/www.cnblogs.com\/frankltf\/p\/11681312.html<\/a><br \/>\n<a href=\"https:\/\/wenku.baidu.com\/view\/ac711c68f28583d049649b6648d7c1c708a10b91.html?_wkts_=1714116127325&amp;bdQuery=lxc%E5%AE%9E%E7%8E%B0%E5%8E%9F%E7%90%86\">https:\/\/wenku.baidu.com\/view\/ac711c68f28583d049649b6648d7c1c708a10b91.html?<em>wkts<\/em>=1714116127325&amp;bdQuery=lxc%E5%AE%9E%E7%8E%B0%E5%8E%9F%E7%90%86<\/a> (\u521b\u5efa\u5bb9\u5668\u3001\u914d\u7f6e\u5bb9\u5668\u3001\u542f\u52a8\u5bb9\u5668\u3001\u7ba1\u7406\u5bb9\u5668)<br \/>\n<a href=\"https:\/\/www.51cto.com\/article\/636399.html\">https:\/\/www.51cto.com\/article\/636399.html<\/a> (\u4f9d\u8d56cgroup\u3001namespace\u7b49\u6280\u672f)<\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E6%8C%87%E4%BB%A4\"><\/span>\u6307\u4ee4<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><a href=\"https:\/\/blog.csdn.net\/yyymmmmyyy\/article\/details\/132695327\">https:\/\/blog.csdn.net\/yyymmmmyyy\/article\/details\/132695327<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"lxc%E7%8E%AF%E5%A2%83%E6%A3%80%E6%9F%A5\"><\/span>lxc\u73af\u5883\u68c0\u67e5<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><a href=\"https:\/\/www.cnblogs.com\/mic-chen\/p\/13409756.html\">https:\/\/www.cnblogs.com\/mic-chen\/p\/13409756.html<\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E5%8F%82%E6%95%B0%E8%AE%BE%E7%BD%AE\"><\/span>\u53c2\u6570\u8bbe\u7f6e<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<h4><span class=\"ez-toc-section\" id=\"%E6%97%A5%E5%BF%97%E8%AE%BE%E7%BD%AE\"><\/span>\u65e5\u5fd7\u8bbe\u7f6e<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>\u8bbe\u7f6e\u65e5\u5fd7\u8f93\u51fa\u4f4d\u7f6e\u548c\u8f93\u51fa\u7ea7\u522b\uff1a<code>--logfile .\/lxc.log --logpriority info<\/code><\/p>\n<h3><span class=\"ez-toc-section\" id=\"%E6%8C%87%E4%BB%A4%E9%9B%86\"><\/span>\u6307\u4ee4\u96c6<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>1.\u521b\u5efa\u865a\u62df\u673a<\/p>\n<pre><code class=\"language-bash\">ls -alh \/usr\/share\/lxc\/templates\/ #\u5217\u51fa\u5df2\u7ecf\u5b89\u88c5\u5230\u4f60\u7684\u7cfb\u7edf\u4e4b\u4e2d\u53ef\u7528\u7684LXC\u6a21\u677f\u5bb9\u5668\nlxc-create -n [container-name] -t centos #\u521b\u5efa\u865a\u62df\u673a<\/code><\/pre>\n<p>2.\u542f\u52a8\u865a\u62df\u673a<\/p>\n<p>\u540e\u53f0\u542f\u52a8<br \/>\n<code>lxc-start -n [container-name] -d<\/code><br \/>\n\u524d\u53f0\u542f\u52a8<br \/>\n<code>lxc-start -n [container-name]<\/code><br \/>\n3.\u505c\u6b62\u865a\u62df\u673a<br \/>\n<code>lxc-stop -n [container-name]<\/code><br \/>\n4.\u5728\u5bbf\u4e3b\u673a\u4e2d\u5bf9\u865a\u62df\u673a\u6267\u884c\u547d\u4ee4<br \/>\n<code>lxc-attach --name [container-name] -- passwd<\/code>\u6216\u8005<code>lxc-attach --n [container-name] -- cmd<\/code><\/p>\n<p>5.\u5220\u9664\u865a\u62df\u673a<\/p>\n<h1><span class=\"ez-toc-section\" id=\"%E5%85%88%E5%81%9C%E6%8E%89%E5%AE%B9%E5%99%A8%E7%84%B6%E5%90%8E%E8%BF%9B%E8%A1%8C%E5%88%A0%E9%99%A4\"><\/span>\u5148\u505c\u6389\u5bb9\u5668\u7136\u540e\u8fdb\u884c\u5220\u9664<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<pre><code class=\"language-bash\">lxc-stop --name [container-name]\nlxc-destroy --name [container-name]<\/code><\/pre>\n<p>6.\u9650\u5236\u865a\u62df\u673a\u8d44\u6e90\u4f7f\u7528<\/p>\n<pre><code class=\"language-bash\">#CPU\n#\u6307\u5b9a\u4e00\u4e2aCPU\u6838\u5fc3\nlxc-cgroup -n [container-name] cpuset.cpus 0\n#\u6307\u5b9a\u591a\u4e2aCPU\u6838\u5fc3\nlxc-cgroup -n [container-name] cpuset.cpus 0-1\n#\u6307\u5b9aCPU\u6700\u9ad8\u4f7f\u7528\u7387\nlxc-cgroup -n [container-name] cpu.cfs_quota_us [value]\n#\u5185\u5b58\n#\u6700\u5927\u4f7f\u7528\u5185\u5b58\nlxc-cgroup -n [container-name] memory.limit_in_bytes [value]<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"hook\"><\/span>hook<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><a href=\"https:\/\/www.cnblogs.com\/utopia007\/p\/12603838.html\">https:\/\/www.cnblogs.com\/utopia007\/p\/12603838.html<\/a><\/p>\n<button class=\"simplefavorite-button\" data-postid=\"9903\" data-siteid=\"1\" data-groupid=\"1\" data-favoritecount=\"0\" style=\"\">\u6536\u85cf <i class=\"sf-icon-star-empty\"><\/i><\/button>","protected":false},"excerpt":{"rendered":"<p>http:\/\/www.360doc.com\/content\/22\/0609\/09\/474846_10 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[791],"tags":[],"_links":{"self":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/9903"}],"collection":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9903"}],"version-history":[{"count":34,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/9903\/revisions"}],"predecessor-version":[{"id":14303,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/9903\/revisions\/14303"}],"wp:attachment":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9903"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9903"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9903"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}