Window10 建置Ubuntu(WSL2)與GUI桌面配置筆記 此筆記內容為紀錄筆者在建置WSL2過程中操作與問題。
關於 Windows 子系統 Linux 版
https://docs.microsoft.com/zh-tw/windows/wsl/about
系統要求 要使用WSL2必須要先符合要求條件
Windows 版本為 2004,組建為19041版本或更高。
開啟 Windows子系統Linux版 與 虛擬機器平台
Window10 建置Ubuntu(WSL2) 官方安裝指南
https://docs.microsoft.com/zh-tw/windows/wsl/install-win10
Step 1. 設定使用WSL2為預設使用版本
Step 2. 需要去控制台 – ->程式和功能 – ->開啟或關Windows功能 – >勾選 Windows子系統Linux版 與 虛擬機器平台
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
開啟完畢後會跑更新,跑完更新之後會需要重開電腦。
Step 3. 下載X server連線工具,使用 VcXsrv
https://sourceforge.net/projects/vcxsrv/
下載完畢後執行程式安裝完即可。
Step 4. 開啟Windows商店在搜尋列輸入Ubuntu,使用Ubuntu 20.04 LTS版本安裝。
安裝完畢後開啟該子系統終端機,執行初次操作設置好 username 與 password ,之後執行下列指令更新環境
GUI桌面配置 開啟Ubuntu 20.04 LTS終端機
Step 1. 執行安裝 X Server 套件
Step 2. 在家目錄(~/)底下建立一個.bash_login
並輸入以下內容
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For WSL2
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0.0
export LIBGL_ALWAYS_INDIRECT=1
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
按 Ctrl+x 後再按 Y 最後在按 Enter 儲存。
Step 3. 執行安裝 xfce4 桌面
Step 4. 回到Windows開啟VcXsrv主程式(XLaunch)
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
Display number 記得設置為0
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
點選完成,出現下面視窗畫面即可
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
Step 5. 在Ubuntu 20.04 LTS終端機啟動X Server,輸入下面指令
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
採雷筆記 剛開始建立好啟動X Server時,並沒有預期那麼順利運作起來,碰到X Server運作不起來顯示下面訊息
172.21.96.1是我的WSL區網虛擬主幹,可以在工作管理員看到
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
在筆者Ubuntu 20.04 LTS所取得IP是在屬於此虛擬區網主幹內,此主幹在防火牆預設使用防護規則屬於 公用網路 ,筆者在執行VcXsrv過程中彈出的防火牆允許視窗中,只勾選了允許私人網路而沒勾到公用網路,摸索研究半天才發現這個問題。
解決方式為去防火牆更設定 允許應用程式或功能通過Windows Defender防火牆 設定中,
將 VcXsrv windows xserver 在公用項目打勾即可。
Image Not Showing
Possible Reasons
The image file may be corrupted The server hosting the image is unavailable The image path is incorrect The image format is not supported
Learn More →
相關參考
關於WSL(Windows Subsystem for Linux)說明可參考
https://wiki.ubuntu.com/WSL
https://docs.microsoft.com/en-us/windows/wsl/install-win10
https://docs.microsoft.com/zh-tw/windows/wsl/install-win10
其他
https://github.com/microsoft/WSL/issues/4106
https://hackmd.io/@billsun/SyL3pzzQm?type=view
https://github.com/QMonkey/wsl-tutorial/blob/master/README.wsl2.md
https://www.youtube.com/watch?v=6_mbd1hvUnE