Windows Subsystem for Linux

Visiting Linux from Windows can be made easier since Windows 10 support Ubuntu etc. In the old good days, we can use Cygwin, MSYS, putty etc. to mimic the Linux environment or visit the Linux boxes. The user experience is not as good as the native Linux. Now with WSL, the life is changed.

Installation

Turn on the developer mode or download and run ./Ubuntu.appx from Microsoft.

Config

  1. Make bash color scheme the same as Ubuntu.

    Make Bash on Ubuntu on Windows 10 Look Like the Ubuntu Terminal

  2. Chinese Fonts

    How to download and set Microsoft YaHei Mono, Microsoft YaHei Mono.zip.

Proxy

See http-proxy.

  1. Config httpproxy, httpsproxy environment variables in ~/.bashprofile
  2. For sudo apt to work, edit /etc/sudoers, add:

    Defaults env_keep = “http_proxy https_proxy ftp_proxy”

Useful tools in bash

Most of them works (tmux, jdk) except perf etc.

X Windows

  1. Install X server like xming
  2. Install and run X11 applications

    $ sudo apt-get install x11-apps $ export DISPLAY=:0 $ xeyes&

If want to display the ssh-ed server’s GUI to local desktop, edit its /etc/ssh/sshdconfig, turn X11Forwarding on and X11UseLocalHost off. Or install vncserver on the server, and run vnc viewer on desktop PC.

Known limitations of bash

Hotkeys like C-c, C-v, C-ins, S-ins not work in early versions. Maybe it is changed, see hotkey.

Upgrade Ubuntu

Upgrade Ubuntu

Because WSL uses the standard Ubuntu installation, upgrading your packages should look very familiar:

$ sudo apt-get update
$ sudo apt-get upgrade

You can aso 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

Difference between drvfs and lxfs

The fstype of Windows is drvfs, while that of Ubuntu is lxfs. As for MySQL, the data dir should locate on lxfs, if not, and 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.

[ WSL ]
Written on January 28, 2019