import{_ as i,c as a,a as n,o as e}from"./app-COnnofor.js";const l={};function h(t,s){return e(),a("div",null,[...s[0]||(s[0]=[n(`<p>嗨呀～让我们在 Windows10 专业版上部署 WSL2 并启动 ubuntu 20.04 虚拟机吧～</p><p>最好使用 Windows10 专业版，并且在物理机上部署呢，在虚拟机上部署的话可能会有小麻烦，所以不太推荐啦~</p><h2 id="windows10-镜像" tabindex="-1"><a class="header-anchor" href="#windows10-镜像"><span>Windows10 镜像</span></a></h2><p>大家好呀～今天要教大家如何在Windows10上部署WSL2并启动ubuntu虚拟机哦～</p><p>首先呢，我们需要准备一个Windows10的镜像文件～虽然Microsoft官方有提供，不过很容易下载失败呢，所以建议大家去<a href="https://msdn.itellyou.cn/" target="_blank" rel="noopener noreferrer">MSDN</a>下载会更稳定哦～</p><p>在MSDN官网找到「操作系统」→「Window10」→「Windows 10 (Multiple Editions) (x64)」这个版本，它包含了专业版呢～要注意哦，WSL2只支持专业版、企业版或教育版，不支持家庭版呢，所以建议大家直接安装专业版会更方便～</p><h2 id="启用wsl2和虚拟机平台" tabindex="-1"><a class="header-anchor" href="#启用wsl2和虚拟机平台"><span>启用WSL2和虚拟机平台</span></a></h2><p>接下来，我们需要启用WSL2和虚拟机平台的功能哦～首先以管理员身份打开PowerShell，然后依次运行下面的命令：</p><div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#393a34;--shiki-dark:#dbd7caee;--shiki-light-bg:#ffffff;--shiki-dark-bg:#121212;"><pre class="shiki shiki-themes vitesse-light vitesse-dark vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#A0ADA0;--shiki-dark:#758575DD;"># 启用 WSL 功能</span></span>
<span class="line"><span style="--shiki-light:#998418;--shiki-dark:#B8A965;">dism.exe</span><span style="--shiki-light:#999999;--shiki-dark:#666666;"> /</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">online </span><span style="--shiki-light:#999999;--shiki-dark:#666666;">/</span><span style="--shiki-light:#998418;--shiki-dark:#B8A965;">enable-feature</span><span style="--shiki-light:#999999;--shiki-dark:#666666;"> /</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">featurename:Microsoft</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">-</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">Windows</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">-</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">Subsystem</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">-</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">Linux </span><span style="--shiki-light:#999999;--shiki-dark:#666666;">/</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">all </span><span style="--shiki-light:#999999;--shiki-dark:#666666;">/</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">norestart</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#A0ADA0;--shiki-dark:#758575DD;"># 启用虚拟机平台（WSL2 必需）</span></span>
<span class="line"><span style="--shiki-light:#998418;--shiki-dark:#B8A965;">dism.exe</span><span style="--shiki-light:#999999;--shiki-dark:#666666;"> /</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">online </span><span style="--shiki-light:#999999;--shiki-dark:#666666;">/</span><span style="--shiki-light:#998418;--shiki-dark:#B8A965;">enable-feature</span><span style="--shiki-light:#999999;--shiki-dark:#666666;"> /</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">featurename:VirtualMachinePlatform </span><span style="--shiki-light:#999999;--shiki-dark:#666666;">/</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">all </span><span style="--shiki-light:#999999;--shiki-dark:#666666;">/</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">norestart</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>运行完成后，记得要重启电脑哦～重启之后，我们还要把WSL2设置为默认版本呢：</p><div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#393a34;--shiki-dark:#dbd7caee;--shiki-light-bg:#ffffff;--shiki-dark-bg:#121212;"><pre class="shiki shiki-themes vitesse-light vitesse-dark vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#A0ADA0;--shiki-dark:#758575DD;"># 设置 WSL2 为默认版本</span></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">wsl </span><span style="--shiki-light:#999999;--shiki-dark:#666666;">--</span><span style="--shiki-light:#998418;--shiki-dark:#B8A965;">set-default</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">-</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">version </span><span style="--shiki-light:#2F798A;--shiki-dark:#4C9A91;">2</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="在-wsl2-中安装-ubuntu-20-04-lts-虚拟机" tabindex="-1"><a class="header-anchor" href="#在-wsl2-中安装-ubuntu-20-04-lts-虚拟机"><span>在 WSL2 中安装 ubuntu 20.04 LTS 虚拟机</span></a></h2><p>现在到了安装Ubuntu虚拟机的环节啦～还是以管理员身份打开PowerShell，然后依次运行这些命令：</p><div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#393a34;--shiki-dark:#dbd7caee;--shiki-light-bg:#ffffff;--shiki-dark-bg:#121212;"><pre class="shiki shiki-themes vitesse-light vitesse-dark vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#A0ADA0;--shiki-dark:#758575DD;"># 查看可用的 Ubuntu 版本</span></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">wsl </span><span style="--shiki-light:#999999;--shiki-dark:#666666;">--</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">list </span><span style="--shiki-light:#999999;--shiki-dark:#666666;">--</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">online</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#A0ADA0;--shiki-dark:#758575DD;"># 安装 Ubuntu 20.04 虚拟机</span></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">wsl </span><span style="--shiki-light:#999999;--shiki-dark:#666666;">--</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">install </span><span style="--shiki-light:#999999;--shiki-dark:#666666;">-</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">d Ubuntu</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">-</span><span style="--shiki-light:#2F798A;--shiki-dark:#4C9A91;">20.04</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>安装过程大概是这样的哦～让我们一起来看看：</p><div class="language-powershell line-numbers-mode has-collapsed-lines collapsed" data-highlighter="shiki" data-ext="powershell" style="--vp-collapsed-lines:15;--shiki-light:#393a34;--shiki-dark:#dbd7caee;--shiki-light-bg:#ffffff;--shiki-dark-bg:#121212;"><pre class="shiki shiki-themes vitesse-light vitesse-dark vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">wsl: 使用旧分发注册。请考虑改用基于 tar 的分发。</span></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">正在下载: Ubuntu </span><span style="--shiki-light:#2F798A;--shiki-dark:#4C9A91;">20.04</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;"> LTS</span></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">Ubuntu </span><span style="--shiki-light:#2F798A;--shiki-dark:#4C9A91;">20.04</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;"> LTS 已下载。</span></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">已成功安装分发。可以通过 </span><span style="--shiki-light:#B5695977;--shiki-dark:#C98A7D77;">“</span><span style="--shiki-light:#B56959;--shiki-dark:#C98A7D;">wsl.exe -d Ubuntu 20.04 LTS</span><span style="--shiki-light:#B5695977;--shiki-dark:#C98A7D77;">”</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;"> 启动它</span></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">正在启动 Ubuntu </span><span style="--shiki-light:#2F798A;--shiki-dark:#4C9A91;">20.04</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;"> LTS...</span></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">Installing</span><span style="--shiki-light:#AB5959;--shiki-dark:#CB7676;">,</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;"> this may take a few minutes...</span></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">Please create a </span><span style="--shiki-light:#1E754F;--shiki-dark:#4D9375;">default</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;"> UNIX user account. The username does not need to match your Windows username.</span></span>
<span class="line"><span style="--shiki-light:#1E754F;--shiki-dark:#4D9375;">For</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;"> more information visit: https:</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">//</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">aka.ms</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">/</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">wslusers</span></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">Enter new UNIX username: simeng</span></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">New password:</span></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">Retype new password:</span></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">passwd: password updated successfully</span></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">操作成功完成。</span></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">wsl: Failed to start the systemd user session </span><span style="--shiki-light:#1E754F;--shiki-dark:#4D9375;">for</span><span style="--shiki-light:#B5695977;--shiki-dark:#C98A7D77;"> &#39;</span><span style="--shiki-light:#B56959;--shiki-dark:#C98A7D;">root</span><span style="--shiki-light:#B5695977;--shiki-dark:#C98A7D77;">&#39;</span><span style="--shiki-light:#AB5959;--shiki-dark:#CB7676;">.</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;"> See journalctl </span><span style="--shiki-light:#1E754F;--shiki-dark:#4D9375;">for</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;"> more details.</span></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">Installation successful</span><span style="--shiki-light:#AB5959;--shiki-dark:#CB7676;">!</span></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">wsl: Failed to start the systemd user session </span><span style="--shiki-light:#1E754F;--shiki-dark:#4D9375;">for</span><span style="--shiki-light:#B5695977;--shiki-dark:#C98A7D77;"> &#39;</span><span style="--shiki-light:#B56959;--shiki-dark:#C98A7D;">simeng</span><span style="--shiki-light:#B5695977;--shiki-dark:#C98A7D77;">&#39;</span><span style="--shiki-light:#AB5959;--shiki-dark:#CB7676;">.</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;"> See journalctl </span><span style="--shiki-light:#1E754F;--shiki-dark:#4D9375;">for</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;"> more details.</span></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">To run a command as administrator </span><span style="--shiki-light:#999999;--shiki-dark:#666666;">(</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">user </span><span style="--shiki-light:#B5695977;--shiki-dark:#C98A7D77;">&quot;</span><span style="--shiki-light:#B56959;--shiki-dark:#C98A7D;">root</span><span style="--shiki-light:#B5695977;--shiki-dark:#C98A7D77;">&quot;</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">)</span><span style="--shiki-light:#AB5959;--shiki-dark:#CB7676;">,</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;"> use </span><span style="--shiki-light:#B5695977;--shiki-dark:#C98A7D77;">&quot;</span><span style="--shiki-light:#B56959;--shiki-dark:#C98A7D;">sudo &lt;command&gt;</span><span style="--shiki-light:#B5695977;--shiki-dark:#C98A7D77;">&quot;</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">.</span></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">See </span><span style="--shiki-light:#B5695977;--shiki-dark:#C98A7D77;">&quot;</span><span style="--shiki-light:#B56959;--shiki-dark:#C98A7D;">man sudo_root</span><span style="--shiki-light:#B5695977;--shiki-dark:#C98A7D77;">&quot;</span><span style="--shiki-light:#1E754F;--shiki-dark:#4D9375;"> for</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;"> details.</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">Welcome to Ubuntu </span><span style="--shiki-light:#2F798A;--shiki-dark:#4C9A91;">20.04</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">.</span><span style="--shiki-light:#2F798A;--shiki-dark:#4C9A91;">6</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;"> LTS </span><span style="--shiki-light:#999999;--shiki-dark:#666666;">(</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">GNU</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">/</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">Linux </span><span style="--shiki-light:#2F798A;--shiki-dark:#4C9A91;">6.6</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">.</span><span style="--shiki-light:#2F798A;--shiki-dark:#4C9A91;">87.2</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">-</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">microsoft</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">-</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">standard</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">-</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">WSL2 x86_64</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">)</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#999999;--shiki-dark:#666666;"> *</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;"> Documentation:  https:</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">//</span><span style="--shiki-light:#998418;--shiki-dark:#B8A965;">help.ubuntu.com</span></span>
<span class="line"><span style="--shiki-light:#999999;--shiki-dark:#666666;"> *</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;"> Management:     https:</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">//</span><span style="--shiki-light:#998418;--shiki-dark:#B8A965;">landscape.canonical.com</span></span>
<span class="line"><span style="--shiki-light:#999999;--shiki-dark:#666666;"> *</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;"> Support:        https:</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">//</span><span style="--shiki-light:#998418;--shiki-dark:#B8A965;">ubuntu.com</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">/</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">advantage</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">  System information as of Tue Sep </span><span style="--shiki-light:#2F798A;--shiki-dark:#4C9A91;">30</span><span style="--shiki-light:#2F798A;--shiki-dark:#4C9A91;"> 14</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">:</span><span style="--shiki-light:#2F798A;--shiki-dark:#4C9A91;">27</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">:</span><span style="--shiki-light:#2F798A;--shiki-dark:#4C9A91;">51</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;"> CST </span><span style="--shiki-light:#2F798A;--shiki-dark:#4C9A91;">2025</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">  System load:  </span><span style="--shiki-light:#2F798A;--shiki-dark:#4C9A91;">0.48</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">                Processes:             </span><span style="--shiki-light:#2F798A;--shiki-dark:#4C9A91;">74</span></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">  Usage of </span><span style="--shiki-light:#999999;--shiki-dark:#666666;">/</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">:   </span><span style="--shiki-light:#2F798A;--shiki-dark:#4C9A91;">0.1</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">%</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;"> of </span><span style="--shiki-light:#2F798A;--shiki-dark:#4C9A91;">1006.85</span><span style="--shiki-light:#1E754F;--shiki-dark:#4D9375;">GB</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">   Users logged </span><span style="--shiki-light:#1E754F;--shiki-dark:#4D9375;">in</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">:       </span><span style="--shiki-light:#2F798A;--shiki-dark:#4C9A91;">1</span></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">  Memory usage: </span><span style="--shiki-light:#2F798A;--shiki-dark:#4C9A91;">7</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">%</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">                  IPv4 address </span><span style="--shiki-light:#1E754F;--shiki-dark:#4D9375;">for</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;"> eth0: </span><span style="--shiki-light:#2F798A;--shiki-dark:#4C9A91;">172.31</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">.</span><span style="--shiki-light:#2F798A;--shiki-dark:#4C9A91;">237.99</span></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">  Swap usage:   </span><span style="--shiki-light:#2F798A;--shiki-dark:#4C9A91;">0</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">%</span></span>
<span class="line"></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">Expanded Security Maintenance </span><span style="--shiki-light:#1E754F;--shiki-dark:#4D9375;">for</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;"> Applications is not enabled.</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#2F798A;--shiki-dark:#4C9A91;">0</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;"> updates can be applied immediately.</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">Enable ESM Apps to receive additional future security updates.</span></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">See https:</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">//</span><span style="--shiki-light:#998418;--shiki-dark:#B8A965;">ubuntu.com</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">/</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">esm or run: sudo pro status</span></span>
<span class="line"></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">The list of available updates is more than a week old.</span></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">To check </span><span style="--shiki-light:#1E754F;--shiki-dark:#4D9375;">for</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;"> new updates run: sudo apt update</span></span>
<span class="line"></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">This message is shown once a day. To disable it please create the</span></span>
<span class="line"><span style="--shiki-light:#999999;--shiki-dark:#666666;">/</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">home</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">/</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">simeng</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">/</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">.hushlogin file.</span></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">simeng</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">@</span><span style="--shiki-light:#B07D48;--shiki-dark:#BD976A;">localhost</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">:~$</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div><div class="collapsed-lines"></div></div><p>这样我们就成功安装好Ubuntu虚拟机啦，可以开始使用了哦～</p><h3 id="安装过程中可能会出现的错误" tabindex="-1"><a class="header-anchor" href="#安装过程中可能会出现的错误"><span>安装过程中可能会出现的错误</span></a></h3><p>在安装过程中，可能会遇到一些小问题呢～不过不用担心，已经帮大家准备好了解决方案哦～</p><h4 id="错误码-0x800701bc-缺少更新包" tabindex="-1"><a class="header-anchor" href="#错误码-0x800701bc-缺少更新包"><span>错误码 0x800701bc 缺少更新包</span></a></h4><p>如果看到这样的错误信息：</p><div class="language-txt line-numbers-mode" data-highlighter="shiki" data-ext="txt" style="--shiki-light:#393a34;--shiki-dark:#dbd7caee;--shiki-light-bg:#ffffff;--shiki-dark-bg:#121212;"><pre class="shiki shiki-themes vitesse-light vitesse-dark vp-code"><code class="language-txt"><span class="line"><span>Installing, this may take a few minutes...</span></span>
<span class="line"><span>WslRegisterDistribution failed with error: 0x800701bc</span></span>
<span class="line"><span>Error: 0x800701bc WSL 2 ?????????????????? https://aka.ms/wsl2kernel</span></span>
<span class="line"><span></span></span>
<span class="line"><span>Press any key to continue...</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>这说明系统缺少WSL2所需的Linux内核更新包哦～这时候我们可以打开微软官网的<a href="https://learn.microsoft.com/zh-cn/windows/wsl/install-manual#step-4---download-the-linux-kernel-update-package" target="_blank" rel="noopener noreferrer">下载 Linux 内核更新包</a>页面，下载最新的包安装就可以解决啦～</p><h4 id="错误码-0x80370102-虚拟化技术没有开启" tabindex="-1"><a class="header-anchor" href="#错误码-0x80370102-虚拟化技术没有开启"><span>错误码 0x80370102 虚拟化技术没有开启</span></a></h4><p>如果遇到这个错误，可能是因为虚拟化技术没有开启哦～如果是在真实机上操作的话，需要进入BIOS开启虚拟化技术呢～开启之后，可以在任务管理器 -&gt; 性能 -&gt; CPU 的详情页面中，看到下方的虚拟化状态显示为「已启用」哦～</p><p><img src="https://image.simengweb.com/blog/technology/20250930140716_251_27.png" alt="虚拟化技术启用"></p><p>如果是在虚拟机中操作的话，就需要启用嵌套虚拟化技术啦～以VMware为例：</p><p>先关闭虚拟机，然后找到虚拟机的.vmx配置文件（通常在虚拟机目录下），在文件末尾添加一行：<code>vhv.enable = &quot;TRUE&quot;</code></p><p>保存之后再启动虚拟机就可以啦～如果还是失败的话，建议尝试换用WSL1，或者使用Hyper-V来部署Windows10虚拟机哦～</p><h2 id="通过-wsl2-操作-ubuntu-20-04-lts-虚拟机" tabindex="-1"><a class="header-anchor" href="#通过-wsl2-操作-ubuntu-20-04-lts-虚拟机"><span>通过 WSL2 操作 ubuntu 20.04 LTS 虚拟机</span></a></h2><p>安装完成后，我们该如何操作Ubuntu虚拟机呢？很简单哦～以管理员身份打开PowerShell，然后运行这个命令查看已安装的虚拟机：</p><div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#393a34;--shiki-dark:#dbd7caee;--shiki-light-bg:#ffffff;--shiki-dark-bg:#121212;"><pre class="shiki shiki-themes vitesse-light vitesse-dark vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#A0ADA0;--shiki-dark:#758575DD;"># 查看已安装的虚拟机</span></span>
<span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">wsl </span><span style="--shiki-light:#999999;--shiki-dark:#666666;">-</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">l </span><span style="--shiki-light:#999999;--shiki-dark:#666666;">-</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">v</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div><div class="line-number"></div></div></div><p>如果前面的步骤都正确的话，这里应该可以看到一个Ubuntu-20.04的虚拟机啦～</p><p>另外，在文件资源管理器中，会多出一个Linux文件夹，里面有一个Ubuntu-20.04文件夹，这就是虚拟机的根目录哦～</p><p>想要启动并进入Ubuntu虚拟机的话，可以运行这个命令：</p><div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#393a34;--shiki-dark:#dbd7caee;--shiki-light-bg:#ffffff;--shiki-dark-bg:#121212;"><pre class="shiki shiki-themes vitesse-light vitesse-dark vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">wsl </span><span style="--shiki-light:#999999;--shiki-dark:#666666;">-</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">d Ubuntu</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">-</span><span style="--shiki-light:#2F798A;--shiki-dark:#4C9A91;">20.04</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div><p>如果直接退出终端或者关闭窗口，虚拟机实例就会进入挂起状态，下次需要重新启动才能继续使用哦～当然，也可以通过指令强制终止虚拟机：</p><div class="language-powershell line-numbers-mode" data-highlighter="shiki" data-ext="powershell" style="--shiki-light:#393a34;--shiki-dark:#dbd7caee;--shiki-light-bg:#ffffff;--shiki-dark-bg:#121212;"><pre class="shiki shiki-themes vitesse-light vitesse-dark vp-code"><code class="language-powershell"><span class="line"><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">wsl </span><span style="--shiki-light:#999999;--shiki-dark:#666666;">--</span><span style="--shiki-light:#393A34;--shiki-dark:#DBD7CAEE;">terminate Ubuntu</span><span style="--shiki-light:#999999;--shiki-dark:#666666;">-</span><span style="--shiki-light:#2F798A;--shiki-dark:#4C9A91;">20.04</span></span></code></pre><div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0;"><div class="line-number"></div></div></div><h2 id="通过-vs-code-开发" tabindex="-1"><a class="header-anchor" href="#通过-vs-code-开发"><span>通过 VS Code 开发</span></a></h2><p>接下来，我们还可以通过VS Code来进行开发哦～不过需要先安装一些扩展呢：&#39;Remote - SSH&#39;和&#39;WSL&#39;</p><p>安装好扩展后，在VS Code左侧打开远程资源管理器，就可以看到Ubuntu20.04虚拟机啦～直接点击连接就可以了哦～不过第一次连接可能需要启动一下虚拟机，会有点慢呢，耐心等待一下吧～ <img src="https://image.simengweb.com/blog/technology/20250930144329_252_27.png" alt="连接 WSL2 虚拟机"> 连接成功之后，就可以愉快地进行开发啦～是不是很简单呢～</p>`,41)])])}const k=i(l,[["render",h]]),d=JSON.parse('{"path":"/article/deploying-wsl2-on-windows-10/","title":"在 Windows10 上部署 WSL2 并启动 ubuntu 虚拟机","lang":"zh-CN","frontmatter":{"title":"在 Windows10 上部署 WSL2 并启动 ubuntu 虚拟机","createTime":"2025/09/29 07:13:17","cover":"https://image.simengweb.com/elysia_cover_image/1pK7sI441p7x25YV.jpg","coverStyle":{"layout":"right"},"permalink":"/article/deploying-wsl2-on-windows-10/","description":"嗨呀～让我们在 Windows10 专业版上部署 WSL2 并启动 ubuntu 20.04 虚拟机吧～ 最好使用 Windows10 专业版，并且在物理机上部署呢，在虚拟机上部署的话可能会有小麻烦，所以不太推荐啦~ Windows10 镜像 大家好呀～今天要教大家如何在Windows10上部署WSL2并启动ubuntu虚拟机哦～ 首先呢，我们需要准备...","head":[["script",{"type":"application/ld+json"},"{\\"@context\\":\\"https://schema.org\\",\\"@type\\":\\"Article\\",\\"headline\\":\\"在 Windows10 上部署 WSL2 并启动 ubuntu 虚拟机\\",\\"image\\":[\\"https://image.simengweb.com/blog/technology/20250930140716_251_27.png\\",\\"https://image.simengweb.com/blog/technology/20250930144329_252_27.png\\"],\\"dateModified\\":\\"2025-10-02T07:56:20.000Z\\",\\"author\\":[]}"],["meta",{"property":"og:url","content":"https://notes.simengweb.com/article/deploying-wsl2-on-windows-10/"}],["meta",{"property":"og:site_name","content":"仲夏夜之梦"}],["meta",{"property":"og:title","content":"在 Windows10 上部署 WSL2 并启动 ubuntu 虚拟机"}],["meta",{"property":"og:description","content":"嗨呀～让我们在 Windows10 专业版上部署 WSL2 并启动 ubuntu 20.04 虚拟机吧～ 最好使用 Windows10 专业版，并且在物理机上部署呢，在虚拟机上部署的话可能会有小麻烦，所以不太推荐啦~ Windows10 镜像 大家好呀～今天要教大家如何在Windows10上部署WSL2并启动ubuntu虚拟机哦～ 首先呢，我们需要准备..."}],["meta",{"property":"og:type","content":"article"}],["meta",{"property":"og:image","content":"https://image.simengweb.com/elysia_cover_image/1pK7sI441p7x25YV.jpg"}],["meta",{"property":"og:locale","content":"zh-CN"}],["meta",{"property":"og:updated_time","content":"2025-10-02T07:56:20.000Z"}],["meta",{"name":"twitter:card","content":"summary_large_image"}],["meta",{"name":"twitter:image:src","content":"https://image.simengweb.com/elysia_cover_image/1pK7sI441p7x25YV.jpg"}],["meta",{"name":"twitter:image:alt","content":"在 Windows10 上部署 WSL2 并启动 ubuntu 虚拟机"}],["meta",{"property":"article:modified_time","content":"2025-10-02T07:56:20.000Z"}]]},"readingTime":{"minutes":5.1,"words":1531},"git":{"createdTime":1759149599000,"updatedTime":1759391780000,"contributors":[{"name":"si-meng-spec","username":"si-meng-spec","email":"simeng@simengweb.com","commits":3,"avatar":"https://avatars.githubusercontent.com/si-meng-spec?v=4","url":"https://github.com/si-meng-spec"}]},"autoDesc":true,"filePathRelative":"blog/technology/Deploying_WSL2_on_Windows_10.md","headers":[],"categoryList":[{"id":"126ac9","sort":10000,"name":"blog"},{"id":"750eb7","sort":10003,"name":"technology"}]}');export{k as comp,d as data};
