微软帮我在 Windows 10 电脑上安装了 Ubuntu Linux
Linux 微软
![](/data/attachment/album/202010/03/111045ecl3b81041jbi0ib.jpg)



> 
> 很多读过我们的技术文章评论的人都知道，每个技术问题的答案都是“切换到 Linux”。而如果你对 Linux 是什么以及它是如何工作的感到好奇，微软可以提供帮助。
> 
> 
> 


如果你曾经经历过痛苦的 Windows 更新，或者不敢置信地看着你的 MacBook 慢到像爬行，并将其风扇切换到巨型喷气式飞机起飞模式，你知道有一个也只有一个答案来解决你的困境：“切换到 Linux”。


当然，我是开玩笑的，但如果你浏览一下这些技术评论，你会发现这个建议是认真的，有一支开源布道者大军定期宣讲圣莱纳斯的福音，以回应关于其他平台的哪怕是最模糊的相关新闻。


你知道吗？我认为那些评论者的观点是合理的。任何有志于了解现代计算环境的人都应该对他们经常使用的操作系统平台以外的平台有一些经验，因为今天你在 Windows、MacOS 和 Linux 中看到的很多东西都来自于相同的 DNA。


为了跟上 Linux 的新动向，我自己每隔一两年就会进行一次这样的练习。所以，想象一下我的惊讶吧，今年我能够在几分钟内搭建一个功能完善的 Ubuntu Linux 机器，而不干扰我当前的 Windows 10 设置。更令人惊讶的是，微软为此做了大部分的工作。


使这一切成为可能的魔法是每台运行 Windows 10 专业版或企业版的 PC 所包含的 Hyper-V 虚拟化软件。（对不起，Windows 10 家庭用户，如果你想玩这些，你得先升级）。用 Hyper-V 的“快速创建”陈列栏，只需点击几下就可以建立一个新的虚拟机，其中包括了独立的 Ubuntu 镜像，而且不是一个而是三个，包括新的 Ubuntu 20.04 版本。


![](/data/attachment/album/202010/03/111247iy21ei64nxqqay6y.jpg)


*Hyper-V 快速创建工具包括了三个 Ubuntu Linux 版本*


最重要的是，这些自定义镜像能够在 Hyper-V 增强会话中运行，这意味着你可以选择自定义的显示分辨率，或者在全屏中运行，甚至跨越多个显示器，其性能接近于在裸机上运行的性能。在增强型会话中，你的虚拟机可以共享主机上的 Windows 剪贴板、本地存储和音频硬件。


一旦你把一切都弄好了，你就可以在全屏模式下启动 Ubuntu 虚拟机，并与它一起工作，就像 Windows 10 宿主机不存在一样。


唉，关于所有东西都能正常工作的那部分话并不是说说而已。好消息是，两年前的 Ubuntu 18.04.3 长期支持（LTS）版本工作得很完美，不需要任何操作。但两个较新的版本却让我欲哭无泪。我需要手动编辑一个受保护的 Linux 配置文件，然后才能让增强的会话在最新的 Ubuntu 版本（20.04）中工作，19.10 版本的虚拟机挂了好几次，至少需要重启十几次（包括几次硬重置）才能如期工作。


不过，在一切都结束后，我还是有了三个可以工作的虚拟机，让我对 Ubuntu Linux 中的新功能有了一个相当不错的印象。


* 补充更新，2020 年 6 月 5 日。[通过 Twitter](https://twitter.com/unixterminal/status/1268918077141528579)，@Canonical 的 Ubuntu on WSL 和 Hyper-V 的开发布道师 Hayden Barnes 说，“我们知道 19.10 和 20.04 中的 xrdp bug。20.04 镜像将在即将到来的 20.04.1 LTS 更新中进行修补。19.10 已经接近 EOL，将被放弃。"
* 补充更新 2，2020 年 10 月 1 日。20.04.1 LTS 桌面 Ubuntu 镜像于 2020 年 7 月 31 日发布，但截至 10 月 1 日，它还没有被整合到 Hyper-V 中的快速创建镜像中。


另外，正如我的同事 Mary Branscombe 所指出的那样，包括 Home 在内的所有版本的 Windows 10 都提供了对 Windows Subsystem for Linux（WSL）的访问，该系统在轻量级虚拟机中运行 Linux 内核，并且从 Windows 10 的 2004 版本开始，该系统已经全新升级为 WSL2。正如 WSL2 文档中明确指出的那样，这并不是传统的虚拟机体验，它最适合那些希望获得命令行体验并能够运行 Bash shell 脚本和 GNU/Linux 命令行应用程序的开发者。在 WSL2 环境中运行图形应用程序的能力已列入微软的路线图，应该会在 2020 年底或 2021 年初由 Windows Insiders 进行测试。


如果你想尝试在 Windows 10 中设置一个或多个 Ubuntu 虚拟机进行自己的实验，请看我的另外一篇文章。




---


via: <https://www.zdnet.com/article/microsoft-helped-me-install-ubuntu-linux-on-my-windows-10-pc-and-its-actually-pretty-good/> 


作者：[Ed Bott](https://www.zdnet.com/meet-the-team/us/ed-bott/) 译者：[wxy](https://github.com/wxy) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](/article-12674-1.html) 荣誉推出


OK
# Microsoft helped me install Ubuntu Linux on my Windows 10 PC, and it's actually pretty good

![ed-bott](https://www.zdnet.com/a/img/resize/53ea6d95ba2f62d612a514d19551a13b56941f68/2022/08/05/e98b0a76-a96a-4fbb-be02-00807405874e/ed-bott.jpg?auto=webp&fit=crop&frame=1&height=192&width=192)

If you've ever suffered through a painful Windows update or watched in disbelief as your MacBook decided to slow to a crawl and switch its fan into jumbo-jet-at-takeoff mode, you know that there's one and only one answer to your woes: "Switch to Linux."

I kid, of course, but you'll find that advice offered in earnest if you scroll through the comments here at *ZDNet*, where an army of open source evangelists regularly preaches the Gospel of Saint Linus in response to even the most vaguely related bit of news about other platforms.

**Also: ****Open source's Eric Raymond: Windows 10 will soon be just an emulation layer on Linux kernel**** **

And you know what? I think those commenters have a legitimate point. Anyone who aspires to understand the modern computing landscape should have some experience with platforms other than the one they use regularly because a lot of what you see in Windows, MacOS, and Linux today comes from the same DNA.

In the interest of keeping up with what's new in Linux, I go through this exercise myself every year or two. So, imagine my surprise when this year I was able to build a functional Ubuntu Linux machine in minutes, without disturbing my current Windows 10 setup. Even more surprising: Microsoft did most of the work.

The magic that made all this possible is the Hyper-V virtualization software included with every PC running Windows 10 Pro or Enterprise. (Sorry, Windows 10 Home users, you're going to have to upgrade if you want to play along.) Hyper-V's Quick Create gallery, which can build a new virtual machine in just a few clicks, includes not one but three separate Ubuntu images, including the new Ubuntu 20.04 version.

The Hyper-V Quick Create utility includes three Ubunutu Linux versions

Best of all, these custom images are capable of running in a Hyper-V *enhanced session*, which means you can choose a custom display resolution or run in a full screen, even spanning multiple monitors, with a performance that's close to what you'd get running on bare metal. In an enhanced session, your virtual machine can share the Windows Clipboard, local storage, and audio hardware on the host machine.

Once you get everything working, you can fire up that Ubuntu VM in full-screen mode and work with it just as if the Windows 10 host machine weren't there.

**Must read:**

[Microsoft: Linux GUI apps coming to Windows 10 WSL along with GPU access](https://www.zdnet.com/article/microsoft-linux-gui-apps-coming-to-windows-10-wsl-along-with-gpu-access/)[Desktop Linux: Why open source is heading for a new breakthrough](https://www.techrepublic.com/article/desktop-linux-why-open-source-is-heading-for-a-new-breakthrough/)**TechRepublic**[Linux-based Windows makes perfect sense](https://www.zdnet.com/article/linux-based-windows-makes-perfect-sense/)

Alas, that part about getting everything working isn't just a figure of speech. The good news is that the two-year-old [Ubuntu 18.04.3 Long Term Support (LTS)](https://www.zdnet.com/article/linux-on-windows-10-running-ubuntu-vms-just-got-a-lot-easier-says-microsoft/) version worked perfectly, with no futzing required. But the two newer releases had me tearing my hair out. I needed to manually edit a protected Linux configuration file before I could get an enhanced session to work in the latest [Ubuntu release (20.04), ](https://www.zdnet.com/article/ubuntu-20-04-arrives-with-linux-5-4-kernel-and-wireguard-vpn/)and the version 19.10 VM hung several times and required at least a dozen restarts (including a few hard resets) before it worked as expected.

Still, after all was said and done, I had three working virtual machines, giving me a pretty decent overview of what's new in Ubuntu Linux.

*Update, June 5, 2020: Via Twitter, Hayden Barnes, Developer Advocate for Ubuntu on WSL and Hyper-V at @Canonical, says, "We know about the xrdp bug in 19.10 and 20.04. The 20.04 image will be patched in the upcoming 20.04.1 LTS update. 19.10 is nearing EOL and will be dropped."*

*Update 2, October 1, 2020: The 20.04.1 LTS desktop Ubuntu image was released on July 31, 2020, but as of October 1 it has not yet been integrated into the Quick Create image in Hyper-V. *

*Also, as my colleague Mary Branscombe notes, all editions of Windows 10, including Home, offer access to the Windows Subsystem for Linux, which runs the Linux kernel in a lightweight virtual machine and has been freshly updated to WSL2 as of Windows 10 version 2004. As the WSL2 documentation makes clear, this is not a traditional VM experience and it's best suited for developers who want a command line experience and the ability to run Bash shell scripts and GNU/Linux command-line applications. The ability to run graphical apps in the WSL2 environment is on Microsoft's roadmap and should be available for testing by Windows Insiders in late 2020 or early 2021.*

If you'd like to try setting up one or more Ubuntu VMs in Windows 10 for your own experimentation, follow these steps.

### 1. Enable the Hyper-V Platform

This hypervisor is built into all 64-bit Windows 10 Pro, Enterprise, and Education editions, but it's not enabled by default. You might need to turn on some firmware options on older PCs before you can enable the feature. For full instructions, see ["Windows 10: How to enable Hyper-V and create virtual machines."](https://www.zdnet.com/article/windows-10-tip-how-to-enable-hyper-v-and-create-virtual-machines/)

### 2. Use Quick Create to download and install the Ubuntu VM

Hyper-V offers two ways to create a new virtual machine. The old fashioned way is to click your way through a tedious multi-step wizard. The much easier solution is to use the Hyper-V Quick Create utility. You'll find a shortcut in the right pane in Hyper-V Manager, or you can open it directly using the Vmcreate.exe command in the Windows 10 search box.

Choose an Ubuntu version from the gallery on the left, then click the Create Virtual Machine button. That kicks off a download of between 1.6GB (18.04.3 LTS) and 2GB (more recent versions). After the download is complete, the Quick Create utility extracts the image, configures the VM, and then displays a dialog box telling you your virtual machine was created successfully.

I recommend you edit a few settings before running the VN for the first time.

### 3. Tweak a few settings

Although you can get started immediately by clicking Connect, if you have sufficient resources on your Windows 10 host machine, I recommend that you click Edit Settings instead, so you can make a few adjustments first.

Choose Memory from the hardware list for your new VM, and then change the assigned RAM from its default value of 2048 to 4096, which should result in better performance. You can also disable dynamic memory if you want a fixed amount of virtual RAM. You might also want to increase the size of the system disk from its default 12GB. Click Hard Drive, then click Edit, and follow the prompts till you reach the Expand command.

Feel free to tweak the memory assigned to your Linux VM

Finally, under the Management heading, click Checkpoints and then clear the Use Automatic Checkpoints box. (You can always create a checkpoint manually if you want the ability to roll back changes.)

With those adjustments out of the way, you can close the Settings dialog box and open the VM for the first time.

### 4. Set up your user account

Run through the system configuration for Ubuntu, choosing your default language, time zone, and so on. When you get to the screen where you create your login credentials, leave the default setting at **Require my password to log in**.

Although it sounds convenient, do not enable the auto-login feature. If you choose this option, you won't be able to sign in using an enhanced session, and your VM will be forced to run in a relatively small window with a default resolution that you can't easily change.

This is also a good time to run the Software Updater app and get the latest Ubuntu updates. (Click the waffle icon in the lower-left corner and use the search box to find the app.)

### 5. Sign in using an enhanced session

You'll know you've started an enhanced session if you see this dialog box in the VM Connect window.

Move that slider to the far right to run your VM in a full screen

Slide the switch to choose your display resolution. I prefer to move the slider to the right, to the Full Screen position. If you have multiple monitors and you want your VM to span across them, select the Use All My Monitors checkbox. Click Connect to continue, which opens the Xrdp sign-in dialog box, shown here.

Sign in to Xrdp to launch your enhanced Hyper-V session

Enter the username and password you set up when creating your Ubuntu Linux account and click OK. Assuming the gods are not angry, you'll sign in to your VM and can get to work. You might have to enter your password a second time if you're not already signed in on the session that you're connecting to. (If you get a black screen, try pressing Enter.)

All of that should work just fine if you started with an 18.04.3 LTS VM. If you're using Ubuntu 19.10, you might have to go through the same frustrating sequence of restarts that I did before everything works properly.

### Linux

For Ubuntu 20.04, everything worked just fine in a basic session, but the option to run an enhanced session wasn't available until I edited the Xrdp.ini file in /etc/xrdp. This is a protected location, so I had to open an editor with an administrator's credentials, a task which is neither intuitive nor easy.

I had to change two lines in that ini file. First, change port=3389 to port=vsock://-1:3389. Then change use_vsock=true to use_vsock=false. Close the Vmconnect window and connect to the VM again and you should be able to start an enhanced session. But you might also be required to invoke some minor deities and burn some incense. It's Linux, after all.

(As I noted earlier, the Canonical/Microsoft team will have a fix for that image with the 20.04.1 update, so the xrdp.ini file won't require editing.)

And you're now on your own. You'll have to find productivity software that allows you to get actual work done. If you're like me and use mostly Microsoft services, prepare for a heaping helping of frustration.

Microsoft doesn't currently have any Office apps for Linux, so you'll need to access your files from a web browser. (Yes, there are Office clones for Linux, including the LibreOffice suite, which is a faithful clone of Microsoft Office 2007. It's... barely adequate.)

**Must read:**

[Look what's inside Linus Torvalds' latest Linux development PC](https://www.zdnet.com/article/look-whats-inside-linus-torvalds-latest-linux-development-pc/)[New fuzzing tool finds 26 USB bugs in Linux, Windows, macOS, and FreeBSD](https://www.zdnet.com/article/new-fuzzing-tool-finds-26-usb-bugs-in-linux-windows-macos-and-freebsd/)[Microsoft's Windows Package Manager: This command-line tool can install all your apps](https://www.zdnet.com/article/microsofts-windows-package-manager-this-command-line-tool-can-install-all-your-apps/)

In Ubuntu Linux 20.04, I was able to connect Google Drive directly, so that those cloud-backed files appeared directly in the Files app. An easy-to-install Dropbox app was also available. But OneDrive? Not so much. There's an open source third-party sync client, but the installation required more than a half-dozen dependent packages, and I didn't have the patience or the confidence to complete the process.

The default browser in Ubuntu Linux is Mozilla Firefox, which worked well enough on the 18.04.3 LTS version but was jerky in the 20.04 release. Microsoft says it plans to release its new Chromium-based Edge for Linux, but so far that's just a pipe dream. On the plus side, there's a very well done [Microsoft Teams client](https://www.zdnet.com/article/microsoft-teams-for-linux-now-available-in-public-preview/) that installs as a native .deb package.

Although the overall experience is surprisingly smooth, there were too many moments when running Linux felt slightly janky for me. In the 20.04 release, for example, Firefox downloads package files to a temp folder, where they won't open properly. Once I figured out that I had to move those files to the Downloads directory, everything was fine. (Note that Google Chrome downloads go to the correct location by default.)

If, on the other hand, your workday is spent in the Google ecosystem, Linux will probably feel very comfortable. After installing Chrome and setting up G Suite, this VM is basically a slightly snooty Chromebook.

Am I going to switch to Linux as my primary operating system? Uh, no. But I will keep these VMs in service and check in regularly. Because you never know...

#### Windows

[Editorial standards](/editorial-guidelines/)