User Tools

Site Tools


other:win10wsl

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
other:win10wsl [2018/11/16 15:36]
jypeter [Installing an X server]
other:win10wsl [2019/06/03 15:56] (current)
jypeter Clarified the "used disk space" and mentioned WSL v2
Line 1: Line 1:
 ====== Windows Subsystem for Linux, and Ubuntu ====== ====== Windows Subsystem for Linux, and Ubuntu ======
  
-Read the beginning ​of the [[https://​docs.microsoft.com/​en-us/​windows/​wsl/​about|Windows Subsystem for Linux Documentation]] for a quick WSL description on the Microsoft site+<note warning>​What is described on this page was tested with **WSL v1**, and not WSL2 (that will be introduced mid-2019). It will be possible to install both WSL v1 and v2 on the same computer and WSL v2 will theoretically have faster I/O, but we recommend you use WSL v1 for now</​note>​ 
 + 
 +Read just the top of the [[https://​docs.microsoft.com/​en-us/​windows/​wsl/​about|Windows Subsystem for Linux Documentation]] for a quick WSL description on the Microsoft site
  
 In a few words, WSL is not Linux, it's more a way to [[https://​blogs.msdn.microsoft.com/​wsl/​2016/​06/​15/​wsl-file-system-support/​|share files between Windows and Linux]] (it's OK to skip this rather technical link!). That's why you need //WSL **and** a Linux distribution//​. In a few words, WSL is not Linux, it's more a way to [[https://​blogs.msdn.microsoft.com/​wsl/​2016/​06/​15/​wsl-file-system-support/​|share files between Windows and Linux]] (it's OK to skip this rather technical link!). That's why you need //WSL **and** a Linux distribution//​.
Line 7: Line 9:
 ===== Prerequisites ===== ===== Prerequisites =====
  
-  * Windows 10 64-bit ​ (ideally ​[[other:​win10misc#​windows_10_versions|build 16215 or later]]) +  * [[other:​win10misc#​windows_10_versions|up-to-date Windows 10 64-bit]]: this should automatically be the case. This page is based on a laptop running the //Fall (September) 2018 edition//, and Microsoft is starting to push the March 2019 (aka //1903//edition ​ 
-  * Enough space on ''​C:''​. Microsoft instructions say //The Windows Subsystem for Linux only runs on your system drive (usually this is your C: drive)// +  * //Enough// space on ''​C:''​. Microsoft instructions say //The Windows Subsystem for Linux only runs on your system drive (usually this is your C: drive)// 
-    * The initial installation of Ubuntu ​seems to use 555 Mo of disk space, but you will get a basic Linux with no graphics, and you may need space for installing more applications +    * The initial installation of Ubuntu ​does not //​seem// ​to use much disk space (< 1 Gb), but you will get a basic Linux with no graphics, and you may need space for installing more applications 
-    * ''/''​ and ''/​home''​ will be on ''​C:'',​ but the data files can be on any disk/​partition of the computer, and all the partitions will be available and accessible in ''/​mnt/'',​ so you can store things ​on other partitions +    * ''/''​ and ''/​home''​ will be on ''​C:'',​ but the data files can be on any disk/​partition ​(or external drive) ​of the computer, and all the partitions will be available and accessible in ''/​mnt/'',​ so you can store data on other partitions 
-    * The files will be installed in hidden partitions of the user's directory on ''​C:''​. Other users of the same Windows 10 computer would have to install Ubuntu again, in their own directory+    * The files will be installed in **hidden partitions of the current ​user's directory on ''​C:​''​**:​ e.g. ''​C:​\Users\johndoe''​. Other users of the same Windows 10 computer would have to install Ubuntu again, in their own user directory 
 +      * Checking the properties of ''​C:​\Users\johndoe''​ will **not** report an accurate size and number of files, because lots of files and directories are hidden! On the test laptop, the reported size of the user backed up directory (with [[other:​win10apps#​syncbackfree|SyncBackFree]]) was ~20 Gb (user data, WSL+Ubuntu, custom install of the CDAT 8.1 python distribution) 
 +      * Be sure to monitor the remaining free space on ''​C:''​!
  
 ===== Installation ===== ===== Installation =====
Line 19: Line 23:
     * In the **Microsoft Store**, just search //Linux// and select Ubuntu (Ubuntu 16.04 LTS was available when this page was created)     * In the **Microsoft Store**, just search //Linux// and select Ubuntu (Ubuntu 16.04 LTS was available when this page was created)
  
-Disk space used in the Windows directory of the user installing Ubuntu (''​C:​\users\johndoe''​):​+===== After the installation =====
  
-^ Step ^ Size ^ Number of files ^ Number of directories ^ +Once you have completed ​the installation steps, you'll get a Ubuntu ​machine, with a //root// and user account (preconfigured to use //sudo//) and lots of pre-installed applications (but no graphics).
-| Before installing Ubuntu | 443 Mb |  2507  |  1974  | +
-| After getting Ubuntu from Microsoft Store |  445 Mo  |  2515  |  1989  | +
-| After Launching Ubuntu ​the first time |  998 Mo  |  30851  |  4931  | +
-| After [[#​updating_linux|updating ​Ubuntu]] |  1.14 Gb  |  31054  |  4947  | +
-| After adding some [[#​adding_useful_packages|Useful packages]] |  1.47 Gb  |  35918  |  5108  |+
  
-===== After the installation ​=====+==== Opening a terminal ​==== 
 + 
 +  * Opening ​the first terminal will start WSL+Ubuntu 
 +  * Closing all terminals will not stop WSL+Ubuntu. Read the [[#​rebooting_wsl|rebooting WSL section]] if you need a clean start without rebooting Windows 
 + 
 +Having a terminal you can efficiently interact with is the basis of your future work with WSL+Ubuntu! You can optionally read the [[https://​nickjanetakis.com/​blog/​conemu-vs-hyper-vs-terminus-vs-mobaxterm-terminator-vs-ubuntu-wsl|ConEmu vs Hyper vs Terminus vs MobaXTerm Terminator vs Ubuntu WSL]] blog if you want more details 
 + 
 +=== The default terminal === 
 + 
 +The **Default WSL+Ubuntu //​terminal//​** is basically a //bash// shell running inside a regular Windows ''​cmd''​ window. You do not need to have an //X server// running to use it 
 + 
 +There are several ways to open a default terminal: 
 +  * select //Ubuntu// from the Start menu\\ You should also add the //Ubuntu// icon to the task bar 
 +    * right-click on the Ubuntu icon (in the Start menu) -> More -> Pin to the task bar 
 +  * click on the //Ubuntu// icon on the task bar 
 +    * to open more windows: right-click on the //Ubuntu// icon on the task bar -> Ubuntu 
 +  * type ''​wsl''​+''<​Return>''​ in the (Cortana) Search field on the task bar 
 + 
 +== Copy/paste in the default terminal == 
 + 
 +Follow the steps in [[https://​blogs.msdn.microsoft.com/​commandline/​2018/​04/​13/​copy-and-paste-arrives-for-linuxwsl-consoles/​|Copy and Paste arrives for Linux/WSL Consoles]] and you will then be able to **copy/​paste by using ''​Shift+Ctrl+C/​V''​** 
 + 
 +  * The //QuickEdit mode// should already be selected by default and you can also: 
 +    * **select** text with the left mouse button 
 +    * **paste** the selected text with the right mouse button (click **twice** after a new selection) 
 +  * Use ''​Alt''​+''<​Return>''​ to toggle the terminal to full screen (maybe more useful options [[https://​docs.microsoft.com/​en-us/​previous-versions/​orphan-topics/​ws.11/​mt427362(v=ws.11)|here?​]]) 
 + 
 +=== The WSLtty terminal === 
 + 
 +[[https://​github.com/​mintty/​wsltty|WSLtty]] allows you to use Mintty as a terminal for WSL. You do not need to have an //X server// running to use it 
 + 
 +  * Download and execute the latest [[https://​github.com/​mintty/​wsltty/​releases|installer]] (the most recent ''​wsltty-*-install.exe''​ file) 
 +  * You will then have different ways to start a terminal: 
 +    * //WSL terminal// shorcut on the desktop 
 +    * //Ubuntu terminal// and //WSL Terminal// in the //Start// menu 
 +  * Open a terminal and right-click in it to discover/​use the options 
 +    * More options with CTRL+right-click 
 +    * You can cycle between the open WSLtty terminals with CTRL+Tab and Shift+CTRL+Tab 
 +  *  [[https://​github.com/​mintty/​mintty/​wiki|Technical stuff]] (on the Mintty wiki) 
 + 
 +=== Terminals started from Linux === 
 + 
 +You can install additional //​graphical//​ terminals inside the Linux running in WSL, but you will need to have a running //X server// if you want to open them. In these terminals, the //usual// Linux copy/paste rules will apply! 
 + 
 +== xterm == 
 + 
 +  * Install with: ''​apt-get install xterm''​ 
 +  * Start from another terminal with: ''​xterm &''​ 
 + 
 +== xfce-terminal ​==
  
-Once you have completed the installation steps, you'll get a Ubuntu machine, with a //root// and user account (preconfigured to use //sudo//) and lots of pre-installed applications (but no graphics). If you want to open a terminal, just select //Ubuntu// from the Start menu, and you'll get a bash terminal ​running inside a regular Windows ​''​cmd'' ​program+  * Install with: ''apt-get install xfce4-terminal'​
 +  * Start from another ​terminal ​with: ''​xfce4-terminal &''​
  
 ==== Location of the files ==== ==== Location of the files ====
  
-Read the detailed [[https://​blogs.msdn.microsoft.com/​wsl/​2016/​06/​15/​wsl-file-system-support/​|WSL File System Support]] page if you want to (try to) understand how things work and how both systems can share files.+You can optionally read the detailed [[https://​blogs.msdn.microsoft.com/​wsl/​2016/​06/​15/​wsl-file-system-support/​|WSL File System Support]] page if you want to (try to) understand how things work and how both systems can share files.
  
 === Linux files seen from Windows === === Linux files seen from Windows ===
Line 57: Line 106:
 H:              366G  138M  366G   1% /​mnt/​h</​code>​ H:              366G  138M  366G   1% /​mnt/​h</​code>​
  
 +Read the [[#​mounting_disks_and_network_drives|Mounting disks and network drives]] section if you want to access remote server disks on your local network, or just wan to access USB disks/​sticks on your local computer.
 +
 +=== Misc ===
 +
 +  * The ''​wslpath''​ command can be used to make Windows<​->​Linux path conversion
 ==== Linux version installed ==== ==== Linux version installed ====
  
Line 90: Line 144:
 ii  zlib1g:​amd64 ​                                         1:​1.2.8.dfsg-2ubuntu4.1 ​        ​amd64 ​                          ​compression library - runtime ii  zlib1g:​amd64 ​                                         1:​1.2.8.dfsg-2ubuntu4.1 ​        ​amd64 ​                          ​compression library - runtime
  
-$ dpkg --list > /​mnt/​h/​Scratch/​jypeter/​pkg_initial.txt+$ dpkg --list > /​mnt/​h/​Scratch/​jyp/​pkg_initial.txt
  
-$ wc -l /​mnt/​h/​Scratch/​jypeter/​pkg_initial.txt +$ wc -l /​mnt/​h/​Scratch/​jyp/​pkg_initial.txt 
-437 /​mnt/​h/​Scratch/​jypeter/​pkg_initial.txt</​code>​+437 /​mnt/​h/​Scratch/​jyp/​pkg_initial.txt</​code>​
  
 Full list of installed packages: {{:​other:​pkg_initial.txt|pkg_initial.txt}} Full list of installed packages: {{:​other:​pkg_initial.txt|pkg_initial.txt}}
 +
 +==== Update ubuntu ====
 +
 +Use the following to update your ubuntu installation:​
 +
 +<​code>​$ sudo -s
 +$ apt-get update
 +$ apt-get upgrade</​code>​
 +
 +==== Managing WSL ====
 +
 +This is just place to store some technical information,​ that will probably not be needed by most people
 +
 +  * [[https://​docs.microsoft.com/​en-us/​windows/​wsl/​wsl-config#​managing-multiple-linux-distributions|command-line options]]
 +  * [[https://​docs.microsoft.com/​en-us/​windows/​wsl/​wsl-config#​set-wsl-launch-settings|Changing the start-up settings]]
 +  * [[https://​docs.microsoft.com/​fr-fr/​windows/​wsl/​interop#​invoking-wsl-from-the-windows-command-line|Invoking WSL from the Windows Command Line]]
 +  * [[https://​docs.microsoft.com/​fr-fr/​windows/​wsl/​interop#​invoking-windows-binaries-from-wsl|Invoking Windows binaries from WSL]]
 +  * News in the [[https://​devblogs.microsoft.com/​commandline/​|Windows Command Line Tools For Developers]] WSL blog
  
 ===== Getting ready for some real work ===== ===== Getting ready for some real work =====
 +
 +<note important>​We often assume below that you are using the **root** account (''​sudo -s''​),​ or ''​sudo''​ when executing the ''​apt*''​ installation commands, and othe admin commands</​note>​
 +
 +==== Package management ====
  
 [[https://​www.howtogeek.com/​63997/​how-to-install-programs-in-ubuntu-in-the-command-line/​|apt-get tutorial]] if you are more used to Fedora/​RedHat ''​yum''/''​dnf''​ and //rpm// packages [[https://​www.howtogeek.com/​63997/​how-to-install-programs-in-ubuntu-in-the-command-line/​|apt-get tutorial]] if you are more used to Fedora/​RedHat ''​yum''/''​dnf''​ and //rpm// packages
  
 +  * Install the **aptitude** package manager: ''​apt-get install aptitude''​
 +    * [[https://​doc.ubuntu-fr.org/​aptitude|details]] (fr)
 +  * Install the **synaptic** package manager: ''​aptitude install synaptic''​
 +    * [[https://​doc.ubuntu-fr.org/​synaptic|details]] (fr)
 +
 +=== Useful commands ===
 +
 +  * ''​dpkg -l'':​ list installed packages
 +  * ''​dpkg -L package_name'':​ list files installed from ''​package_name''​
 +  * ''​dpkg -S path/​command'':​ name of the package used to install ''​path/​command''​
 ==== Installing an X server ==== ==== Installing an X server ====
 +
 <WRAP center round important 60%> <WRAP center round important 60%>
  
 Need to check the best way to do this and get the best (and not blurry...) images Need to check the best way to do this and get the best (and not blurry...) images
-  * [[https://​askubuntu.com/​questions/​993225/​whats-the-easiest-way-to-run-gui-apps-on-wsl-as-of-2018|What'​s the easiest way to run GUI apps on WSL as of 2018?]] 
   * [[https://​token2shell.com/​x410/​|x410]] Commercial X server that looks promising   * [[https://​token2shell.com/​x410/​|x410]] Commercial X server that looks promising
 </​WRAP>​ </​WRAP>​
  
 +=== Installing x410 ===
  
-  * Download and install [[https://​sourceforge.net/​projects/​vcxsrv/​|VcXrsv]] +=== Installing ​VcXrsv ​===
-    * blurry text due to [[https://​www.reddit.com/​r/​bashonubuntuonwindows/​comments/​7h5xru/​did_high_dpi_break_for_anyone_else_lately/​|wrong dpi]]? Screen size in xdpyinfo also seems wrong +
-      * check [[https://​gist.github.com/​stowler/​9921780|options]]?​+
  
-<wrap hi>Next => Check the rest of [[https://github.com/QMonkey/wsl-tutorial|wsl-tutorial]]</wrap> +  * Download and install ​the free [[https://sourceforge.net/​projects/​vcxsrv/​|VcXrsv]] X server (or try the [[https://​token2shell.com/x410/|x410]] or [[https://​mobaxterm.mobatek.net/​|MobaXterm]] commercial servers) 
-==== Updating Linux ====+    * Warning: dont' forget to [[other:​win10misc#​vcxsrv_x_server|fix the compatibility settings]], otherwise the content of the X windows will appear blurry
  
-<code>$ apt-get update +=== Configuration === 
-$ apt-get upgrade</code>+ 
 +  * Set the DISPLAY variable in the shell (by hand, or in the shell init file) 
 +    * ''​export DISPLAY=localhost:​0.0''​ 
 +    * <wrap em>Warning!</​wrap>​ ''​export DISPLAY=:​0.0''​ will also work for using graphical windows locally, but will fail when trying to open a window on a remote computer, with a ''​connect /tmp/.X11-unix/X0: No such file or directory''​ error message ([[https://​unix.stackexchange.com/​questions/​57138/​why-does-my-x11-forwarding-attempt-fail-with-connect-tmp-x11-unix-x0-no-such/​|source]]) 
 +  * Need to determine if/when ''​export LIBGL_ALWAYS_INDIRECT=1''​ is useful 
 +    * it breaks ''​glxgears''​ with x410 
 + 
 +Note: see X410 tips to automatically start X410 
 + 
 +=== Resources === 
 + 
 +    * Check [[https://​askubuntu.com/​questions/​993225/​whats-the-easiest-way-to-run-gui-apps-on-wsl-as-of-2018|What'​s the easiest way to run GUI apps on WSL as of 2018?]] 
 +    * Check the X410 [[https://​token2shell.com/​howto/​x410/​|Tips and Tricks]] that can probably apply to other X servers 
 +    * Check the rest of [[https://​github.com/​QMonkey/​wsl-tutorial|wsl-tutorial]]
  
 ==== Adding useful packages ==== ==== Adding useful packages ====
 +
 +Reminder: you need to use the ''​root''​ account (with ''​sudo -s''​) in order to use the following commands
  
 <​code>​$ apt-get install gcc libglu1-mesa mesa-utils libsm6 x11-apps <​code>​$ apt-get install gcc libglu1-mesa mesa-utils libsm6 x11-apps
-$ apt-get install xterm</​code>​ 
  
-TO DO +# Check the "​Terminals started from Linux" section 
-  * [[https://​www.emacswiki.org/emacs/CategoryWSL|emacs]]+# if you need to install extra terminals 
 + 
 +# Install emacs 
 +$ apt-get install emacs25 
 + 
 +# Install pdf (evince) and image (eog) viewers 
 +$ apt-get install evince eog 
 + 
 +# Install wslu to improve the Windows<​->​Linux communication 
 +$ apt-get install wslu 
 + 
 +# The packages below are useful for dealing with climate data 
 +# in netCDF files (and are also requirements of CLIMAF) 
 +$ aptitude install imagemagick nco cdo netcdf-bin ncview exiv2</​code>​ 
 + 
 + 
 +===== Updating WSL and ubuntu ===== 
 + 
 +==== WSL ==== 
 + 
 +WSL is automatically updated when Windows 10 is updated 
 + 
 +[[https://​docs.microsoft.com/​en-us/​windows/​wsl/​wsl-config#​managing-multiple-linux-distributions| WSL command line options]] 
 + 
 +==== Updating ubuntu ==== 
 + 
 +The ''​Ubuntu **16**.04.3 LTS''​ that was initially installed from the //Windows Store// when the test computer was running ''​Win 10 1709''​ was automatically updated to ''​Ubuntu **18**.04.2 LTS''​ when the computer was updated to ''​Win 10 1809''​. 
 + 
 +<​code>​$ lsb_release -a 
 +No LSB modules are available. 
 +Distributor ID: Ubuntu 
 +Description: ​   Ubuntu 18.04.2 LTS 
 +Release: ​       18.04 
 +Codename: ​      ​bionic</​code>​ 
 + 
 +We also ran the ''​do-release-upgrade''​ command to complete the upgrade (from 16.04 to 18.04) [ [[https://​devblogs.microsoft.com/​commandline/​upgrading-ubuntu/​|More info from WSL team]] - [[https://​doc.ubuntu-fr.org/​migration|more info from Ubuntu]] ] 
 + 
 +An we then ran the usual upgrade commands. These commands can be run any time for updating the installed packages 
 +<​code>​$ sudo -s 
 +$ apt-get update 
 +$ apt-get upgrade</​code>​ 
 + 
 +Full list of the resulting {{ :​other:​pkg_190221.txt |installed packages}}, generated with 
 + 
 +<​code>​$ dpkg --list >$ dpkg --list > /​mnt/​h/​Scratch/​jyp/​pkg_190221.txt 
 +$ wc -l /​mnt/​h/​Scratch/​jyp/​pkg_190221.txt 
 +578 /​mnt/​h/​Scratch/​jyp/​pkg_190221.txt</​code>​ 
 + 
 + 
 +===== Advanced configuration ===== 
 + 
 +==== Get configuration files ==== 
 + 
 +  * You can either use your existing Linux configuration files, or download some example files in your WSL home directory and use (and improve) them as directed (or as you wish) 
 +    * <​code>​$ cd 
 +$ scp -pr jypeter@ssh1.lsce.ipsl.fr:​WSL_config .</​code>​ 
 +    * You get a default ''​.bashrc''​ file in your home directory when your WSL account is created. Add the following line at the end of ''​~/​.bashrc''​ to use what is defined in the downloaded ''​WSL_config''​ directory:​\\ ''​source ~/​WSL_config/​bashrc_extra.sh''​ 
 +  * You can either copy the full ''​.ssh''​ directory of your Linux account, or just get the //private key// files: 
 +    * <​code>​$ cd 
 +$ scp -pr your_login@ssh1.lsce.ipsl.fr:​.ssh .</​code>​ 
 +    * Make sure you also read the [[other:​win10wsl#​ssh_agent_and_keys_related_questions|ssh,​ agent and keys related questions]] section! 
 +==== ssh, agent and keys related questions ==== 
 + 
 +This assumes that you have already created a private/​public ssh key pair and that the private key is available somewhere in the Windows 10 computer 
 + 
 +=== ssh from WSL === 
 + 
 +== Authorizing ssh to use old dsa keys == 
 + 
 +//dsa// ssh keys are disabled by default (becoming obsolete). ''​ssh''​ will ask for your password even if you have a ''​~/​.ssh/​id_dsa''​ file. ''​ssh -v''​ will print ''​Skipping ssh-dss key /​home/​jyp/​.ssh/​id_dsa - not in PubkeyAcceptedKeyTypes''​. The solution is to use the user config file to authorize dsa ([[https://​unix.stackexchange.com/​a/​247614|source]]) 
 +    * Add ''​PubkeyAcceptedKeyTypes +ssh-dss''​ to ''​~/​.ssh/​config''​ 
 +    * Make sure the config file has the correct access rights: ''​chmod 600 config''​ 
 + 
 +== Using Putty Pageant as an ssh agent == 
 + 
 +This assumes that you have converted your private ssh key with ''​PuTTYgen''​ and unlocked it in Pageant 
 + 
 +  * Download the required binaries from the [[https://​github.com/​vuori/​weasel-pageant|weasel-pageant github page]] and extract them to a Windows directory, e.g. ''​C:​\Utils\weasel-pageant-x.x''​ 
 +  * Add the following line to your ''​~/​.bashrc''​ file:\\ ''​eval $(C:​\Utils\weasel-pageant-x.x/​weasel-pageant -rb -a $HOME/​.weasel-pageant.sock)''​ 
 +  * Open a new terminal: 
 +    * Type ''​ssh-add -l'':​ it will display either ''​The agent has no identities'',​ or as many lines as you have entered keys in Pageant 
 +    * Type ''​ssh user@host''​ to connect to a computer where you have your public key 
 + 
 +Note: the other similar solutions are [[https://​github.com/​rupor-github/​ssh-agent-wsl|ssh-agent-wsl]] (the key is stored in the Windows ssh-agent instead of Pageant) or [[https://​github.com/​benpye/​wsl-ssh-pageant|wsl-ssh-pageant]] 
 + 
 +== Using Ubuntu as an ssh-agent == 
 + 
 +We **do not use this** now, because there will be one running ssh-agent per terminal, and the key is stored only for the current terminal  
 + 
 +  * It's not possible to add a key to ssh-agent. '​ssh-add'​ will print ''​Could not open a connection to your authentication agent''​ 
 +    * type ''​eval `ssh-agent -s`''​ (or ''​eval $(ssh-agent)''​) before using ''​ssh-add''​ 
 + 
 +See if a solution appears for [[https://​unix.stackexchange.com/​questions/​504083/​wsl-keeping-ssh-private-key-accessible-as-long-as-i-dont-restart-windows-10-l/​|WSL:​ Keeping ssh private key accessible as long as I don't restart Windows 10 (like the behaviour of pageant)]] 
 + 
 +=== ssh to WSL === 
 + 
 +FIXME 
 + 
 +Need to find a way to ssh from the Win10 part of the machine to the WSL part, and from outside the machine to the WSL part 
 + 
 +It would probably already be enough to enable the ssh server on Win10 (the [[https://​devblogs.microsoft.com/​powershell/​using-the-openssh-beta-in-windows-10-fall-creators-update-and-windows-server-1709/​|ssh 1709 release beta features]] are now officially in Win10) 
 + 
 +[[https://​www.google.com/search?​client=firefox-b-d&​q=wsl+ssh|Google search: wsl ssh]] 
 + 
 +  * [[https://​gist.github.com/​dentechy/​de2be62b55cfd234681921d5a8b6be11|How to automatically start ssh server on boot on Windows Subsystem for Linux]] 
 +  * [[https://​www.illuminiastudios.com/​dev-diaries/​ssh-on-windows-subsystem-for-linux/​|SSH on Windows Subsystem for Linux]] 
 +  * [[https://​superuser.com/​questions/​1123552/​how-to-ssh-into-wsl|How to SSH into WSL]] 
 + 
 +==== Creating shortcuts to Linux programs on the Windows desktop ==== 
 + 
 +  * Install [[https://​github.com/​wslutilities/​wslu|wslu]] (A collection of utilities for WSL) if it is not already installed 
 +    * ''​aptget install wslu''​ 
 +  * Have a quick look at the wslu [[https://​github.com/​wslutilities/​wslu|github]] page and [[https://​github.com/​wslutilities/​wslu/​wiki|wiki]] to find about the available tools (that you may need later) 
 +  * Create a shortcut (e.g. to emacs) with: ''​wslusc -g emacs''​ 
 +  * You can optionally get some information about the [[https://​github.com/​Microsoft/​WSL/​issues/​3404|technical details]] 
 + 
 +==== emacs configuration ==== 
 + 
 +  * [[other:​win10wsl#​get_configuration_files|Get configuration files]] 
 +  * Use the provided emacs configuration file (or your own): 
 +    * <​code>​$ cd 
 +$ ln -s WSL_config/​emacs .emacs</​code>​ 
 +  * Use ''​wslusc''​ to create a shortcut to **emacs** **on your Windows desktop**:​\\ ''​wslusc -g emacs''​ 
 +    * This will make it easier to start emacs, but since this is a graphical Linux application,​ you need to have an X server running before you click on the shortcut! 
 +==== Mounting disks and network drives ==== 
 + 
 +By default, the local disks and the external USB disks available (and decrypted!) when the first WSL terminal is opened are automatically available (//​mounted//​) in ''/​mnt''​ : the content of ''​C:​\''​ is available in ''/​mnt/​c'',​ etc... The list is refreshed when Windows (or just WSL) is rebooted . 
 + 
 +Extra local disks or //network drives// (what you can access by opening ''​\\dfshost\dfs\''​ in the file explorer when you are on the LSCE network) can be either mounted on the fly with the ''​mount''​ command, or automatically by configuring the ''/​etc/​fstab''​ file. 
 + 
 +You will access the network drives with the access rights you have in the current Windows session (and you may have to access the drives in Windows before you can mount them in WSL) 
 + 
 +<wrap hi>​Warning!</​wrap>​ In all cases, the owner, groups and permissions displayed may not be accurate (but the actual access rights will apply). 
 +  * the user/group of the files may appear as ''​your_login''/''​your_login''​ or ''​root''/''​root''​ 
 +  * the access rights may appear as ''​rwxrwxrwx''​ even if the actual rights are more restrictive 
 +  * more details in the //​metadata//​ section 
 + 
 +=== Enabling metadata === 
 + 
 +Some access rights handling can be partially corrected by automatically enabling the ''​metadata''​ mount option. This will allow you to use ''​chmod''/''​chown''​ on local NTFS disks (e.g. ''/​mnt/​c/​Users/​your_login''​). ''​sudo -s''​ and then create a ''/​etc/​wsl.conf''​ with the following content: 
 + 
 +<​code>​[automount] 
 +options = "​metadata"</​code>​ 
 + 
 +You need to [[other:​win10wsl#​rebooting_wsl|restart WSL+ubuntu]] to activate the new content of ''/​etc/​wsl.conf''​. See below an example of the ''​mount -l''​ output: 
 +  * Before: ''​C:​ on /mnt/c type drvfs (rw,​noatime,​uid=1000,​gid=1000,​case=off)''​ 
 +  * After: ''​C:​ on /mnt/c type drvfs (rw,​noatime,​uid=1000,​gid=1000,​metadata,​case=off)''​ 
 + 
 +Optional: more details about [[https://​devblogs.microsoft.com/​commandline/​automatically-configuring-wsl/​|wsl.conf]] and [[https://​devblogs.microsoft.com/​commandline/​chmod-chown-wsl-improvements/​|metadata and access rights management]] 
 + 
 +=== On-the-fly mount === 
 + 
 +You have to create a //mount point// in the existing ''/​mnt''​ directory and then use the ''​mount''​ command 
 + 
 +<​code>​$ sudo -s 
 + 
 +# Create the mount point (once) 
 +$ mkdir /​mnt/​scratch01 
 + 
 +# Mount the remote disk 
 +$ mount -t drvfs '​\\dfshost\dfs\scratch01'​ /​mnt/​scratch01 
 + 
 +# Unmount the disk, or just shutdown Windows or WSL when you are finished 
 +$ umount /​mnt/​scratch01</​code>​ 
 + 
 +If you connect a USB disk/stick and windows sees it as a new ''​J:​\''​ drive, you can also manually mount it 
 + 
 +<​code>​$ sudo -s 
 + 
 +# Create the mount point (once) 
 +$ mkdir /mnt/j 
 + 
 +# Mount the USB disk 
 +$ mount -t drvfs J: /mnt/j 
 + 
 +# Unmount the disk, or just shutdown Windows or WSL when you are finished 
 +$ umount /​mnt/​j</​code>​ 
 + 
 +=== Automatic mount === 
 + 
 +The disks defined in ''/​etc/​fstab''​ will be automatically mounted when you start WSL and if they are actually accessible from your Windows session (e.g. ''​\\dfshost\dfs''​ can only be accessed from the LSCE network) 
 + 
 +You need to add 1 line per mount point to ''/​etc/​fstab'',​ and create (once) the directories that will be used for mounting the disks 
 + 
 +<​code>​$ sudo -s 
 + 
 +# Create the mount points (once) 
 +$ mkdir /​mnt/​home_jyp /​mnt/​scratch_jyp 
 + 
 +# Make a backup copy of /​etc/​fstab 
 +$ cp -p /etc/fstab /​etc/​fstab.bak 
 + 
 +# Add lines to /etc/fstab associating mount points and directories 
 +$ cat /​etc/​fstab 
 +LABEL=cloudimg-rootfs ​  / ​       ext4   ​defaults ​       0 0 
 +\\dfshost\dfs\users\jyp /​mnt/​home_jyp drvfs defaults 0 0 
 +\\dfshost\dfs\scratch01\jyp /​mnt/​scratch_jyp drvfs defaults 0 0 
 + 
 +# Try to mount all the disks in /​etc/​fstab 
 +$ mount -a</​code>​ 
 + 
 +=== Resources === 
 + 
 +Useful ''​mount''​ options: 
 +  * ''​mount -a''​ (must be //root//): mount everything specified in ''/​etc/​fstab''​ 
 +  * ''​umont /​mnt/​scratch01''​ (must be //root//): unmount the disk accessible through ''/​mnt/​scratch01''​ 
 +  * ''​mount -l'':​ list all the mounted disks and the mount options (useful when you are using the default mount options and want to know which options were actually applied) 
 + 
 +Useful links (used for writing this section): 
 +  * [[https://​devblogs.microsoft.com/​commandline/​automatically-configuring-wsl/​|Automatically Configuring WSL]] 
 +  * [[https://​blogs.msdn.microsoft.com/​wsl/​2017/​04/​18/​file-system-improvements-to-the-windows-subsystem-for-linux/​|File System Improvements to the Windows Subsystem for Linux]] 
 +  * [[https://​devblogs.microsoft.com/​commandline/​chmod-chown-wsl-improvements/​|Chmod/​Chown WSL Improvements]] (the new //​metadata//​ option) 
 +  * [[https://​github.com/​Microsoft/​WSL/​issues/​2636|Automount additonal filesystems from fstab]] 
 +  * [[https://​gist.github.com/​sgtoj/​f82990bcd9e89db49b84e2d2e70b281d|Ubuntu for Windows: Mounting C: Drive to WSL's Root]] 
 + 
 +==== Rebooting WSL ==== 
 + 
 +It is not possible to reboot WSL like a regular Linux computer 
 +  * ''​shutdown -r now''​ will generate an error message 
 +  * WSL keeps on running even when all the terminals are closed 
 + 
 +Rebooting the Windows computer will of course reboot WSL but it's useful to be able to just reboot WSL: 
 +  * to force WSL to recognize new disk drives and make them available as ''/​mnt/<​new_drive_letter''​ 
 +  * to force WSL to recognize drives that were still encrypted when the first terminal was started 
 + 
 +WSL can be rebooted (all the terminals and processed will be closed/​killed) by restarting the //WSL service// (''​LxssManager''​) 
 +  * from the //​Services//​ tab of the Task manager or the //​Services//​ program (launch ''​services.msc''​) 
 +    * Right-click on the ''​LxssManager''​ service and select //​Restart//​ 
 +  * from a //​Powershell//​ in admin mode (right-click on the Windows //Start// button) 
 +    * Type ''​Get-Service LxssManager | Restart-Service''​ 
 + 
 +Source: google ''​wsl lxssmanager''​ ([[https://​www.how2shout.com/​how-to/​how-to-reboot-wsl-windows-subsystem-linux-in-windows-10.html|most usable answer]]) 
 + 
 +==== Creating a backup ==== 
 + 
 +Best thing is probably to create tar file of the user's home directory, and get a list of installed applications and updated settings (e.g ''/​etc/​fstab''​) 
 + 
 +Check [[https://​askubuntu.com/​questions/​9135/​how-to-backup-settings-and-list-of-installed-packages|How to backup settings and list of installed packages]] 
 +==== Uninstalling WSL ====
  
 +Not too sure about this part...
  
 +  * Make a backup of whatever you had in your Ubuntu home directory, and all the files and settings that are not in the ''/​mnt''​ directories
 +  * Find how to unregister Ubuntu on the [[https://​docs.microsoft.com/​en-us/​windows/​wsl/​wsl-config|Manage and configure Windows Subsystem for Linux]] page
 +  * and then disable WSL???
 ===== Other WSL resources and links ===== ===== Other WSL resources and links =====
  
Line 134: Line 475:
   * [[https://​docs.microsoft.com/​en-us/​windows/​wsl/​troubleshooting|Troubleshooting]]   * [[https://​docs.microsoft.com/​en-us/​windows/​wsl/​troubleshooting|Troubleshooting]]
   * [[https://​docs.microsoft.com/​en-us/​windows/​wsl/​user-support|User Accounts and Permissions]]   * [[https://​docs.microsoft.com/​en-us/​windows/​wsl/​user-support|User Accounts and Permissions]]
 +  * [[https://​devblogs.microsoft.com/​commandline/​|Windows Command Line Tools For Developers]]
 +    * Very useful Microsoft blogs about //Windows Console, Command-Line,​ Windows Subsystem for Linux, WSL, Linux//
   * [[https://​github.com/​Microsoft/​WSL|WSL @ github]]   * [[https://​github.com/​Microsoft/​WSL|WSL @ github]]
   * [[https://​stackoverflow.com/​questions/​tagged/​windows-subsystem-for-linux|WSL @ stackoverflow]]   * [[https://​stackoverflow.com/​questions/​tagged/​windows-subsystem-for-linux|WSL @ stackoverflow]]
 +  * [[https://​wpdev.uservoice.com/​forums/​266908-command-prompt/​filters/​top|WSL @ UserVoice portal]]
 +  * [[https://​github.com/​sirredbeard/​Awesome-WSL|Awesome-WSL]]:​ An Awesome collection of Windows Subsystem for Linux information,​ distributions,​ and tools
   * [[https://​virtualizationreview.com/​articles/​2018/​01/​10/​hands-on-with-wsl-installation-and-new-features.aspx|Hands-On with WSL: Installation & New Features]] (five nice and useful articles)   * [[https://​virtualizationreview.com/​articles/​2018/​01/​10/​hands-on-with-wsl-installation-and-new-features.aspx|Hands-On with WSL: Installation & New Features]] (five nice and useful articles)
   * [[https://​github.com/​ethanhs/​WSL-Programs|A list of which programs work...]]   * [[https://​github.com/​ethanhs/​WSL-Programs|A list of which programs work...]]
other/win10wsl.1542379013.txt.gz · Last modified: 2018/11/16 15:36 by jypeter