Skip to content

Commit d095603

Browse files
authored
Merge branch 'live' into patch-1
2 parents d9607c6 + de10d64 commit d095603

28 files changed

Lines changed: 984 additions & 739 deletions

.openpublishing.redirection.json

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"source_path": "wsl/install_guide.md",
55
"redirect_url": "/windows/wsl/install-win10",
6-
"redirect_document_id": true
6+
"redirect_document_id": false
77
},
88
{
99
"source_path": "wsl/user_support.md",
@@ -16,9 +16,24 @@
1616
"redirect_document_id": true
1717
},
1818
{
19-
"source_path": "WSL/index.md",
20-
"redirect_url": "about",
19+
"source_path": "wsl/initialize-distro.md",
20+
"redirect_url": "install-win10",
21+
"redirect_document_id": true
22+
},
23+
{
24+
"source_path": "wsl/wsl2-ux-changes.md",
25+
"redirect_url": "compare-versions",
26+
"redirect_document_id": true
27+
},
28+
{
29+
"source_path": "wsl/wsl2-install",
30+
"redirect_url": "install-win10",
31+
"redirect_document_id": false
32+
},
33+
{
34+
"source_path": "wsl/wsl2-install",
35+
"redirect_url": "install-win10",
2136
"redirect_document_id": false
2237
}
2338
]
24-
}
39+
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ If you find doc issues / errors or have an improvement you'd like to suggest, pl
1212

1313
[Rendered documentation website](https://docs.microsoft.com/windows/wsl/)
1414

15-
[Release notes for WSL](https://docs.microsoft.com/en-us/windows/wsl/release-notes)
15+
[Release notes for WSL](https://docs.microsoft.com/windows/wsl/release-notes)
1616

1717
## Microsoft Open Source Code of Conduct
1818

ThirdPartyNotices

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ may be either trademarks or registered trademarks of Microsoft in the United Sta
99
The licenses for this project do not grant you rights to use any Microsoft names, logos, or trademarks.
1010
Microsoft's general trademark guidelines can be found at https://go.microsoft.com/fwlink/?LinkID=254653.
1111

12-
Privacy information can be found at https://privacy.microsoft.com/en-us/
12+
Privacy information can be found at https://privacy.microsoft.com/
1313

1414
Microsoft and any contributors reserve all others rights, whether under their respective copyrights, patents,
1515
or trademarks, whether by implication, estoppel or otherwise.

WSL/TOC.md

Lines changed: 0 additions & 20 deletions
This file was deleted.

WSL/about.md

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,61 @@
11
---
2-
title: Learn about the Windows Subsystem for Linux
3-
description: Learn more about how the Windows Subsystem for Linux works.
2+
title: An overview on the the Windows Subsystem for Linux
3+
description: Learn about the Windows Subsystem for Linux, the different versions and ways you can use them.
44
keywords: BashOnWindows, bash, wsl, windows, windowssubsystem, gnu, linux
5-
ms.date: 07/11/2016
5+
ms.date: 05/12/2020
66
ms.topic: article
77
ms.assetid: 3cefe0db-7616-4848-a2b6-9296746a178b
8-
ms.custom: seodec18
98
ms.localizationpriority: high
109
---
1110

12-
# Windows Subsystem for Linux Documentation
11+
# What is the Windows Subsystem for Linux?
1312

14-
The Windows Subsystem for Linux lets developers run a GNU/Linux environment -- including most command-line tools, utilities, and applications -- directly on Windows, unmodified, without the overhead of a virtual machine.
13+
The Windows Subsystem for Linux lets developers run a GNU/Linux environment -- including most command-line tools, utilities, and applications -- directly on Windows, unmodified, without the overhead of a virtual machine.
1514

1615
You can:
1716

18-
1. Choose your favorite GNU/Linux distributions [from the Microsoft Store](https://aka.ms/wslstore).
19-
1. Run common command-line free software such as `grep`, `sed`, `awk`, or other ELF-64 binaries.
20-
1. Run Bash shell scripts and GNU/Linux command-line applications including:
17+
* Choose your favorite GNU/Linux distributions [from the Microsoft Store](https://aka.ms/wslstore).
18+
* Run common command-line tools such as `grep`, `sed`, `awk`, or other ELF-64 binaries.
19+
* Run Bash shell scripts and GNU/Linux command-line applications including:
2120
* Tools: vim, emacs, tmux
22-
* Languages: Javascript/node.js, Ruby, Python, C/C++, C# & F#, Rust, Go, etc.
23-
* Services: sshd, MySQL, Apache, lighttpd
24-
1. Install additional software using own GNU/Linux distribution package manager.
25-
1. Invoke Windows applications using a Unix-like command-line shell.
26-
1. Invoke GNU/Linux applications on Windows.
21+
*Languages: [NodeJS](https://docs.microsoft.com/windows/nodejs/setup-on-wsl2), Javascript, [Python](https://docs.microsoft.com/windows/python/web-frameworks), Ruby, C/C++, C# & F#, Rust, Go, etc.
22+
*Services: SSHD, MySQL, Apache, lighttpd, [MongoDB](https://docs.microsoft.com/windows/nodejs/databases), [PostgreSQL](https://docs.microsoft.com/windows/python/databases).
23+
* Install additional software using own GNU/Linux distribution package manager.
24+
* Invoke Windows applications using a Unix-like command-line shell.
25+
* Invoke GNU/Linux applications on Windows.
2726

28-
## Getting Started
27+
## What is WSL 2?
2928

30-
* [Install Linux on Windows 10](install-win10.md)
31-
* [Visit the command reference](reference.md)
32-
* [Read frequently asked questions](faq.md)
29+
WSL 2 is a new version of the Windows Subsystem for Linux architecture that powers the Windows Subsystem for Linux to run ELF64 Linux binaries on Windows. Its primary goals are to **increase file system performance**, as well as adding **full system call compatibility**.
3330

34-
## Team Blogs
35-
* [Overview post with a collection of videos and blogs](https://blogs.msdn.microsoft.com/commandline/learn-about-windows-console-and-windows-subsystem-for-linux-wsl/)
36-
* [Command-Line blog](https://blogs.msdn.microsoft.com/commandline/) (Active)
37-
* [Windows Subsystem for Linux Blog](https://blogs.msdn.microsoft.com/wsl/) (Historical)
31+
This new architecture changes how these Linux binaries interact with Windows and your computer's hardware, but still provides the same user experience as in WSL 1 (the current widely available version).
3832

39-
## Posts & Articles
40-
* [Run Bash on Ubuntu on Windows](https://blogs.windows.com/buildingapps/2016/03/30/run-bash-on-ubuntu-on-windows/)
41-
* [Developers Can Run Bash And Usermode Ubuntu Linux Binaries On Windows 10](https://www.hanselman.com/blog/DevelopersCanRunBashShellAndUsermodeUbuntuLinuxBinariesOnWindows10.aspx)
42-
* [Ubuntu on Windows – The Ubuntu Userspace for Windows Developers](https://insights.ubuntu.com/2016/03/30/ubuntu-on-windows-the-ubuntu-userspace-for-windows-developers/)
33+
Individual Linux distributions can be run with either the WSL 1 or WSL 2 architecture. Each distribution can be upgraded or downgraded at any time and you can run WSL 1 and WSL 2 distributions side by side. WSL 2 uses an entirely new architecture that benefits from running a real Linux kernel.
4334

44-
## Provide Feedback
45-
* [GitHub issue tracker](https://github.com/Microsoft/BashOnWindows/issues)
35+
## Next steps
4636

37+
* [Install WSL 1 and update to WSL 2](./install-win10.md)
38+
39+
* [Compare WSL 2 and WSL 1](./compare-versions.md)
40+
41+
* [Create a user account and password for your new Linux distribution](./user-support.md)
42+
43+
* [Read Frequently Asked Questions](./faq.md)
44+
45+
* [Read Frequently Asked Questions about WSL 2](./wsl2-faq.md)
46+
47+
* [Troubleshooting](./troubleshooting.md)
48+
49+
* [Run interoperability commands between Windows and Linux](./interop.md)
50+
51+
* [Run launch commands and configurations](./wsl-config.md)
52+
53+
* [Set up file permissions](./file-permissions.md)
54+
55+
* [Set up WSL for Enterprise](./enterprise.md)
56+
57+
* [Reference WSL commands](./reference.md)
58+
59+
* [Build a custom distributions](./build-custom-distro.md)
60+
61+
* [Read the WSL Release Notes](./release-notes.md)

WSL/compare-versions.md

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
---
2+
title: An overview on the the Windows Subsystem for Linux
3+
description: Learn about the Windows Subsystem for Linux, the different versions and ways you can use them.
4+
keywords: BashOnWindows, bash, wsl, windows, windowssubsystem, gnu, linux, ubuntu, debian, suse, windows 10, UX changes, WSL 2, linux kernel, network applications, localhost, IPv6, Virtual Hardware Disk, VHD, VHD limitations, VHD error
5+
ms.date: 05/12/2020
6+
ms.topic: article
7+
ms.localizationpriority: high
8+
---
9+
10+
# Comparing WSL 2 and WSL 1
11+
12+
The primary goals of updating the Windows Subsystem for Linux to a new version are to **increase file system performance** and support **full system call compatibility**.
13+
14+
WSL 2 uses the latest and greatest in virtualization technology to run a Linux kernel inside of a lightweight utility virtual machine (VM). However, WSL 2 is not a traditional VM experience. [Learn more about the WSL 2 architecture](#wsl-2-architecture).
15+
16+
## Comparing features
17+
18+
Feature | WSL 1 | WSL 2
19+
--- | --- | ---
20+
Integration between Windows and Linux| ✅|✅
21+
Fast boot times| ✅ | ✅
22+
Small resource foot print| ✅ |✅
23+
Managed VM| ❌ | ✅
24+
Full Linux Kernel| ❌ |✅
25+
Full system call compatibility| ❌ | ✅
26+
Runs with VM Ware and VirtualBox| ✅ |❌
27+
Performance across OS file systems| ✅ | ❌
28+
29+
Already using WSL 1 and want to upgrade to WSL 2? Follow the instructions to [update to WSL 2](./install-win10.md#update-to-wsl-2)!
30+
31+
WSL 2 is only available in Windows 10, Version 2004, Build 19041 or higher. You will need to [update your Windows version](ms-settings:windowsupdate) and [join the Windows Insider program](https://insider.windows.com/insidersigninboth/) on the "Release Preview" ring until the public release in late May.
32+
33+
## Use the Linux file system for faster performance
34+
35+
In order to optimize for the fastest performance speed, be sure to store your project files in the Linux file system (not the Windows file system).
36+
37+
For example, when storing your WSL project files:
38+
39+
* Use the Linux file system root directory: `\\wsl$\Ubuntu-18.04\home\<user name>\Project`
40+
* Not the Windows file system root directory: `C:\Users\<user name>\Project`
41+
42+
Project files that you are working with using a WSL distribution (like Ubuntu) must be in the Linux root file system to take advantage of faster file system access.
43+
44+
You can access your Linux root file system with Windows apps and tools like File Explorer. Try opening a Linux distribution (like Ubuntu), be sure that you are in the Linux home directory by entering this command: `cd ~`. Then open your Linux file system in File Explorer by entering *(don't forget the period at the end)*: `explorer.exe .`
45+
46+
## Exceptions for using WSL 1 rather than WSL 2
47+
48+
We recommend that you use WSL 2 as it offers faster performance and 100% system call compatibility. However, there are a few specific scenarios where you might prefer using WSL 1. Consider using WSL 1 if:
49+
50+
* Your project files must be stored in the Windows file system.
51+
* If you will be using your WSL Linux distribution to access project files on the Windows file system, and these files cannot be stored on the Linux file system, you will achieve faster performance across the OS files systems by using WSL 1.
52+
* A project which requires cross-compilation using both Windows and Linux tools on the same files.
53+
* File performance across the Windows and Linux operating systems is faster in WSL 1 than WSL 2, so if you are using Windows applications to access Linux files, you will currently achieve faster performance with WSL 1.
54+
55+
> [!NOTE]
56+
> Consider trying the VS Code [Remote WSL Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) to enable you to store your project files on the Linux file system, using Linux command line tools, but also using VS Code on Windows to author, edit, debug, or run your project in an internet browser without any of the performance slow-downs associated with working across the Linux and Windows file systems. [Learn more](https://code.visualstudio.com/docs/remote/wsl).
57+
58+
## WSL 2 architecture
59+
60+
A traditional VM experience can be slow to boot up, is isolated, consumes lots of resources, and requires your time to manage it. WSL 2 does not have these attributes.
61+
62+
WSL 2 provides the benefits of WSL 1, including seamless integration between Windows and Linux, fast boot times, a small resource footprint, and requires no VM configuration or management. While WSL 2 does use a VM, it is managed and run behind the scenes, leaving you with the same user experience as WSL 1.
63+
64+
### Full Linux kernel
65+
66+
The Linux kernel in WSL 2 is built by Microsoft from the latest stable branch, based on the source available at kernel.org. This kernel has been specially tuned for WSL 2, optimizing for size and performance to provide an amazing Linux experience on Windows. The kernel will be serviced by Windows updates, which means you will get the latest security fixes and kernel improvements without needing to manage it yourself.
67+
68+
The [WSL 2 Linux kernel is open source](https://github.com/microsoft/WSL2-Linux-Kernel). If you'd like to learn more, check out the blog post [Shipping a Linux Kernel with Windows](https://devblogs.microsoft.com/commandline/shipping-a-linux-kernel-with-windows/) written by the team that built it.
69+
70+
### Increased file IO performance
71+
72+
File intensive operations like git clone, npm install, apt update, apt upgrade, and more are all be noticeably faster with WSL 2.
73+
74+
The actual speed increase will depend on which app you're running and how it is interacting with the file system. Initial versions of WSL 2 run up to 20x faster compared to WSL 1 when unpacking a zipped tarball, and around 2-5x faster when using git clone, npm install and cmake on various projects.
75+
76+
### Full system call compatibility
77+
78+
Linux binaries use system calls to perform functions such as accessing files, requesting memory, creating processes, and more. Whereas WSL 1 used a translation layer that was built by the WSL team, WSL 2 includes its own Linux kernel with full system call compatibility. Benefits include:
79+
80+
* A whole new set of apps that you can run inside of WSL, such as **[Docker](https://code.visualstudio.com/blogs/2020/03/02/docker-in-wsl2)** and more.
81+
82+
* Any updates to the Linux kernel are immediately ready for use. (You don't have to wait for the WSL team to implement updates and add the changes).
83+
84+
### WSL 2 uses a smaller amount of memory on startup
85+
86+
WSL 2 uses a lightweight utility VM on a real Linux kernel with a small memory footprint. The utility will allocate Virtual Address backed memory on startup. It is configured to start with a smaller proportion of your total memory that what was required for WSL 1.
87+
88+
## Accessing network applications
89+
90+
### Accessing Linux networking apps from Windows (localhost)
91+
92+
If you are building a networking app (for example an app running on a NodeJS or SQL server) in your Linux distribution, you can access it from a Windows app (like your Edge or Chrome internet browser) using `localhost` (just like you normally would).
93+
94+
However, if you are running an older version of Windows (Build 18945 or less), you will need to get the IP address of the Linux host VM (or [update to the latest Windows version](ms-settings:windowsupdate)).
95+
96+
To find the IP address of the virtual machine powering your Linux distribution:
97+
98+
* From your WSL distribution (ie Ubuntu), run the command: `ip addr`
99+
* Find and copy the address under the `inet` value of the `eth0` interface.
100+
* If you have the grep tool installed, find this more easily by filtering the output with the command: `ip addr | grep eth0`
101+
* Connect to your Linux server using this IP address.
102+
103+
The picture below shows an example of this by connecting to a Node.js server using the Edge browser.
104+
105+
![Accessing Linux network applications from Windows](media/wsl2-network-w2l.jpg)
106+
107+
### Accessing Windows networking apps from Linux (host IP)
108+
109+
If you want to access a networking app running on Windows (for example an app running on a NodeJS or SQL server) from your Linux distribution (ie Ubuntu), then you need to use the IP address of your host machine. While this is not a common scenario, you can follow these steps to make it work.
110+
- Obtain the IP address of your host machine by running this command from your Linux distribution: `cat /etc/resolv.conf`
111+
- Copy the IP address following the term: `nameserver`.
112+
- Connect to any Windows server using the copied IP address.
113+
114+
The picture below shows an example of this by connecting to a Node.js server running in Windows via curl.
115+
116+
![Accessing Linux network applications from Windows](media/wsl2-network-l2w.png)
117+
118+
### Additional networking considerations
119+
120+
#### Connecting via remote IP addresses
121+
122+
When using remote IP addresses to connect to your applications, they will be treated as connections from the Local Area Network (LAN). This means that you will need to make sure your application can accept LAN connections.
123+
124+
For example, you may need to bind your application to `0.0.0.0` instead of `127.0.0.1`. In the example of a Python app using Flask, this can be done with the command: `app.run(host='0.0.0.0')`. Please keep security in mind when making these changes as this will allow connections from your LAN.
125+
126+
#### Accessing a WSL 2 distribution from your local area network (LAN)
127+
128+
When using a WSL 1 distribution, if your computer was set up to be accessed by your LAN, then applications run in WSL could be accessed on your LAN as well.
129+
130+
This isn't the default case in WSL 2. WSL 2 has a virtualized ethernet adapter with its own unique IP address. Currently, to enable this workflow you will need to go through the same steps as you would for a regular virtual machine. (We are looking into ways to improve this experience.)
131+
132+
#### IPv6 access
133+
134+
WSL 2 distributions currently cannot reach IPv6-only addresses. We are working on adding this feature.
135+
136+
## Expanding the size of your WSL 2 Virtual Hardware Disk
137+
138+
WSL 2 uses a Virtual Hardware Disk (VHD) to store your Linux files. If you reach its max size you may need to expand it.
139+
140+
The WSL 2 VHD uses the ext4 file system. This VHD automatically resizes to meet your storage needs and has an initial maximum size of 256GB. If your distribution grows in size to be greater than 256GB, you will see errors stating that you've run out of disk space. You can fix this error by expanding the VHD size.
141+
142+
To expand your maximum VHD size beyond 256GB:
143+
144+
1. Terminate all WSL instances using the command: `wsl --shutdown`
145+
146+
2. Find your distribution installation package name ('PackageFamilyName')
147+
* Using PowerShell (where 'distro' is your distribution name) enter the command:
148+
* `Get-AppxPackage -Name "*<distro>*" | Select PackageFamilyName`
149+
150+
3. Locate the VHD file `fullpath` used by your WSL 2 installation, this will be your `pathToVHD`:
151+
* `%LOCALAPPDATA%\Packages\<PackageFamilyName>\LocalState\<disk>.vhdx`
152+
153+
4. Resize your WSL 2 VHD by completing the following commands:
154+
* Open Windows Command Prompt with admin privileges and enter:
155+
* `diskpart`
156+
* `Select vdisk file="<pathToVHD>"`
157+
* `expand vdisk maximum="<sizeInMegaBytes>"`
158+
159+
5. Launch your WSL distribution (Ubuntu, for example).
160+
161+
6. Make WSL aware that it can expand its file system's size by running these commands from your Linux distribution command line:
162+
* `sudo mount -t devtmpfs none /dev`
163+
* `mount | grep ext4`
164+
* Copy the name of this entry, which will look like: `/dev/sdXX` (with the X representing any other character)
165+
* `sudo resize2fs /dev/sdXX`
166+
* Use the value you copied earlier. You may also need to install resize2fs: `apt install resize2fs`
167+
168+
> [!NOTE]
169+
> In general do not modify, move, or access the WSL related files located inside of your AppData folder using Windows tools or editors. Doing so could cause your Linux distribution to become corrupted.

WSL/curl-distro.png

-17.5 KB
Binary file not shown.

WSL/docfx.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"files": [
66
"**/*.md",
7-
"**/*.yml"
7+
"**/**.yml"
88
],
99
"exclude": [
1010
"**/obj/**",

0 commit comments

Comments
 (0)