利用VirtualBox在Linux上创建Windows虚拟机的详细教程
<div id="navCategory"><h5 class="catalogue">目录</h5><ul class="first_class_ul"><li>1. 安装桌面环境<ul class="second_class_ul"><li>RDP连接Ubuntu桌面具体步骤</li><ul class="third_class_ul"><li>1. 安装 RDP 服务器:</li><li>2. 配置 Xfce4 桌面:</li><li>3. 配置 xrdp</li><li>4. 启动 xrdp 服务:</li><li>5. 允许通过防火墙(可选)</li><li>6. 连接到RDP服务器</li></ul></ul></li><li>2. 安装 virtualbox<ul class="second_class_ul"></ul></li><li>3. 安装 Windows 11虚拟机<ul class="second_class_ul"></ul></li><li>4. 使用 Windows 11虚拟机<ul class="second_class_ul"></ul></li><li>写在最后<ul class="second_class_ul"></ul></li></ul></div><p>后台有小伙伴催更:<strong>如何在 Linux 上构建一台 Windows 虚拟机?</strong></p><p>今日分享,来搞定它!</p>
<p>只需三步:</p>
<ul><li>安装桌面环境(如有,可忽略);</li><li>安装 virtualbox;</li><li>安装 Windows 11虚拟机;</li></ul>
<p>不多说,开始实操!</p>
<p class="maodian"></p><h2>1. 安装桌面环境</h2>
<p>桌面环境其实很占内存,不过既然你都要装上 Windsows 虚拟机了,那桌面自然少不了。</p>
<p>如果你的 Linux 系统是 Ubuntu,那么自带桌面环境,本段可忽略。</p>
<p>如果你的 Linux 系统不带桌面环境,比如 Debian,那么推荐你安装 xfce,轻量小巧,资源占用少。</p>
<p>有需要的小伙伴可参考以下内容:</p>
<p>在Windows下远程访问Linux服务器的桌面,有几种常见的方法:</p>
<ul><li><p>xrdp(X Remote Desktop Protocol):xrdp允许Windows使用RDP(Remote Desktop Protocol)来连接到Linux服务器的桌面。这种方式相对简便,因为它使用Windows自带的远程桌面客户端。</p></li><li><p>VNC(Virtual Network Computing):VNC是一种基于图形界面的远程桌面协议,它允许用户远程访问Linux桌面。</p></li><li><p>SSH(Secure Shell):SSH是一种网络协议,用于加密方式远程登录到服务器。虽然SSH本身不提供图形界面访问,但可以通过X11转发功能在Windows上显示Linux的图形应用程序。</p></li></ul>
<p>原本打算通过 VNC 实现远程连接,不过灰屏的问题一直无法解决,考虑到登陆远程桌面的需求并不多,主要是需要登陆浏览器实现校园网登陆,所以退而求其次采用 xrdp 来实现远程登陆。</p>
<p class="maodian"></p><h3>RDP连接Ubuntu桌面具体步骤</h3>
<p>要通过远程桌面协议(RDP)连接运行Xfce4桌面环境的Ubuntu系统,大致可以按照以下步骤操作:</p>
<p class="maodian"></p><h4>1. 安装 RDP 服务器:</h4>
<p>在Ubuntu系统上,您需要安装一个RDP服务器,如xrdp。使用以下命令安装:</p>
<div class="dxycode"><pre class="brush:bash;">sudo apt-get update
sudo apt-get install xrdp</pre></div>
<p class="maodian"></p><h4>2. 配置 Xfce4 桌面:</h4>
<p>xrdp默认使用Xfce4作为桌面环境。确保Xfce4已经安装在您的系统上。如果没有,您可以使用以下命令安装:</p>
<div class="dxycode"><pre class="brush:bash;">sudo apt-get install xfce4</pre></div>
<p>xrdp 使用VNC 作为其显示协议,因此您还需要安装一个VNC服务器,不过 xrdp 安装过程中通常会同时安装 Xvnc。</p>
<p class="maodian"></p><h4>3. 配置 xrdp</h4>
<p>安装完成后,您可能需要配置xrdp以使用Xfce4。这通常涉及到编辑.xsession文件,确保它指向Xfce4。这里使用文本编辑器 Vim 编辑 ~/.xsession 文件,并添加以下行:</p>
<div class="dxycode"><pre class="brush:bash;">xfce4-session</pre></div>
<p class="maodian"></p><h4>4. 启动 xrdp 服务:</h4>
<p>安装和配置完成后,启动 xrdp 服务:</p>
<div class="dxycode"><pre class="brush:bash;">sudo systemctl enable xrdp
sudo systemctl start xrdp</pre></div>
<p>如果要退出 xrdp 服务:</p>
<div class="dxycode"><pre class="brush:bash;">sudo systemctl stop xrdp</pre></div>
<p class="maodian"></p><h4>5. 允许通过防火墙(可选)</h4>
<p>这一步非必须,如果能连接到 RDP 服务器,则不需要执行这一步。否则,需要确保 RDP 端口 3389 在您的防火墙中是开放的。如果您使用的是ufw,可以使用以下命令:</p>
<div class="dxycode"><pre class="brush:bash;">sudo ufw allow 3389/tcp</pre></div>
<p class="maodian"></p><h4>6. 连接到RDP服务器</h4>
<p>在Windows机器上,打开<code>远程桌面连接</code>应用程序,并输入Ubuntu服务器的IP地址。您应该会看到登录界面,输入Ubuntu的用户名和密码后,您就可以通过RDP访问Xfce4桌面了。</p>
<p class="maodian"></p><h2>2. 安装 virtualbox</h2>
<p>有了桌面环境,就可以安装 virtualbox 了。</p>
<p><strong>step 1. 检查系统要求</strong></p>
<p>确保 Linux 主机支持硬件虚拟化(Intel VT-x 或 AMD-V),可以通过以下命令检查:</p>
<div class="dxycode"><pre class="brush:bash;">egrep -c '(vmx|svm)' /proc/cpuinfo</pre></div>
<ul><li>返回值 >0 表示支持虚拟化。</li><li>如果虚拟化未启用,请在 BIOS/UEFI 中开启。</li></ul>
<p><strong>step 2. 安装 VirtualBox</strong></p>
<div class="dxycode"><pre class="brush:bash;">wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
sudo add-apt-repository "deb https://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib"
sudo apt update
sudo apt install virtualbox-7.0 -y
# 安装扩展包(可选,支持 USB 3.0 等高级功能):暂时不用安装
wget https://download.virtualbox.org/virtualbox/7.0.10/Oracle_VM_VirtualBox_Extension_Pack-7.0.10.vbox-extpack
sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-7.0.10.vbox-extpack</pre></div>
<p><strong>step 3. 启动 VirtualBox</strong></p>
<p>终端输入:</p>
<div class="dxycode"><pre class="brush:bash;">virtualbox</pre></div>
<p>或者在 xfce4 桌面环境中点击:</p>
<p style="text-align:center"><img style="max-width:100%!important;height:auto!important;"alt="" src="https://zhuji.jb51.net/uploads/allimg/20250530/2-2505301153433Q.png" /></p>
<p class="maodian"></p><h2>3. 安装 Windows 11虚拟机</h2>
<p><strong>step 1. 下载镜像</strong></p>
<p>首先,下载 Windows11 ISO 镜像,并保存到 Linux 主机:https://www.microsoft.com/zh-cn/software-download/windows11</p>
<p><strong>step 2. 新建虚拟机</strong></p>
<p><code>Folder</code> 处,设置虚拟机的安装目录,并找到刚刚下载的镜像路径:</p>
<p style="text-align:center"><img style="max-width:100%!important;height:auto!important;"alt="" src="https://zhuji.jb51.net/uploads/allimg/20250530/2-2505301153445a.png" /></p>
<p>给主机取个名字 <code>win11</code>:默认用户名和密码为 vboxuser changeme。</p>
<p style="text-align:center"><img style="max-width:100%!important;height:auto!important;"alt="" src="https://zhuji.jb51.net/uploads/allimg/20250530/2-250530115344230.png" /></p>
<p>选择系统资源,建议内存 8192M,CPU 4 以上,硬盘分配 100G 足够了。<strong>注意勾选<code>Enable EFI</code></strong></p>
<p style="text-align:center"><img style="max-width:100%!important;height:auto!important;"alt="" src="https://zhuji.jb51.net/uploads/allimg/20250530/2-250530115345357.png" /></p>
<p>等待系统安装,当 终端出现 <code>press any key from cd</code> 时,立刻按下任意键。</p>
<p>跳过密钥设置,直接下一步。</p>
<p style="text-align:center"><img style="max-width:100%!important;height:auto!important;"alt="" src="https://zhuji.jb51.net/uploads/allimg/20250530/2-25053011534AI.png" /></p>
<p class="maodian"></p><h2>4. 使用 Windows 11虚拟机</h2>
<p>安装成功后,系统大概就占用了 20 G。和本地 Windows 操作无异,开始愉快玩耍吧。</p>
<p style="text-align:center"><img style="max-width:100%!important;height:auto!important;"alt="" src="https://zhuji.jb51.net/uploads/allimg/20250530/2-25053011534C53.jpg" /></p>
<p>只运行 VsCode 和微信客户端,系统资源占用如下:</p>
<p style="text-align:center"><img style="max-width:100%!important;height:auto!important;"alt="" src="https://zhuji.jb51.net/uploads/allimg/20250530/2-250530115351962.png" /></p>
<p>当然,你还希望本地和虚拟机之间,能自由复制粘贴,那就如下配置一番:</p>
<p style="text-align:center"><img style="max-width:100%!important;height:auto!important;"alt="" src="https://zhuji.jb51.net/uploads/allimg/20250530/2-250530115352R6.png" /></p>
<p class="maodian"></p><h2>写在最后</h2>
<p>本文分享了利用 VirtualBox 在 Linux 上创建 Windows 虚拟机。</p>
<p>以上就是如何在 Linux 上搞一台 Windows 虚拟机的详细内容,更多相关资料请阅读琼殿技术社区其它文章!</p>
頁:
[1]