You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Update kernel-release-notes.md
* Update install with step #s and kernel download (#912)
* Update install with step #s and kernel download
* fix anchor link
* Clean up and reorganize
* Add Windows Terminal section
* Update install with step #s and kernel download
* fix anchor link
* Clean up and reorganize
* Add Windows Terminal section
* Add redirects, update toc to remove whats new wsl2
* remove version specific link
* Fix redirects missing file type
* Add anchor link to kernel redirect
* Feedback update on wording
* Change compare topic type, remove links, reorg
Co-authored-by: Craig Loewen <[email protected]>
Copy file name to clipboardExpand all lines: WSL/build-custom-distro.md
+16-12Lines changed: 16 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,39 +2,43 @@
2
2
title: Build a Custom Linux Distro for WSL
3
3
description: Learn how to create a custom Linux distribution for Windows Subsystem for Linux.
4
4
keywords: BashOnWindows, bash, wsl, windows, windows subsystem, distro, custom
5
-
ms.date: 03/27/2018
5
+
ms.date: 09/15/2020
6
6
ms.topic: article
7
-
ms.assetid: a5095219-0c82-4ce5-9a6d-5c2fc00835a3
8
-
ms.custom: seodec18
9
7
---
10
8
11
-
# Creating a Custom Linux Distro for WSL
9
+
# Creating a Custom Linux Distribution for WSL
12
10
13
11
Use our open source WSL sample to build WSL distro packages for the Microsoft Store and/or to create custom Linux distro packages for sideloading. You can find the [distro launcher repo](https://github.com/Microsoft/WSL-DistroLauncher) on GitHub.
14
12
15
13
This project enables:
16
-
* Linux distribution maintainers to package and submit a Linux distribution as an appx that runs on WSL
17
-
* Developers to create custom Linux distributions that can be sideloaded onto their dev machine
14
+
15
+
- Linux distribution maintainers to package and submit a Linux distribution as an appx that runs on WSL
16
+
- Developers to create custom Linux distributions that can be sideloaded onto their dev machine
18
17
19
18
## Background
19
+
20
20
We distribute Linux distros for WSL as UWP applications through the Microsoft Store. You can install those applications that will then run on WSL - the subsystem that sits in the Windows kernel. This delivery mechanism has many benefits as discussed in an [earlier blog post](https://blogs.msdn.microsoft.com/commandline/2017/07/10/ubuntu-now-available-from-the-windows-store/).
21
21
22
22
## Sideloading a Custom Linux Distro Package
23
+
23
24
You can create a custom Linux distro package as an application to sideload on your personal machine. Please note that your custom package would not be distributed through the Microsoft Store unless you submit as a distribution maintainer.
24
25
To set up your machine to sideload apps, you will need to enable this in the system settings under “For Developers”. Be sure to either have developer mode, or sideload apps selected
25
26
26
27
## For Linux Distro Maintainers
28
+
27
29
To submit to the Store, you will need to work with us to receive publishing approval. If you are a Linux distribution owner interested in adding your distribution to the Microsoft Store, please contact [email protected].
28
30
29
31
## Getting Started
32
+
30
33
Follow the instructions on the [Distro Launcher GitHub repo](https://github.com/Microsoft/WSL-DistroLauncher) to create a custom Linux distro package.
31
34
32
-
33
35
## Team Blogs
34
-
*[Open Sourcing a WSL Sample for Linux Distribution Maintainers and Sideloading Custom Linux Distributions](https://blogs.msdn.microsoft.com/commandline/2018/03/26/wsl-distro-launcher/)
-[Open Sourcing a WSL Sample for Linux Distribution Maintainers and Sideloading Custom Linux Distributions](https://blogs.msdn.microsoft.com/commandline/2018/03/26/wsl-distro-launcher/)
description: Compare version 1 and version 2 of the Windows Subsystem for Linux. WSL 2 runs an actual Linux kernel, increasing speed and full system call compatibility. WSL 1 works better if your working across BOTH Windows and Linux file systems.
3
+
description: Compare version 1 and version 2 of the Windows Subsystem for Linux. Learn whats new in WSL 2 - actual Linux kernel, faster speed, full system call compatibility. WSL 1 works better if your storing files across operating file systems. You can expand the size of your WSL 2 Virtual Hardware Disk (VHD).
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**.
12
+
The primary difference and reasons for updating the Windows Subsystem for Linux from WSL 1 to WSL 2 are to:
13
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).
14
+
-**increase file system performance**,
15
+
-**support full system call compatibility**.
16
+
17
+
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.
15
18
16
19
## Comparing features
17
20
@@ -26,41 +29,35 @@ Feature | WSL 1 | WSL 2
26
29
Full system call compatibility| ❌ | ✅
27
30
Performance across OS file systems| ✅ | ❌
28
31
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 1903, Build 18362 or higher. Check your Windows version by selecting the **Windows logo key + R**, type **winver**, select **OK**. (Or enter the `ver` command in Windows Command Prompt). You may need to [update to the latest Windows version](ms-settings:windowsupdate). For builds lower than 18362, WSL is not supported at all.
32
-
33
-
> [!NOTE]
34
-
> WSL 2 will work with [VMWare 15.5.5+](https://blogs.vmware.com/workstation/2020/05/vmware-workstation-now-supports-hyper-v-mode.html) and [VirtualBox 6+](https://www.virtualbox.org/wiki/Changelog-6.0).
32
+
As you can tell from the comparison table above, the WSL 2 architecture outperforms WSL 1 in several ways, with the exception of performance across OS file systems.
35
33
36
-
## Use the Linux file system for faster performance
34
+
## Performance across OS file systems
37
35
38
-
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
+
We recommend against working across operating systems with your files, unless you have a specific reason for doing so. For the fastest performance speed, store your files in the WSL file system if you are working in a Linux command line (Ubuntu, OpenSUSE, etc). If your working in a Windows command line (PowerShell, Command Prompt), store your files in the Windows file system.
39
37
40
38
For example, when storing your WSL project files:
41
39
42
-
* Use the Linux file system root directory: `\\wsl$\Ubuntu-18.04\home\<user name>\Project`
43
-
* Not the Windows file system root directory: `C:\Users\<user name>\Project`
44
-
45
-
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.
40
+
- Use the Linux file system root directory: `\\wsl$\Ubuntu-18.04\home\<user name>\Project`
41
+
- Not the Windows file system root directory: `C:\Users\<user name>\Project`
46
42
47
43
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 .`
48
44
49
-
## Exceptions for using WSL 1 rather than WSL 2
45
+
WSL 2 is only available in Windows 10, Version 1903, Build 18362 or higher. Check your Windows version by selecting the **Windows logo key + R**, type **winver**, select **OK**. (Or enter the `ver` command in Windows Command Prompt). You may need to [update to the latest Windows version](ms-settings:windowsupdate). For builds lower than 18362, WSL is not supported at all.
50
46
51
-
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:
47
+
> [!NOTE]
48
+
> WSL 2 will work with [VMWare 15.5.5+](https://blogs.vmware.com/workstation/2020/05/vmware-workstation-now-supports-hyper-v-mode.html) and [VirtualBox 6+](https://www.virtualbox.org/wiki/Changelog-6.0).
52
49
53
-
* Your project files must be stored in the Windows file system.
54
-
* 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.
55
-
* A project which requires cross-compilation using both Windows and Linux tools on the same files.
56
-
* 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.
50
+
## Whats new in WSL 2
57
51
58
-
> [!NOTE]
59
-
> 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).
52
+
WSL 2 is a major overhaul of the underlying architecture and uses virtualization technology and a Linux kernel to enable new features. The primary goals of this update are to increase file system performance and add full system call compatibility.
53
+
54
+
-[WSL 2 system requirements](./install-win10.md#step-2---update-to-wsl-2)
55
+
-[Update from WSL 1 to WSL 2](./install-win10.md#step-2---update-to-wsl-2)
56
+
-[Frequently Asked Questions about WSL 2](./wsl2-faq.md)
60
57
61
-
## WSL 2 architecture
58
+
###WSL 2 architecture
62
59
63
-
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.
60
+
A traditional VM experience can be slow to boot up, is isolated, consumes a lot of resources, and requires your time to manage it. WSL 2 does not have these attributes.
64
61
65
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.
66
63
@@ -80,14 +77,26 @@ The actual speed increase will depend on which app you're running and how it is
80
77
81
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:
82
79
83
-
* 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.
80
+
- A whole new set of apps that you can run inside of WSL, such as **[Docker](tutorials/wsl-containers.md)** and more.
84
81
85
-
* 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).
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).
86
83
87
84
### WSL 2 uses a smaller amount of memory on startup
88
85
89
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.
90
87
88
+
## Exceptions for using WSL 1 rather than WSL 2
89
+
90
+
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:
91
+
92
+
- Your project files must be stored in the Windows file system. WSL 1 offers faster access to files mounted from Windows.
93
+
- 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.
94
+
- A project which requires cross-compilation using both Windows and Linux tools on the same files.
95
+
- 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.
96
+
97
+
> [!NOTE]
98
+
> 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](tutorials/wsl-vscode.md).
99
+
91
100
## Accessing network applications
92
101
93
102
### Accessing Linux networking apps from Windows (localhost)
@@ -98,14 +107,14 @@ However, if you are running an older version of Windows (Build 18945 or less), y
98
107
99
108
To find the IP address of the virtual machine powering your Linux distribution:
100
109
101
-
* From your WSL distribution (ie Ubuntu), run the command: `ip addr`
102
-
* Find and copy the address under the `inet` value of the `eth0` interface.
103
-
* If you have the grep tool installed, find this more easily by filtering the output with the command: `ip addr | grep eth0`
104
-
* Connect to your Linux server using this IP address.
110
+
- From your WSL distribution (ie Ubuntu), run the command: `ip addr`
111
+
- Find and copy the address under the `inet` value of the `eth0` interface.
112
+
- If you have the grep tool installed, find this more easily by filtering the output with the command: `ip addr | grep eth0`
113
+
- Connect to your Linux server using this IP address.
105
114
106
115
The picture below shows an example of this by connecting to a Node.js server using the Edge browser.
107
116
108
-

117
+

109
118
110
119
### Accessing Windows networking apps from Linux (host IP)
111
120
@@ -116,7 +125,7 @@ If you want to access a networking app running on Windows (for example an app ru
116
125
117
126
The picture below shows an example of this by connecting to a Node.js server running in Windows via curl.
118
127
119
-

128
+

120
129
121
130
### Additional networking considerations
122
131
@@ -133,6 +142,7 @@ When using a WSL 1 distribution, if your computer was set up to be accessed by y
133
142
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.)
134
143
135
144
Here's an example PowerShell command to add a port proxy that listens on port 4000 on the host and connects it to port 4000 to the WSL 2 VM with IP address 192.168.101.100.
4. Resize your WSL 2 VHD by completing the following commands:
162
-
* Open Windows Command Prompt with admin privileges and enter:
163
-
*`diskpart`
164
-
*`Select vdisk file="<pathToVHD>"`
165
-
*`expand vdisk maximum="<sizeInMegaBytes>"`
172
+
- Open Windows Command Prompt with admin privileges and enter:
173
+
-`diskpart`
174
+
-`Select vdisk file="<pathToVHD>"`
175
+
-`expand vdisk maximum="<sizeInMegaBytes>"`
166
176
167
177
5. Launch your WSL distribution (Ubuntu, for example).
168
178
169
179
6. Make WSL aware that it can expand its file system's size by running these commands from your Linux distribution command line:
170
-
*`sudo mount -t devtmpfs none /dev`
171
-
*`mount | grep ext4`
172
-
* Copy the name of this entry, which will look like: `/dev/sdXX` (with the X representing any other character)
173
-
*`sudo resize2fs /dev/sdXX`
174
-
* Use the value you copied earlier. You may also need to install resize2fs: `apt install resize2fs`
180
+
-`sudo mount -t devtmpfs none /dev`
181
+
-`mount | grep ext4`
182
+
- Copy the name of this entry, which will look like: `/dev/sdXX` (with the X representing any other character)
183
+
-`sudo resize2fs /dev/sdXX`
184
+
- Use the value you copied earlier. You may also need to install resize2fs: `apt install resize2fs`
175
185
176
186
> [!NOTE]
177
187
> 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.
0 commit comments