Skip to content

Commit 6f6b7b6

Browse files
Updated wsl2-ux-changes.md to include more networking info
1 parent 73f4cc6 commit 6f6b7b6

1 file changed

Lines changed: 96 additions & 86 deletions

File tree

WSL/wsl2-ux-changes.md

Lines changed: 96 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,96 @@
1-
---
2-
title: UX Changes between WSL 1 and WSL 2
3-
description: User Experience Changes Between WSL 1 and WSL 2
4-
keywords: BashOnWindows, bash, wsl, wsl2, windows, windows subsystem for linux, windowssubsystem, ubuntu, debian, suse, windows 10
5-
ms.date: 05/30/2019
6-
ms.topic: article
7-
ms.assetid: 7afaeacf-435a-4e58-bff0-a9f0d75b8a51
8-
ms.custom: seodec18
9-
---
10-
11-
# User Experience Changes Between WSL 1 and WSL 2
12-
13-
This page goes over the user experience differences between WSL 1 and the WSL 2 preview. The key changes to be aware of are:
14-
15-
- Place files that your Linux apps will access in your Linux root file system for faster file performance speed
16-
- In initial builds of the WSL 2 preview you will need to access network applications using an IP address and not using localhost
17-
18-
And below is the full list of other changes that you may notice:
19-
20-
- WSL 2 uses a [Virtual Hardware Disk](https://en.wikipedia.org/wiki/VHD_(file_format)) (VHD) to store your files and if you reach its max size you may need to expand it
21-
- When starting, WSL 2 will now use a small proportion of memory
22-
- Cross OS file access speed will be slower in initial preview builds
23-
24-
## Place your Linux files in your Linux root file system
25-
Make sure to put the files that you will be accessing frequently with Linux applications inside of your Linux root file system to enjoy the file performance benefits. These files have to be inside of the Linux root file system to have faster file system access. We have also made it possible for Windows apps to access the Linux root file system (like File Explorer! Try running: `explorer.exe .` in the home directory of your Linux distro and see what happens) which will make this transition significantly easier.
26-
27-
## Accessing network applications
28-
In the initial builds of the WSL 2 preview, you will need to access any Windows server from Linux using the IP address of your host machine.
29-
30-
### Accessing Windows applications from Linux
31-
To access a Windows network application you'll need to use the IP address of your host machine. You can do so with these steps:
32-
33-
- Obtain the IP address of your host machine by running the command `cat /etc/resolv.conf` and copying the IP address following the term `nameserver`.
34-
- Connect to any Windows server using the copied IP address.
35-
36-
The picture below shows an example of this by connecting to a Node.js server running in Windows via curl.
37-
38-
![Accessing Linux network applications from Windows](media/wsl2-network-l2w.png)
39-
40-
### Accessing Linux applications from Windows (only in builds lower than 18945)
41-
If you have a server in a WSL distro, you'll need to find the IP address of the virtual machine powering your distro and connect to it with that IP address. You can do that by following these steps:
42-
43-
- Obtain the IP address of your distro by running the command `ip addr` inside of your WSL distro and finding it under the `inet` value of the `eth0` interface.
44-
- You can find this more easily by filtering the output of the command using grep like so: `ip addr | grep eth0`.
45-
- Connect to your Linux server using the IP you found above.
46-
47-
The picture below shows an example of this by connecting to a Node.js server using the Edge browser.
48-
49-
![Accessing Linux network applications from Windows](media/wsl2-network-w2l.jpg)
50-
51-
If your build is 18945 or higher, you can use localhost just like normal.
52-
53-
### Other networking considerations
54-
55-
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, i.e: You might need to bind your application to `0.0.0.0` instead of `127.0.0.1`. For example in python 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.
56-
57-
## Understanding WSL 2 uses a VHD, and what to do if you reach its max size
58-
WSL 2 stores all your Linux files inside of a VHD that uses the ext4 file system. This VHD automatically resizes to meet your storage needs. This VHD also has an initial max size of 256GB. If your distro grows in size to be greater than 256GB you will see errors stating that you've run out of disk space. You can fix these by expanding the VHD size. Instructions on how to do so are below:
59-
60-
1. Terminate all WSL instances using the `wsl --shutdown` command
61-
2. Find your distro installation package name 'PackageFamilyName'
62-
- In a powershell prompt (where 'distro' is your distribution name) type:
63-
- `Get-AppxPackage -Name "*<distro>*" | Select PackageFamilyName`
64-
3. Locate the VHD file fullpath used by your WSL 2 installation, this will be your 'pathToVHD':
65-
- `%LOCALAPPDATA%\Packages\<PackageFamilyName>\LocalState\<disk>.vhdx`
66-
4. Resize your WSL 2 VHD by completing the following commands
67-
- Open a command prompt Window with admin privileges and run the following commands:
68-
- `diskpart`
69-
- `Select vdisk file="<pathToVHD>"`
70-
- `expand vdisk maximum="<sizeInMegaBytes>"`
71-
5. Launch your WSL distro
72-
6. Make WSL aware that it can expand its file system's size
73-
- Run these commands in your WSL distro:
74-
- `sudo mount -t devtmpfs none /dev`
75-
- `mount | grep ext4`
76-
- Copy the name of this entry, which will look like: /dev/sdXX (with the X representing any other character)
77-
- `sudo resize2fs /dev/sdXX`
78-
- Make sure to use the value you copied earlier, and you may need to use: `apt install resize2fs`.
79-
80-
Please note: 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 distro to become corrupted.
81-
82-
## WSL 2 will use some memory on startup
83-
WSL 2 uses a lightweight utility VM on a real Linux kernel to provide great file system performance and full system call compatibility while still being just as light, fast, integrated and responsive as WSL 1. This utility VM has a small memory footprint and will allocate Virtual Address backed memory on startup. It is configured to start with a small proportion of your total memory.
84-
85-
## Cross OS file speed will be slower in initial preview builds
86-
You will notice slower file speeds compared to WSL 1 when accessing Windows files from a Linux application, or accessing Linux files from a Windows application. This is a result of the architectural changes in WSL 2, and is something that the WSL team is actively investigating on how we can improve this experience.
1+
---
2+
title: UX Changes between WSL 1 and WSL 2
3+
description: User Experience Changes Between WSL 1 and WSL 2
4+
keywords: BashOnWindows, bash, wsl, wsl2, windows, windows subsystem for linux, windowssubsystem, ubuntu, debian, suse, windows 10
5+
ms.date: 05/30/2019
6+
ms.topic: article
7+
ms.assetid: 7afaeacf-435a-4e58-bff0-a9f0d75b8a51
8+
ms.custom: seodec18
9+
---
10+
11+
# User Experience Changes Between WSL 1 and WSL 2
12+
13+
This page goes over the user experience differences between WSL 1 and the WSL 2 preview. The key changes to be aware of are:
14+
15+
- Place files that your Linux apps will access in your Linux root file system for faster file performance speed
16+
- In initial builds of the WSL 2 preview you will need to access network applications using an IP address and not using localhost
17+
18+
And below is the full list of other changes that you may notice:
19+
20+
- WSL 2 uses a [Virtual Hardware Disk](https://en.wikipedia.org/wiki/VHD_(file_format)) (VHD) to store your files and if you reach its max size you may need to expand it
21+
- When starting, WSL 2 will now use a small proportion of memory
22+
- Cross OS file access speed will be slower in initial preview builds
23+
24+
## Place your Linux files in your Linux root file system
25+
Make sure to put the files that you will be accessing frequently with Linux applications inside of your Linux root file system to enjoy the file performance benefits. These files have to be inside of the Linux root file system to have faster file system access. We have also made it possible for Windows apps to access the Linux root file system (like File Explorer! Try running: `explorer.exe .` in the home directory of your Linux distro and see what happens) which will make this transition significantly easier.
26+
27+
## Accessing network applications
28+
In the initial builds of the WSL 2 preview, you will need to access any Windows server from Linux using the IP address of your host machine.
29+
30+
### Accessing Windows applications from Linux
31+
To access a Windows network application you'll need to use the IP address of your host machine. You can do so with these steps:
32+
33+
- Obtain the IP address of your host machine by running the command `cat /etc/resolv.conf` and copying the IP address following the term `nameserver`.
34+
- Connect to any Windows server using the copied IP address.
35+
36+
The picture below shows an example of this by connecting to a Node.js server running in Windows via curl.
37+
38+
![Accessing Linux network applications from Windows](media/wsl2-network-l2w.png)
39+
40+
### Accessing Linux applications from Windows (only in builds lower than 18945)
41+
If you have a server in a WSL distro, you'll need to find the IP address of the virtual machine powering your distro and connect to it with that IP address. You can do that by following these steps:
42+
43+
- Obtain the IP address of your distro by running the command `ip addr` inside of your WSL distro and finding it under the `inet` value of the `eth0` interface.
44+
- You can find this more easily by filtering the output of the command using grep like so: `ip addr | grep eth0`.
45+
- Connect to your Linux server using the IP you found above.
46+
47+
The picture below shows an example of this by connecting to a Node.js server using the Edge browser.
48+
49+
![Accessing Linux network applications from Windows](media/wsl2-network-w2l.jpg)
50+
51+
If your build is 18945 or higher, you can use localhost just like normal.
52+
53+
### Other networking considerations
54+
55+
#### Connecting via remote IP addresses
56+
57+
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, i.e: You might need to bind your application to `0.0.0.0` instead of `127.0.0.1`. For example in python 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.
58+
59+
#### Accessing a WSL2 distro from your local area network (LAN)
60+
61+
When using a WSL1 distro, if your computer was set up to be accessed by in your LAN, then applications run in WSL could be accessed on your LAN as well. This isn't the default case in WSL2, as WSL2 has a virtualized ethernet adapter with its own 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!
62+
63+
#### IPv6 access
64+
65+
WSL2 distros currently cannot reach IPv6 only addresses. We are working on adding this feature.
66+
67+
## Understanding WSL 2 uses a VHD, and what to do if you reach its max size
68+
WSL 2 stores all your Linux files inside of a VHD that uses the ext4 file system. This VHD automatically resizes to meet your storage needs. This VHD also has an initial max size of 256GB. If your distro grows in size to be greater than 256GB you will see errors stating that you've run out of disk space. You can fix these by expanding the VHD size. Instructions on how to do so are below:
69+
70+
1. Terminate all WSL instances using the `wsl --shutdown` command
71+
2. Find your distro installation package name 'PackageFamilyName'
72+
- In a powershell prompt (where 'distro' is your distribution name) type:
73+
- `Get-AppxPackage -Name "*<distro>*" | Select PackageFamilyName`
74+
3. Locate the VHD file fullpath used by your WSL 2 installation, this will be your 'pathToVHD':
75+
- `%LOCALAPPDATA%\Packages\<PackageFamilyName>\LocalState\<disk>.vhdx`
76+
4. Resize your WSL 2 VHD by completing the following commands
77+
- Open a command prompt Window with admin privileges and run the following commands:
78+
- `diskpart`
79+
- `Select vdisk file="<pathToVHD>"`
80+
- `expand vdisk maximum="<sizeInMegaBytes>"`
81+
5. Launch your WSL distro
82+
6. Make WSL aware that it can expand its file system's size
83+
- Run these commands in your WSL distro:
84+
- `sudo mount -t devtmpfs none /dev`
85+
- `mount | grep ext4`
86+
- Copy the name of this entry, which will look like: /dev/sdXX (with the X representing any other character)
87+
- `sudo resize2fs /dev/sdXX`
88+
- Make sure to use the value you copied earlier, and you may need to use: `apt install resize2fs`.
89+
90+
Please note: 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 distro to become corrupted.
91+
92+
## WSL 2 will use some memory on startup
93+
WSL 2 uses a lightweight utility VM on a real Linux kernel to provide great file system performance and full system call compatibility while still being just as light, fast, integrated and responsive as WSL 1. This utility VM has a small memory footprint and will allocate Virtual Address backed memory on startup. It is configured to start with a small proportion of your total memory.
94+
95+
## Cross OS file speed will be slower in initial preview builds
96+
You will notice slower file speeds compared to WSL 1 when accessing Windows files from a Linux application, or accessing Linux files from a Windows application. This is a result of the architectural changes in WSL 2, and is something that the WSL team is actively investigating on how we can improve this experience.

0 commit comments

Comments
 (0)