-
Notifications
You must be signed in to change notification settings - Fork 2
WSL: Windows Subsystem for Linux
This article explains the problems for Ubuntu on Windows. Items for WSL but not WSL2 have the mark “WSL only.”
Turn on the developer mode or download and run ./Ubuntu.appx.
- Make the bash color scheme the same as Ubuntu.
Make Bash on Ubuntu on Windows 10 Look Like the Ubuntu Terminal
- Chinese Fonts
How to download and set Microsoft YaHei Mono, Microsoft YaHei Mono.zip.
- Config http_proxy, https_proxy environment variables in ~/.bash_profile
- For “sudo apt” to work, edit /etc/sudoers, add:
Defaults env_keep = "http_proxy https_proxy ftp_proxy"
Most of them work (tmux, JDK) except perf, etc. (WSL only) WSL2 runs upon Hyper-V; Ubuntu works just like in a VM.
- Install X server like Xming
- Install Fonts for Xming Xming fonts
- Install and run X11 applications
# apt-get install x11-apps $ export DISPLAY=$(ip route list default | awk '{print $3}'):0 $ export LIBGL_ALWAYS_INDIRECT=1 $ xeyes&
- Install Google Chrome and run it
$ wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb $ dpkg -i google-chrome-stable_current_amd64.deb $ google-chrome&
Disable Xming’s access control to allow public access. It looks like a security risk, but it is ok for me.
If you want to display the ssh-ed server’s GUI to the local desktop, edit its /etc/ssh/sshd_config, and turn X11Forwarding on and X11UseLocalHost off. Or install vncserver on the server, and run VNC viewer on desktop PC.
Hotkeys like C-c, C-v, C-ins, S-ins do not work. WSL2 has already fixed it.
Because WSL uses the standard Ubuntu installation, upgrading your packages should look very familiar:
$ sudo apt-get update $ sudo apt-get upgrade
You can also upgrade to the latest version of Ubuntu with the following command (caution, this will take quite some time)!
$ sudo -S apt-mark hold procps strace sudo $ sudo -S env RELEASE_UPGRADER_NO_SCREEN=1 do-release-upgrade
https://github.com/microsoft/WSL/issues/5068#issuecomment-1087206431
This workaround is not a one-time operation. You have to do it whenever the VPN
connection is lost or after a machine reboot.
The idea is to disable vEthernet (WSL) network adapter before connecting to VPN.
In this case, "ip routes /interfaces" of the WSL2 network are unknown for Pulse VPN,
and we can now enable the WSL2 network on top of the established VPN connection.
Step 1 - Disconnect from VPN (if it is connected)
Step 2 - Go to Network Connections
Step 3 - Disable vEthernet (WSL)
Step 4 - Connect to VPN
Step 5 - Enable vEthernet (WSL)
Enabling/Disabling step can also be from PowerShell. For this purpose, run PowerShell as administrator:
Disable the WSL2 network by executing this:
PS> Disable-NetAdapter -Name "vEthernet (WSL)"
Connect to VPN and then enable the WSL2 network by executing this:
PS> Enable-NetAdapter -Name "vEthernet (WSL)."
The root cause of the problem is there is more than one route rule for the WSL IP address. To get the interface index and IP address of vEthernet (WSL), run this command in PowerShell:
PS> Get-NetIpAddress -InterfaceAlias "vEthernet (WSL)" | Format-Table -Property ifIndex,IPAddress
ifIndex IPAddress
------- ---------
49 172.23.48.1
To get similar information for the VPN connection,
PS> Get-NetIpAddress -InterfaceAlias "*VPN*" | Format-Table -Property ifIndex,IPAddress
To get the route rules,
PS> Get-NetRoute -DestinationPrefix 172.23.48.0* | Format-Table -AutoSize
ifIndex DestinationPrefix NextHop RouteMetric ifMetric PolicyStore
------- ----------------- ------- ----------- -------- -----------
20 172.23.48.0/20 0.0.0.0 1 35 ActiveStore
49 172.23.48.0/20 0.0.0.0 256 5000 ActiveStore
To delete the route rules using ifIndex 20,
PS> Remove-NetRoute 172.23.48.0/20 -InterfaceIndex 20
We can also use the “netsh,” and “route” alternatives in CMD.exe instead of PowerShell.
For a detailed explanation, https://wheatevo.com/wsl-2-and-vpn/ is a good summary.
The fstype of Windows is drvfs, while that of Ubuntu is lxfs. As for MySQL, the data-dir should locate on lxfs; if not, put it on mnt/C etc., fdatasync() will report errors, like errno=5.
1. ./mysql-test-run.pl -boot-gdb # start mysqld under gdb 2. break at my_fsync 3. continue to see the error of fdatasync 4. verify the fs of the data path
Found it by comparing the strace of a test program and mysqld, then verified by the upper steps.
Created by Wenliang Zhang.