1. 程式人生 > 實用技巧 >在Windows 10上為Hyper-V使用增強模式Ubuntu 18.04

在Windows 10上為Hyper-V使用增強模式Ubuntu 18.04

I run Windows as my daily driver but I use WSL (Windows Subsystem for Linux) all day long but WSL is just the command-line and has some perf issues with heavy file system work. I use Docker for Windows which works amazingly and has it good perf but sometimes I want to test on a full Ubuntu Desktop.

我將Windows作為日常驅動程式執行,但是整天都使用WSL(Linux的Windows子系統),但是WSL只是命令列,並且在檔案系統繁重的工作中存在一些效能問題。 我使用適用於Windows的Docker,它的效能驚人且效能出色,但有時我想在完整的Ubuntu桌面上進行測試。

ASIDE: No joke. My Linux/Ubuntu bona fides go back a while. Here's me installing Ubuntu 10.4 on Windows 7 over 8 years ago. Umuntu ngumuntu ngabantu!

旁白:沒有開玩笑。 我Linux / Ubuntu真實情況可以追溯到一段時間。 這是

我8年前在Windows 7上安裝Ubuntu 10.4的地方。 Umuntu ngumuntu ngabantu!

To be frank, historically Ubuntu has sucked on Window's Hyper-V. If you wanted to get a higher (read: usable) resolution it would take a miracle. If you wanted shared clipboards or shared disk drives, well, again, miracle or a ton of manual set up. It's possible but it's not fun.

坦率地說,從歷史上看,Ubuntu吸引了Window的Hyper-V。 如果您想獲得更高的解析度(閱讀:可用),那將是一個奇蹟。 如果您想要共享剪貼簿或共享磁碟驅動器,那麼還是要奇蹟般地進行大量手動設定。 有可能,但是不好玩。

Why can't it be easy? Well, it is. I installed the Windows 10 "Fall Creators Update" - yes the name is stupid. It's Windows 10 "1809" - that's 2018 and the 9th month. Just type "Winver" from the Start menu. You may have "1803" from March. Go update.

為什麼不那麼容易? 好吧,是的。 我安裝了Windows 10“秋季創作者更新”-是的,這個名稱很愚蠢。 它是Windows 10“ 1809”,即2018年和第9個月。 只需從“開始”選單中鍵入“ Winver”。 從三月開始,您可能會收到“ 1803”。 去更新。

Windows 10 includes Hyper-V Quick Create which has this suspiciously short list under "Select an operating system." Anytime a list has 1 or 2 items and some whitespace that means it will someday have n+1 list items.

Windows 10包括Hyper-V快速建立,在“選擇作業系統”下具有此可疑的簡短列表。 每當列表包含1或2個專案以及某些空格時,表示某天它將具有n + 1個列表專案。

Recently Ubuntu 18.04.1 LTS showed up in this list. You can quickly and easily create an Ubuntu VM from here and it's all handled, downloading, network switch, VM create, etc.

最近,Ubuntu 18.04.1 LTS出現在此列表中。 您可以從此處快速輕鬆地建立Ubuntu VM,並已完成所有操作,下載,網路切換,VM建立等。

Create Virtual Machine

I dig it. So click create, start it up...get to the set up screen. Now, here, make sure you click "Require my password to login." What we want to do won't work with "Log in Automatically" and you don't want that anyway.

我喜歡。 因此,單擊建立,啟動它...進入設定螢幕。 現在,在這裡,請確保單擊“需要我的密碼才能登入”。 我們要執行的操作不適用於“自動登入”,並且您還是不希望這樣做。

Setting up an Ubuntu VM

After you've created your VM and got it mostly setup, close the Hyper-V client window. Just X it out. The VM is still running of course.

建立虛擬機器並對其進行主要設定後,請關閉Hyper-V客戶端視窗。 只需X出來。 VM當然仍在執行。

Go over to Hyper-V Manager and right click on it and "Connect."

轉到Hyper-V Manager,右鍵單擊它,然後單擊“連線”。

Connect to VM

You'll see a resolution dialog...pick one! Go crazy! Do be aware that there are issues on 4k display but you can adjust within Ubuntu itself.

您會看到一個解析度對話方塊...選擇一個! 瘋了! 請注意,4k顯示屏存在問題,但是您可以在Ubuntu本身中進行調整。

Set Resolution

Now, BEFORE you click Connect, click "Show Options" and then "Local Resources." Under here, uncheck Smart Cards and Check "Drives."

現在,在單擊“連線”之前,單擊“顯示選項”,然後單擊“本地資源”。 在這裡,取消選中智慧卡,然後選中“驅動器”。

Uncheck Smart Cards and Check Drives

Click OK and Connect...and you get this weird dialog! You're actually RDP'ing into Ubuntu! Rather than using the historical weird Hyper-V Client stuff to talk to Ubuntu and struggle with video cards and resolutions, here you are literally just Remote Desktoping into Ubuntu using integrated open source xrdp!

單擊確定並連線...,您將得到這個奇怪的對話方塊! 您實際上是在RDP進入Ubuntu! 與其使用歷史悠久的怪異Hyper-V Client東西與Ubuntu進行對話並與視訊卡和解析度作鬥爭,這裡實際上是使用整合的開源xrdp將桌面遠端化到Ubuntu中!

Login with your name and password (remember before when I said don't automatically login? This is why.)

使用您的名稱和密碼登入(記得之前我說過不要自動登入嗎?這就是為什麼。)

Login to xrdp

動態調整大小呢? (What about Dynamic Resizing?)

Here's an even better possible future. What we REALLY want (don't we, Dear Reader) is Dynamic Resolution and Resizing without Reconnection! Today you can just close and reconnect to change resolutions but I'd love to just resize the Ubuntu window like I do Windows 7/8/10 VM client windows.

這是一個更好的未來。 我們真正想要的(親愛的讀者,我們不要)是動態解析度和調整大小而無需重新連線! 今天,您可以關閉並重新連線以更改解析度,但是我希望像Windows 7/8/10 VM Client視窗一樣調整Ubuntu視窗的大小。

The feature "Dynamic resolution update" was introduced in RDP 8.1. It enables to resize screen resolution on-the-fly.

RDP 8.1中引入了“動態解析度更新”功能。 它可以即時調整螢幕解析度的大小。

Since we are using xrdp and that's open source over https://github.com/neutrinolabs/xrdp/ AND there's even a issue about this AND a lovely person has the code in their own branch and agreed to possibly upstream it maybe we can start using it and this great feature will just light up for folks who use Hyper-V Quick Create. Certainly we're talking weeks and months here (unless you want to help) but the lion's share of the work is done. I'm looking forward to resizing Ubuntu VMs dynamically.

由於我們使用的是xrdp,並且是通過https://github.com/neutrinolabs/xrdp/開放的原始碼,因此甚至存在一個問題,一個可愛的人在自己的分支中擁有程式碼,並同意在上游進行開發,也許我們可以開始使用它,這項功能非常強大,只會為使用Hyper-V Quick Create的人們點亮。 當然,我們在這裡談論了數週和數月的時間(除非您想提供幫助),但是大部分工作已經完成。 我期待動態調整Ubuntu VM的大小。

今天處於增強模式下是什麼? (What's in Enhanced Mode Today?)

Back to today! You can read about how Linux VMs (Ubuntu or Arch) are set up in this GitHub repo https://github.com/Microsoft/linux-vm-tools You can set them up yourself with scripts, but the nice thing about Hyper-V Quick Create is that the work is done for us to make these "enhanced session" RDP-friendly VMs. No need to fear, you can just read the scripts yourself.

回到今天! 您可以在此GitHub儲存庫中瞭解有關如何設定Linux VM(Ubuntu或Arch)的資訊。https://github.com/Microsoft/linux-vm-tools您可以使用指令碼自行設定它們,但是關於Hyper- V Quick Create的工作是為我們製作這些“增強的會話”,對RDP友好的VM。 不用擔心,您可以自己閱讀指令碼

I can connect quickly and Enhanced Mode VMs give me:

我可以快速連線,增強模式VM可以為我提供:

  • a shared clipboard

    共享剪貼簿

  • the resolution of my choice on connect

    我選擇的連線解析度

  • fast painting/video/scrolling

    快速繪畫/視訊/滾動

  • automatic shared-drives

    自動共享驅動器

  • Smooth and automatic mouse capture

    流暢,自動的滑鼠捕獲

Fantastic.

太棒了

Ubuntu on Windows 10

What about installing Visual Studio Code? Of course. And also .NET Core.NET Core, natch.

如何安裝Visual Studio Code ? 當然。 還有.NET Core .NET Core,natch。

image

This took like 10 min and 8 of it was waiting for Hyper-V Create to download Ubuntu. Try it out!

這大約花了10分鐘,其中8分鐘正在等待Hyper-V Create下載Ubuntu。 試試看!



Sponsor: Check out the latest JetBrains Rider with built-in spell checking, enhanced debugger, Docker support, full C# 7.3 support, publishing to IIS and more advanced Unity support.

贊助商:使用內建的拼寫檢查,增強的偵錯程式,Docker支援,完整的C#7.3支援,釋出到IIS和更高階的Unity支援,檢視最新的JetBrains Rider

關於斯科特 (About Scott)

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

斯科特·漢塞爾曼(Scott Hanselman)是前教授,前金融首席架構師,現在是演講者,顧問,父親,糖尿病患者和Microsoft員工。 他是一位失敗的單口相聲漫畫家,一個玉米種植者和一本書的作者。

facebook twitter subscribe About 關於 Newsletter 時事通訊 Hosting By 主持人 Hosted in an Azure App Service

翻譯自: https://www.hanselman.com/blog/using-enhanced-mode-ubuntu-1804-for-hyperv-on-windows-10