{"id":678,"date":"2024-04-04T23:30:39","date_gmt":"2024-04-04T15:30:39","guid":{"rendered":"https:\/\/www.db2go.net\/?p=678"},"modified":"2024-04-05T00:58:06","modified_gmt":"2024-04-04T16:58:06","slug":"%e5%b0%86wsl%e5%ae%89%e8%a3%85%e7%9a%84%e5%8f%91%e8%a1%8c%e7%89%88%e8%bf%81%e7%a7%bb%e5%88%b0%e5%85%b6%e4%bb%96%e7%9b%ae%e5%bd%95","status":"publish","type":"post","link":"https:\/\/www.db2go.net\/?p=678","title":{"rendered":"\u5c06WSL\u5b89\u88c5\u7684\u53d1\u884c\u7248\u8fc1\u79fb\u5230\u5176\u4ed6\u76ee\u5f55"},"content":{"rendered":"<p>WSL \u9ed8\u8ba4\u5b89\u88c5\u5728 C \u76d8\uff0c\u968f\u7740\u7cfb\u7edf\u7684\u4f7f\u7528\uff0c\u4f1a\u5360\u7528\u6211\u4eec C \u76d8\u7684\u7a7a\u95f4\uff0c\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u5c06\u5176\u8fc1\u79fb\u653e\u5230\u5176\u4ed6\u76d8\u53bb\u3002<\/p>\n<ol>\n<li>\u67e5\u770b WSL \u53d1\u884c\u7248\u672c<br \/>\n\u5728 Windows PowerShell \u4e2d\u8f93\u5165\u547d\u4ee4:<\/p>\n<pre><code class=\"language-shell line-numbers\">wsl -l --all -v\n<\/code><\/pre>\n<\/li>\n<li>\u5bfc\u51fa\u5206\u53d1\u7248\u4e3a tar \u6587\u4ef6\u5230 D \u76d8\n<pre><code class=\"language-shell line-numbers\">wsl --export Ubuntu-20.04 d:\\wsl-ubuntu20.04.tar\n<\/code><\/pre>\n<p>\uff08Ubuntu-20.04 \u4fee\u6539\u6210\u4f60\u73b0\u5728\u7684\u53d1\u884c\u7248\u540d\u79f0\uff09<\/p>\n<\/li>\n<li>\n<p>\u6ce8\u9500\u5f53\u524d\u5206\u53d1\u7248<\/p>\n<pre><code class=\"language-shell line-numbers\">wsl --unregister Ubuntu-20.04\n<\/code><\/pre>\n<p>\uff08Ubuntu-20.04 \u4fee\u6539\u6210\u4f60\u73b0\u5728\u7684\u53d1\u884c\u7248\u540d\u79f0\uff09<\/p>\n<\/li>\n<li>\n<p>\u91cd\u65b0\u5bfc\u5165\u5e76\u5b89\u88c5 WSL \u5728 D:\\wsl-ubuntu20.04\uff08\u53ef\u4ee5\u4fee\u6539\u6210\u4f60\u81ea\u5df1\u60f3\u8981\u7684\u76ee\u5f55\uff09<\/p>\n<pre><code class=\"language-shell line-numbers\">wsl --import Ubuntu-20.04 d:\\wsl-ubuntu20.04 d:\\wsl-ubuntu20.04.tar --version 2\n<\/code><\/pre>\n<\/li>\n<li>\u8bbe\u7f6e\u9ed8\u8ba4\u767b\u5f55\u7528\u6237\u4e3a\u5b89\u88c5\u65f6\u7528\u6237\u540d\n<pre><code class=\"language-shell line-numbers\">ubuntu2004 config --default-user Username\n<\/code><\/pre>\n<\/li>\n<li>\u5220\u9664 tar \u6587\u4ef6\uff08\u53ef\u9009\uff09\n<pre><code class=\"language-shell line-numbers\">del d:\\wsl-ubuntu20.04.tar\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<h2>\u793a\u4f8b<\/h2>\n<pre><code class=\"language-shell line-numbers\">C:\\Users\\yourname&gt; wsl -l -v\n  NAME            STATE           VERSION\n* Ubuntu-20.04    Running         2\nC:\\Users\\yourname&gt;\nC:\\Users\\yourname&gt; wsl --shutdown\nC:\\Users\\yourname&gt;\nC:\\Users\\yourname&gt; wsl -l -v\n  NAME            STATE           VERSION\n* Ubuntu-20.04    Stopped         2\nC:\\Users\\yourname&gt; wsl --export Ubuntu-20.04 d:\\wslworkspace\\ubuntu.tar\nC:\\Users\\yourname&gt;\nC:\\Users\\yourname&gt; wsl --unregister Ubuntu-20.04\n\u6b63\u5728\u6ce8\u9500...\nC:\\Users\\yourname&gt;\n\nC:\\Users\\yourname&gt;  wsl --import Ubuntu-20.04 D:\\wslworkspace\\ubuntu20.04\\ d:\\wslworkspace\\ubuntu.tar --version 2\nC:\\Users\\yourname&gt;\n\nC:\\Users\\yourname&gt; wsl -l -v\n  NAME            STATE           VERSION\n* Ubuntu-20.04    Stopped         2\nC:\\Users\\yourname&gt;\nC:\\Users\\yourname&gt; ubuntu2004.exe config --default-user sure\nC:\\Users\\yourname&gt; wsl -d  Ubuntu-20.04\n\u9002\u7528\u4e8e Linux \u7684 Windows \u5b50\u7cfb\u7edf\u73b0\u5df2\u5728 Microsoft Store \u4e2d\u53ef\u7528!\n\u4f60\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c\u201cwsl.exe --update\u201d\u6216\u901a\u8fc7\u8bbf\u95ee https:\/\/aka.ms\/wslstorepage \u8fdb\u884c\u5347\u7ea7\n\u4ece Microsoft Store \u5b89\u88c5 WSL \u5c06\u53ef\u4ee5\u66f4\u5feb\u5730\u83b7\u53d6\u6700\u65b0\u7684 WSL \u66f4\u65b0\u3002\n\u6709\u5173\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u8bbf\u95ee https:\/\/aka.ms\/wslstoreinfo\n\nWelcome to Ubuntu 20.04.6 LTS (GNU\/Linux 5.10.16.3-microsoft-standard-WSL2 x86_64)\n\n * Documentation:  https:\/\/help.ubuntu.com\n * Management:     https:\/\/landscape.canonical.com\n * Support:        https:\/\/ubuntu.com\/pro\n\n  System load:  0.0                 Processes:             43\n  Usage of \/:   48.8% of 250.98GB   Users logged in:       0\n  Memory usage: 1%                  IPv4 address for eth0: 172.29.68.82\n  Swap usage:   0%\n\n * Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s\n   just raised the bar for easy, resilient and secure K8s cluster deployment.\n\n   https:\/\/ubuntu.com\/engage\/secure-kubernetes-at-the-edge\n\nExpanded Security Maintenance for Applications is not enabled.\n\n2 updates can be applied immediately.\nTo see these additional updates run: apt list --upgradable\n\nEnable ESM Apto receive additional future security updates.\nSee https:\/\/ubuntu.com\/esm or run: sudo pro status\n<\/code><\/pre>\n<h2>\u53d1\u73b0\u5728\u5df2\u7ecf\u5b89\u88c5\u7684\u5e94\u7528\uff0c\u53ef\u4ee5\u76f4\u63a5\u8fc1\u79fb<\/h2>\n<p>\u53d1\u73b0\u4e2a\u65b0\u5927\u9646\uff0c\u5df2\u7ecf\u5b89\u88c5\u7684\u5e94\u7528\uff0c\u53ef\u4ee5\u76f4\u63a5\u8fc1\u79fb\u3002\u4f46\u4f1a\u5e26\u6765\u4ec0\u4e48\u5f71\u54cd\uff0c\u9700\u8981\u7814\u7a76\u4e00\u4e0b\u3002<\/p>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/www.db2go.net\/wp-content\/uploads\/2024\/04\/wp_editor_md_a66614efa54d103b3168a93480b2be24.jpg\"><img decoding=\"async\" src=\"https:\/\/www.db2go.net\/wp-content\/uploads\/2024\/04\/wp_editor_md_a66614efa54d103b3168a93480b2be24.jpg\" alt=\"\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>WSL \u9ed8\u8ba4\u5b89\u88c5\u5728 C \u76d8\uff0c\u968f\u7740\u7cfb\u7edf\u7684\u4f7f\u7528\uff0c\u4f1a\u5360\u7528\u6211\u4eec C \u76d8\u7684\u7a7a\u95f4\uff0c\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u5c06\u5176\u8fc1\u79fb\u653e\u5230\u5176\u4ed6\u76d8\u53bb\u3002 \u67e5\u770b&hellip;<\/p>\n <a href=\"https:\/\/www.db2go.net\/?p=678\" title=\"\u5c06WSL\u5b89\u88c5\u7684\u53d1\u884c\u7248\u8fc1\u79fb\u5230\u5176\u4ed6\u76ee\u5f55\" class=\"entry-more-link\"><span>Read More<\/span> <span class=\"screen-reader-text\">\u5c06WSL\u5b89\u88c5\u7684\u53d1\u884c\u7248\u8fc1\u79fb\u5230\u5176\u4ed6\u76ee\u5f55<\/span><\/a>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[15],"tags":[],"class_list":["entry","author-suredandan","post-678","post","type-post","status-publish","format-standard","category-15"],"views":4548,"_links":{"self":[{"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/posts\/678","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.db2go.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=678"}],"version-history":[{"count":4,"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/posts\/678\/revisions"}],"predecessor-version":[{"id":682,"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/posts\/678\/revisions\/682"}],"wp:attachment":[{"href":"https:\/\/www.db2go.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=678"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.db2go.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=678"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.db2go.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}