Wsl windows 11 что это

1.2K
показов

1.9K
открытий

Сегодня покажу как поставить WSL (Windows Subsystem for Linux) на Windows 11

В этой статье вы узнаете:

  • Что такое WSL и для чего она нужна
  • Гайд по установке WSL
  • Настройка компилятора
  • Что делать, если WSL потребляет избыточное количество оперативной памяти

Что такое WSL и для чего она нужна

WSL (Windows Subsystem for Linux) — это среда выполнения Linux, предоставляемая операционной системой Windows. WSL позволяет запускать исполняемые файлы Linux напрямую в Windows без необходимости установки отдельной виртуальной машины или перезагрузки компьютера.

WSL обеспечивает совместимость с ядром Linux, что позволяет пользователям запускать большинство командной строки и приложений Linux непосредственно в Windows. Оно включает в себя поддержку большинства дистрибутивов Linux, таких как Ubuntu, Debian, Fedora и других, и предлагает доступ к огромному количеству программ и утилит, которые разработаны для Linux.

Теперь перейдём к гайду

Гайд по установке WSL

Открываем PowerShell или Terminal от имени администратора

Можно как угодно открыть эти программы, думаю, вы в курсе))

Вводим следующую команду: wsl —install

Нажимаем Enter

Ждём

Кстати говоря, по умолчанию устанавливается дистрибутив — Ubuntu

По завершении установки перезагружаем наш ПК.

Мне нравится Ubuntu, поэтому я не буду её менять, но если ты хочешь поменять дистрибутив, то вот ссылка на инструкцию.

Теперь после установки WSL необходимо создать учетную запись пользователя и пароль для установленного дистрибутива Linux (в моём случаи речь идёт про Ubuntu):

Придумай имя

Обрати внимание, что пароль при вводе не видно((

На случай, если что-то пошло не так на этапе создания учётной записи вот мини-туториал как это можно исправить.

Готово!

Важный нюанс: Windows не выполняет автоматическую установку обновлений или обновление дистрибутивов Linux. Это задача, выполнение которой большинство пользователей Linux предпочитают контролировать самостоятельно. Поэтому обновим нашу подсистему с помощью этой команды: sudo apt update && sudo apt upgrade

Я перешёл из PowerShell в Terminal, не пугайтесь, всё будет работать также))

Да, Y с большой буквы, это важно))

Настройка компилятора

Я использую WSL, чтобы компилировать программы на языке С, поэтому покажу команды для установки компилятора.

По очереди:

sudo apt-get update

sudo apt-get install cmake gcc clang gdb build-essential

sudo apt-get install valgrind

Первая есть

Да.

Вторая

И третья

Важный момент: Проверим, установился ли у нас компилятор, должен появится номер: gcc —version

Что делать, если WSL потребляет избыточное количество оперативной памяти

Бонусом, я покажу, как снизить потребление оперативной памяти нашей подсистемой:

Вот это не есть хорошо((

Есть два пути

Путь первый:
Открываем командную строку от администратора и вставить команду
wsl —shutdown, эта команда завершит процесс VmmemWSL.

Чтобы легко открыть командную строку можно зажать кнопки Win + X > пункт PowerShell (Администратор) > команда start cmd > нажимаем Enter.

Путь второй:
Можно также ограничить ресурсы Vmmem путем создания файла %UserProfile%\.wslconfig, внутри которого прописать:

[wsl2]
memory=2GB # Ограничиваем память для WSL2 VM.processors=5 # Ограничиваем количество процессов для WSL2 VM.

Чтобы создать файл с названием .wslconfig — нужно открыть блокнот Win + R > notepad > вставить содержимое > Сохранить как > в Тип файла указать Все файлы, после указать название и сохранить.

Text Document

Всё

Более чем в два раза))

Кстати говоря, в этом файлике можете попробовать поставить значение memory равное 1, может ещё меньше будет))

На этом у меня всё, надеюсь моя статья помогла тебе решить твою проблему))

Благодарю за прочтение!

From Wikipedia, the free encyclopedia

Windows Subsystem for Linux

Bash running on Windows 10

Other names WSL
Developer(s) Microsoft
Initial release August 2, 2016; 7 years ago
Stable release

WSL 2 1.2.5
/ April 20, 2023; 5 months ago[1]

Preview release

WSL 2 2.0.1
/ September 25, 2023; 12 days ago[2]

Repository github.com/Microsoft/WSL (issues only)
Operating system Windows 10, Windows 10 LTSB/LTSC, Windows Server 2016, Windows Server 2019, Windows 11, Windows Server 2022
Predecessor Windows Services for UNIX
Type Compatibility layer, Virtualization
License Subsystem: Proprietary commercial software;
Linux kernel: GNU GPLv2 (only) with some code under compatible GPL variants or under permissive licenses like BSD, MIT
Website learn.microsoft.com/windows/wsl/about

Windows Subsystem for Linux (WSL) is a feature of Windows that allows developers to run a Linux environment without the need for a separate virtual machine or dual booting. There are two versions of WSL: WSL 1 and WSL 2. WSL 1 was first released on August 2, 2016, and acts as a compatibility layer for running Linux binary executables (in ELF format) by implementing Linux system calls on the Windows kernel.[3] It is available on Windows 10, Windows 10 LTSB/LTSC, Windows 11,[4] Windows Server 2016, Windows Server 2019 and Windows Server 2022.

In May 2019, WSL 2 was announced,[5] introducing important changes such as a real Linux kernel,[6] through a subset of Hyper-V features. WSL 2 differs from WSL 1 in that WSL 2 runs inside a managed virtual machine that implements the full Linux kernel. As a result, WSL 2 is compatible with more Linux binaries than WSL 1, as not all syscalls were implemented in WSL 1. Since June 2019, WSL 2 is available to Windows 10 customers through the Windows Insider program, including the Home edition.[7] WSL is not available to all Windows 10 users by default. It can be installed either by joining the Windows Insider program or manual install.[8]

History[edit]

Microsoft’s first foray into achieving Unix-like compatibility on Windows began with the Microsoft POSIX Subsystem, superseded by Windows Services for UNIX via MKS/Interix, which was eventually deprecated with the release of Windows 8.1. The technology behind Windows Subsystem for Linux originated in the unreleased Project Astoria, which enabled some Android applications to run on Windows 10 Mobile.[9] It was first made available in Windows 10 Insider Preview build 14316.[10]

Whereas Microsoft’s previous projects and the third-party Cygwin had focused on creating their own unique Unix-like environments based on the POSIX standard, WSL aims for native Linux compatibility. Instead of wrapping non-native functionality into Win32 system calls as Cygwin did, WSL’s initial design (WSL 1) leveraged the NT kernel executive to serve Linux programs as special, isolated minimal processes (known as «pico processes») attached to kernel mode «pico providers» as dedicated system call and exception handlers distinct from that of a vanilla NT process, opting to reutilize existing NT implementations wherever possible.[11]

WSL beta was introduced in Windows 10 version 1607 (Anniversary Update) on August 2, 2016. Only Ubuntu (with Bash as the default shell) was supported. WSL beta was also called «Bash on Ubuntu on Windows» or «Bash on Windows». WSL was no longer beta in Windows 10 version 1709 (Fall Creators Update), released on October 17, 2017. Multiple Linux distributions could be installed and were available for install in the Windows Store.[12]

In 2017 Richard Stallman expressed fears that integrating Linux functionality into Windows will only hinder the development of free software, calling efforts like WSL «a step backward in the campaign for freedom.»[13]

Though WSL (via this initial design) was much faster and arguably much more popular than the previous UNIX-on-Windows projects, Windows kernel engineers found difficulty in trying to increase WSL’s performance and syscall compatibility by trying to reshape the existing NT kernel to recognize and operate correctly on Linux’s API. At a Microsoft Ignite conference in 2018, Microsoft engineers gave a high-level overview of a new «lightweight» Hyper-V VM technology for containerization where a virtualized kernel could make direct use of NT primitives on the host.[14] In 2019, Microsoft announced a completely redesigned WSL architecture (WSL 2) using this lightweight VM technology hosting actual (customized) Linux kernel images, claiming full syscall compatibility.[6] Microsoft announced WSL 2 on May 6, 2019,[5] and it was shipped with Windows 10 version 2004.[15] It was also backported to Windows 10 version 1903 and 1909.[16]

GPU support for WSL 2 to do GPU-accelerated machine learning was introduced in Windows build 20150.[17] GUI support for WSL 2 to run Linux applications with graphical user interfaces (GUIs) was introduced in Windows build 21364.[18] Both of them are shipped in Windows 11.

In April 2021, Microsoft released a Windows 10 test build that also includes the ability to run Linux graphical user interface (GUI) apps using WSL 2 and CBL-Mariner.[19][18] The Windows Subsystem for Linux GUI (WSLg) was officially released at the Microsoft Build 2021 conference. It is included in Windows 10 Insider build 21364 or later.[20]

Microsoft introduced a Windows Store version of WSL on October 11, 2021, for Windows 11.[21] It reached version 1.0.0 on November 16, 2022 with added support for Windows 10.

Notable releases[edit]

WSL as a Windows component

Release / Feature Preview build Public build
WSL (Beta) (Bash on Ubuntu on Windows) Windows 10 build 14316 Windows 10 version 1607 (Anniversary Update)
WSL (no longer Beta) Windows 10 build 16251 Windows 10 version 1709 (Fall Creators Update)
WSL 2 (lightweight VM) Windows 10 build 18917 Windows 10 version 2004 (also backported to 1903 and 1909)
WSL 2 GPU support Windows 10 build 20150 Windows 11 (also Windows 10 21H2)
WSL 2 GUI support (WSLg) (last version) Windows 10 build 21364 Windows 11
WSL as a Windows Store app

Version Comment
0.47.1 First version
0.67.6 systemd support
1.0.0 Generally available; Windows 10 support

Features[edit]

Bash running on Windows 10

WSL is available in Windows Server 2019 and in versions of Windows 10 from version 1607, though only in 64-bit versions.

Microsoft envisages WSL as «primarily a tool for developers – especially web developers and those who work on or with open source projects».[22] In September 2018, Microsoft said that «WSL requires fewer resources (CPU, memory, and storage) than a full virtual machine» (which prior to WSL was the most direct way to run Linux software in a Windows environment), while also allowing users to use Windows apps and Linux tools on the same set of files.[22]

The first release of WSL provides a Linux-compatible kernel interface developed by Microsoft, containing no Linux kernel code, which can then run the user space of a Linux distribution on top of it, such as Ubuntu,[23][24][25][26] openSUSE,[27] SUSE Linux Enterprise Server,[28][29][12] Debian[30] and Kali Linux.[31] Such a user space might contain a GNU Bash shell and command language, with native GNU command-line tools (sed, awk, etc.), programming-language interpreters (Ruby, Python, etc.), and even graphical applications (using an X11 server at the host side).[22]

The architecture was redesigned in WSL 2,[5] with a Linux kernel running in a lightweight virtual machine environment.

wsl.exe[edit]

The wsl.exe command is used to manage distributions in the Windows Subsystem for Linux on the command-line. It can list available distributions, set a default distribution, and uninstall distributions.[32] The command can also be used to run Linux binaries from the Windows Command Prompt or Windows PowerShell.[33] wsl.exe replaces lxrun.exe which is deprecated as of Windows 10 1803 and later.[34]

WSLg[edit]

Windows Subsystem for Linux GUI (WSLg) is built with the purpose of enabling support for running Linux GUI applications (X11 and Wayland) on Windows in a fully integrated desktop experience.[35] WSLg was officially released at the Microsoft Build 2021 conference and is included in Windows 10 Insider build 21364 or later.[20] However, with the introduction of Windows 11, WSLg is finally shipping with a production build of Windows, bringing support for both graphics and audio in WSL apps.[36]
FreeRDP is used to encode all communications going from the RDP Server (in Weston) to the RDP Client (mstsc on Windows) according to the RDP protocol specifications.[37]

Prerequisites for running WSLg include:

  • Windows 11 or Windows 10 Insider Preview builds 21362-21390.[35][38]
  • A system with virtual GPU (vGPU) enabled for WSL is recommended, as it will allow you to benefit from hardware accelerated OpenGL rendering.[35]

Design[edit]

WSL 1[edit]

Firefox for Linux running on WSL

LXSS Manager Service is the service in charge of interacting with the subsystem (through the drivers lxss.sys and lxcore.sys), and the way that Bash.exe (not to be confused with the Shells provided by the Linux distributions) launches the Linux processes, as well as handling the Linux system calls and the binary locks during their execution.[39] All Linux processes invoked by a particular user go into a «Linux Instance» (usually, the first invoked process is init). Once all the applications are closed, the instance is closed.

WSL 1’s design featured no hardware emulation / virtualization (unlike other projects such as coLinux) and makes direct use of the host file system (through VolFS and DrvFS)[40] and some parts of the hardware, such as the network, which guarantees interoperability. Web servers for example, can be accessed through the same interfaces and IP addresses configured on the host, and shares the same restrictions on the use of ports that require administrative permissions, or ports already occupied by other applications.[41] There are certain locations (such as system folders) and configurations whose access/modification is restricted, even when running as root, with sudo from the shell. An instance with elevated privileges must be launched in order to get «sudo» to give real root privileges, and allow such access.[22]

WSL 1 is not capable of running all Linux software, such as 32-bit binaries,[42][43] or those that require specific Linux kernel services not implemented in WSL. Due to a lack of any «real» Linux kernel in WSL 1, kernel modules, such as device drivers, cannot be run. WSL 2, however, makes use of live virtualized Linux kernel instances. It is possible to run some graphical (GUI) applications (such as Mozilla Firefox) by installing an X11 server within the Windows (host) environment (such as VcXsrv or Xming),[44] although not without caveats, such as the lack of audio support (though this can be remedied by installing PulseAudio in Windows in a similar manner to X11) or hardware acceleration (resulting in poor graphics performance). Support for OpenCL and CUDA is also not being implemented currently, although planned for future releases.[45][46] Microsoft stated WSL was designed for the development of applications, and not for desktop computers or production servers, recommending the use of virtual machines (Hyper-V), Kubernetes, and Azure for those purposes.[22]

In benchmarks WSL 1’s performance is often near native Linux Ubuntu, Debian, Intel Clear Linux or other Linux distributions. I/O is in some tests a bottleneck for WSL.[47][48][49] The redesigned WSL 2 backend is claimed by Microsoft to offer twenty-fold increases in speed on certain operations compared to that of WSL 1.[6] In June 2020, a benchmark with 173 tests with an AMD Threadripper 3970x shows good performance with WSL 2 (20H2) with 87% of the performance of native Ubuntu 20.04.0 LTS. This is an improvement over WSL 1, which has only 70% of the performance of native Ubuntu in this comparison. WSL 2 improves I/O performance, providing a near-native level.[50]
A comparison of 69 tests with Intel i9 10900K in May 2020 shows nearly the same relative performance.[51] In December 2020, a benchmark with 43 tests with an AMD Ryzen 5900X shows good performance with WSL 2 (20H2) with 93% of the performance of native 20.04.1 LTS. This is an improvement over WSL 1, which has only 73% in this comparison.[52]

WSL 2[edit]

Synaptic package manager running on WSL

Version 2 introduces changes in the architecture. Microsoft has opted for virtualization through a highly optimized subset of Hyper-V features, in order to run the kernel and distributions (based upon the kernel), promising performance equivalent to WSL 1. For backward compatibility, developers don’t need to change anything in their published distributions. WSL 2 settings can be tweaked by the WSL global configuration, contained in an INI file named .wslconfig in the User Profile folder.[53][54]

The distribution installation resides inside an ext4-formatted filesystem inside a virtual disk, and the host file system is transparently accessible through the 9P protocol,[55] similarly to other virtual machine technologies like QEMU.[56] For the users, Microsoft promised up to 20 times the read/write performance of WSL 1.[5] From Windows an IFS network redirector is provided for Linux guest file access using the UNC path prefix of \\wsl$.

WSL 2 requires Windows 11,[57] or Windows 10 version 1903 or higher, with Build 18362 or higher, for x64 systems, and Version 2004 or higher, with Build 19041 or higher, for ARM64 systems.[8]

WSL 2 and Windows 11 are in good shape with 95% performance of native Ubuntu 20.04 LTS.[58]

See also[edit]

  • Azure Sphere
  • FreeBSD § OS compatibility layers
  • SmartOS § Virtualization
  • Windows Terminal
  • Xenix

References[edit]

  1. ^ «Release 1.2.5 · microsoft/WSL». GitHub. Retrieved 4 July 2023.
  2. ^ «Release 2.0.1 · microsoft/WSL». GitHub. Retrieved 27 September 2023.
  3. ^ Leeks, Stuart (2020). Windows Subsystem for Linux 2 (WSL 2) Tips, Tricks, and Techniques: Maximise Productivity of Your Windows 10 Development Machine with Custom Workflows and Configurations. Birmingham: Packt Publishing. pp. 18–19. ISBN 978-1-80056-352-0. OCLC 1202451000.
  4. ^ June 2021, Darren Allan 23 (23 June 2021). «Windows 11 could seamlessly run graphical Linux apps». TechRadar. Retrieved 29 June 2021.
  5. ^ a b c d Craig Loewen (6 May 2019). «Announcing WSL 2». Windows Command Line Tools For Developers.
  6. ^ a b c mscraigloewen. «About WSL 2». docs.microsoft.com.
  7. ^ «WSL 2 Post BUILD FAQ». Windows Command Line Tools For Developers. 14 May 2019.
  8. ^ a b craigloewen-msft (24 February 2022). «Install WSL on Windows 10». Microsoft.
  9. ^ Bright, Peter (6 April 2016). «Why Microsoft needed to make Windows run Linux software». Ars Technica. Condé Nast.
  10. ^ Aul, Gabe (6 April 2016). «Announcing Windows 10 Insider Preview Build 14316». Windows Experience Blog. Microsoft.
  11. ^ «Windows Subsystem for Linux Overview». Windows Subsystem for Linux. Retrieved 22 April 2018.
  12. ^ a b «What’s new in WSL in Windows 10 Fall Creators Update — Windows Command Line». Windows Command Line. 11 October 2017. Retrieved 15 October 2021.
  13. ^ Heath, Nick (20 September 2017). «Will Microsoft love Linux to death? Shuttleworth and Stallman on whether Windows 10 is free software’s friend». TechRepublic. Archived from the original on 1 December 2022. Retrieved 18 February 2022.
  14. ^ Microsoft Ignite (2 October 2018), OS internals: Technical deep-dive into operating system innovations — BRK3365, archived from the original on 9 November 2021, retrieved 7 May 2019
  15. ^ «WSL 2 will be generally available in Windows 10, version 2004 — Windows Command Line». Windows Command Line. 13 March 2020. Retrieved 15 October 2021.
  16. ^ «WSL 2 Support is coming to Windows 10 Versions 1903 and 1909 — Windows Command Line». Windows Command Line. 20 August 2020. Retrieved 15 October 2021.
  17. ^ «GPU accelerated ML training inside the Windows Subsystem for Linux — Windows Developer Blog». Windows Blog. 17 June 2020. Retrieved 16 October 2021.
  18. ^ a b «The Initial Preview of GUI app support is now available for the Windows Subsystem for Linux — Windows Command Line». Windows Command Line. 21 April 2021.
  19. ^ Foley, Mary Jo (21 April 2021). «New Windows 10 test build adds first preview of Linux GUI apps on WSL». ZDNet. Retrieved 23 April 2021.
  20. ^ a b Abrams, Lawrence (29 May 2021). «Hands on with WSLg: Running Linux GUI apps in Windows 10». Bleeping Computer. Retrieved 30 May 2021.
  21. ^ «A preview of WSL in the Microsoft Store is now available! — Windows Command Line». Windows Command Line. 11 October 2021. Retrieved 16 October 2021.
  22. ^ a b c d e «Frequently Asked Questions for WSL». Microsoft. Retrieved 13 November 2016.
  23. ^ Harsh, Mike (30 March 2016). «Run Bash on Ubuntu on Windows». Building Apps for Windows. Microsoft.
  24. ^ Finley, Klint (30 March 2016). «Why Microsoft Making Linux Apps Run on Windows Isn’t Crazy». Wired. Condé Nast.
  25. ^ Kirkland, Dustin (30 March 2016). «Ubuntu on Windows – The Ubuntu Userspace for Windows Developers». Ubuntu Insights. Canonical.
  26. ^ Hammons, Jack (9 April 2016). «Bash on Ubuntu on Windows». MSDN. Microsoft.
  27. ^ Get openSUSE Leap 42 — Microsoft Store
  28. ^ Get SUSE Linux Enterprise Server 12 — Microsoft Store
  29. ^ Yegulalp, Serdar (12 May 2017). «Windows Subsystem for Linux welcomes Suse and Fedora options». InfoWorld. Retrieved 16 September 2017.
  30. ^ «Debian GNU/Linux for WSL now available in the Windows Store». Windows Command Line Tools For Developers. Retrieved 7 March 2018.
  31. ^ «Kali Linux in the Windows App Store». Retrieved 9 March 2018.
  32. ^ Manage and configure Windows Subsystem for Linux
  33. ^ Windows Subsystem for Linux interoperability with Windows
  34. ^ Command Reference for Windows Subsystem for Linux
  35. ^ a b c Welcome to WSLg, Microsoft, 7 November 2021, retrieved 7 November 2021
  36. ^ Salter, Jim (7 October 2021). «The best part of Windows 11 is a revamped Windows Subsystem for Linux». Ars Technica. Retrieved 7 November 2021.
  37. ^ «Installing WSLg». GitHub. 27 April 2022. Retrieved 27 April 2022.
  38. ^ «Clarify Windows 10 vs 11 and build numbers (#485) · microsoft/wslg@5ddd8d2». GitHub. Retrieved 28 May 2022.
  39. ^ Jack Hammons (22 April 2016). «Windows Subsystem for Linux Overview». Windows Subsystem for Linux blog on MSDN.
  40. ^ Jack Hammons (15 June 2016). «WSL File System Support». Windows Subsystem for Linux blog on MSDN.
  41. ^ Jack Hammons (8 November 2016). «WSL Networking». Windows Subsystem for Linux blog on MSDN.
  42. ^ «Please enable WSL to run 32 bit ELF binaries». Windows Developer feedback (Microsoft/UserVoice). Archived from the original on 23 August 2019. Retrieved 21 January 2018.
  43. ^ «Support for 32-bit i386 ELF binaries». GitHub.
  44. ^ «Windows 10’s Bash shell can run graphical Linux applications with this trick». PC World. Retrieved 10 September 2018.
  45. ^ «GPU not accesssible for running tensorflow and installing CUDA · Issue #1788 · Microsoft/WSL». GitHub. Retrieved 10 September 2018.
  46. ^ «OpenCL & CUDA GPU support». Windows Developer feedback (Microsoft/UserVoice). 15 September 2016. Archived from the original on 7 July 2018. Retrieved 10 September 2018.
  47. ^ «Windows Subsystem for Linux». Phoronix.
  48. ^ Larabel, Michael (12 October 2018). «A Look At The Windows 10 October 2018 Update Performance With WSL». Phoronix.
  49. ^ Larabel, Michael (5 November 2018). «The WSL Improvements In The Windows 10 October 2018 Update». Phoronix.
  50. ^ Larabel, Michael (24 June 2020). «Ubuntu 20.04 vs. Windows 10 WSL/WSL2 Performance In 170+ Benchmarks». Phoronix.
  51. ^ Larabel, Michael (17 June 2020). «Windows 10 May 2020 Performance For WSL vs. WSL2». Phoronix.
  52. ^ Larabel, Michael (16 December 2020). «Windows Subsystem For Linux / WSL2 Performance With The AMD Ryzen 9 5900X». Phoronix.
  53. ^ Loewen, Craig (26 July 2019). «What’s new for WSL in Insiders Preview Build 18945». Microsoft devblog. Archived from the original on 26 July 2019. Retrieved 26 July 2019. In this new update we’ve added the ability to start using global config options for WSL. These options are targeted towards power users who want to further customize their WSL experience.
  54. ^ Hillis, Ben (25 July 2019). «MicrosoftDocs/WSL | Build 18947». GitHub. Archived from the original on 26 July 2019. Retrieved 26 July 2019.
  55. ^ «A Deep Dive Into How WSL Allows Windows to Access Linux Files». Windows Command Line Tools For Developers. 30 May 2019. Retrieved 24 June 2019.
  56. ^ Jujjuri, Venkateswararao; Van Hensbergen, Eric; Liguori, Anthony; Pulavarty, Badari (13–16 July 2010). «VirtFS—A virtualization aware File System pass-through» (PDF). Linux Symposium.
  57. ^ «Comparing WSL 1 and WSL 2». Microsoft Learn. 4 October 2022. Retrieved 18 October 2022.
  58. ^ Larabel, Michael (29 September 2021). «Windows 11 WSL2 Performance is Quite Competitive Against Ubuntu 20.04 LTS / Ubuntu 21.10». Phoronix.

Further reading[edit]

  • Barnes, Hayden (2021). Pro Windows Subsystem for Linux (WSL): Powerful Tools and Practices for Cross-Platform Development and Collaboration. Apress. ISBN 978-1484268728.
  • Leeks, Stuart (2020). Windows Subsystem for Linux 2 (WSL 2) Tips, Tricks, and Techniques: Maximise productivity of your Windows 10 development machine with custom workflows and configurations. Packt Publishing. ISBN 978-1800562448.
  • Singh, Prateek (2020). Learn Windows Subsystem for Linux: A Practical Guide for Developers and IT Professionals. Apress. ISBN 978-1484260371.

External links[edit]

  • WSL on Microsoft Learn
  • WSL on GitHub
  • WSL2-Linux-Kernel on GitHub
  • Brown, Pete (22 July 2016). «Fun with the Windows Subsystem for Linux». Windows Developer Blog. Microsoft.
Windows 11 WSL improvements
Windows 11 WSL improvements
(Image credit: Windows Central)

The Windows Subsystem for Linux (WSL) for Windows 11 has been updated with various new features and improvements, including support for Linux GUI apps, changes to make it easier to install and update the platform, File Explorer integration, storage enhancements, and more.

On Windows, WSL is the platform that allows you to run Linux distributions (such as Ubuntu and Debian) using a lightweight virtual machine, alongside Windows, without the need for setting up a full-blown virtual machine or configure a dual-boot system.

In this Windows 11 guide, we will show you the most significant changes shipping with the updated version of the Windows Subsystem for Linux.

The new changes for the Windows Subsystem for Linux

While this is still considered WSL version 2, there are many improvements to the experience, including a new faster installation process, support for Linux graphical applications, File Explorer integration, and more.

Simplified installation

On Windows 11, the installation process of WSL has been noticeably simplified. In the past, you first needed to enable WSL 1 through the «Windows Features» interface, enable the virtualization platform, and download an update for the kernel to switch to WSL 2. Starting with this new version, Microsoft is implementing two new commands, including the

wsl --install

 and 

wsl --update

 to install and update the system more quickly.

In other words, if the Windows Subsystem for Linux is not set up on your computer, you can now run the

wsl --install

command to install all the components required to start using Linux on Windows 11. The command will configure the virtual machine platform, install the WSL components, download the Windows Subsystem for Linux kernel, set up the Linux GUI app support, and install the Ubuntu by default. After running the command, the only extra step is to restart the computer to apply the configuration.

Windows 11 WSL install

Source: Windows Central (Image credit: Source: Windows Central)

It’s worth noting that the custom Linux kernel available inside the Windows 11 system image has been removed, and it’s now downloaded from the Microsoft Store.

If you use the

wsl --install

command with the

--distribution

option, you can also specify the distro you want to download in the case you don’t wish to use Ubuntu as the default distro.

You can always use the

wsl --list --online

command to view all the available distributions that you can get on Windows 11.

Furthermore, there’s a new

wsl --update

command to check and install any updates available for the platform.

While these commands are new to Windows 11, they are also available for Windows 10.

Linux GUI apps

Perhaps one of the most significant improvements in this update is the support for Linux GUI apps. So, this basically means you can now install graphical applications and run them alongside Windows 11 apps.

Windows 11 WSL Linux GUI apps

Source: Windows Central (Image credit: Source: Windows Central)

Microsoft is introducing this feature for developers to test their apps, but you can use it to run your favorite editors, tools, and programs. The support also ships with GPU accelerated 3D graphics and microphones and speakers, which means that if you install a media application, these components will be available for apps.

Once you set up the Windows Subsystem for Linux with the install command, it also sets up an X server that runs automatically, which includes Wayland, pulse audio, and other components to make everything work. Then, after closing the application and the WSL session, the system distro will shut down automatically.

In addition, during the installation of the app, the system will add an entry in the Start menu to launch the program without the need for typing the command in the console. Furthermore, when running an app, you will notice the icon also includes a Linux log, indicating this is not a native Windows application.

When running an application, you will notice the system renders the visuals as if it was installed on Linux. For example, the app frame, menus, buttons, and other events are the same as the graphical interface of Linux. However, Windows is not rendering these visuals. Instead, you are seeing a remote desktop connection to the distro running the application.

Attach and mount drives to distros

In this updated version of the Windows Subsystem for Linux, it’s also possible to attach and mount a drive to access Linux file systems not supported on Windows 11.

The process to mount a drive is straightforward. You would open PowerShell and run the

wmic diskdrive list brief

to determine the disk you want to mount, and then (for example) the

wsl --mount \\.\physicaldrivepath --partition 1

command will mount the first partition using the ext4 file system of the physical drive.

If you need to mount a different file system, you will use (for example) the

wsl --mount \\.\physicaldrivepath -t vfat

command to mount the file system as «fat.»

Once the drive is mounted, you can always access the file from File Explorer using the

\\wsl.localhost\distroname\mountpoint

command. (Of course, you always need to update the commands with the information corresponding to your situation.)

File Explorer with Linux integration

Also, the Windows Subsystem for Linux is now better integrated into the File Explorer app. For example, the default file manager on Windows 11 now includes a «Linux» entry in the navigation pane, which allows you to access all the distros files quickly.

File Explorer Linux integration

Source: Windows Central (Image credit: Source: Windows Central)

In addition, the default path has been changed from

\\wsl\

to

\\wsl.localhost\

to improve performance and reliability, but you can still use the original path to access the files.

Execute commands on startup

The platform also includes a new option to run Linux commands during the startup of a distro. However, to use this new functionality, you need to change the

/etc/wsl.config

configuration file by adding the «command» option under the «boot» section.

GPU compute

The WSL solution now also comes with GPU compute, a new feature that enables the Linux binaries to leverage the GPU to perform more intensive machine learning (ML) development and data science workflows.

More Windows resources

For more helpful articles, coverage, and answers to common questions about Windows 10 and Windows 11, visit the following resources:

  • Windows 10 on Windows Central — All you need to know
  • Windows 10 help, tips, and tricks
  • Windows 11 on Windows Central — All you need to know

All the latest news, reviews, and guides for Windows and Xbox diehards.

Mauro Huculak is technical writer for WindowsCentral.com. His primary focus is to write comprehensive how-tos to help users get the most out of Windows 10 and its many related technologies. He has an IT background with professional certifications from Microsoft, Cisco, and CompTIA, and he’s a recognized member of the Microsoft MVP community.

Время на прочтение
4 мин

Количество просмотров 25K

image

В новостях прошла весть, что теперь WSL поддерживает демон systemd. В качестве преимущества использования systemd предлагается установка и запуск приложений и сервисов через snap. Для примера приведены Nextcloud, LXD, MySQL, MicroK8s и Docker. Я пока в преимущества самого snap не вникал. Но возможность запуска и управления демонами через systemd привлекает.

Начинаем с установки «Virtual Machine Platform». Запускать команду надо от имени администратора в консоли PowerShell:

PS C:\> dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all
Cистема DISM
Версия: 10.0.22000.653
Версия образа: 10.0.22000.1042
Включение функций
[==========================100.0%==========================]
Операция успешно завершена.

Для запуска systemd нужна WSL версия 0.67.6. Статья на сайте Microsoft рекомендует установить предварительную версию WSL из магазина приложений. Проблема в том, что в магазине версия 0.66. Для установки WSL Preview требуется Windows 11 (сборка 22000 или более новая).

Поступаем следующим образом. Ставим из магазина приложений «устаревшую» версию (0.66), чтобы в дальнейшем получать обновления на нее. А дальше качаем с GitHub нужную нам версию 0.67.6. Она последняя доступная на момент написания статьи. Возможно, на момент прочтения выйдут версии поновее. При запуске скаченного с GitHub пакета Менеджер установки предложит обновить WSL до нужной нам версии, то есть распознает, что WSL Preview у вас уже установлен. Это позволит в будущем обновлять WSL Preview автоматически встроенными в магазин приложений средствами

Какие команды могут помочь. Проверка версии WSL.

PS C:\> wsl.exe --version

Если команда не распознает параметр «—version», значит у вас старая версия WSL (0.65 и ниже).

Недопустимый параметр в командной строке: --version
(c) Корпорация Майкрософт (Microsoft Corporation). Все права защищены.
Использование: wsl.exe [Аргумент] [Параметры...] [Командная строка]
....


В этом случае будет работать параметр «—status»:

PS C:\> wsl --status
Распределение по умолчанию: Ubuntu-20.04
Версия по умолчанию: 2
Подсистема Windows для Linux в последний раз обновлена 21.06.2022
Включены автоматические обновления WSL.
Версия ядра: 5.10.102.1


В версии 0.66 параметр «—version» (-v) и статус «—status» дают следующий вывод:

PS C:\> wsl --status
Default Distribution: Ubuntu-20.04
Default Version: 2
WSL version: 0.66.2.0
Kernel version: 5.15.57.1
WSLg version: 1.0.42
MSRDC version: 1.2.3401
Direct3D version: 1.606.4
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22000.978
PS C:\> wsl --version
WSL version: 0.66.2.0
Kernel version: 5.15.57.1
WSLg version: 1.0.42
MSRDC version: 1.2.3401
Direct3D version: 1.606.4
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22000.978


А вот в версии 0.67 вывод параметра «—status» меняет формат:

PS C:\> wsl --status
Default Distribution: Ubuntu-20.04
Default Version: 2


Итого, надо добиться того, чтобы версия WSL («WSL version» в выводе команды) была 0.67.6.0.

PS C:\> wsl -v
WSL version: 0.67.6.0
Kernel version: 5.15.62.1
WSLg version: 1.0.44
MSRDC version: 1.2.3401
Direct3D version: 1.606.4
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22000.1042
PS C:\> wsl --status
Default Distribution: Ubuntu-20.04
Default Version: 2

Я предполагаю, что уже есть созданная виртуальная среда в WSL. Кратко, как создать, если еще нет. Смотрим список доступных систем в WSL:

PS C:\> wsl.exe --list --online
The following is a list of valid distributions that can be installed.
Install using 'wsl.exe --install <Distro>'.
NAME               FRIENDLY NAME
Ubuntu             Ubuntu
Debian             Debian GNU/Linux
kali-linux         Kali Linux Rolling
SLES-12            SUSE Linux Enterprise Server v12
SLES-15            SUSE Linux Enterprise Server v15
Ubuntu-18.04       Ubuntu 18.04 LTS
Ubuntu-20.04       Ubuntu 20.04 LTS
OracleLinux_8_5    Oracle Linux 8.5
OracleLinux_7_9    Oracle Linux 7.9

Далее ставим выбранный дистрибутив параметром «—install», пример:

PS C:\> wsl.exe --install Ubuntu


В конце установки предложат ввести имя пользователя Linux и пароль для него.

После установки надо в файл /etc/wsl.conf добавить ключ для запуска systemd. В моем случае файл /etc/wsl.conf не существовал и был создан при редактировании:

user@DESKTOP:~$ sudo vim /etc/wsl.conf
[boot]
systemd=true

Важно, файл редактируется в гостевой системе Linux, не на хосте.

PS C:\> wsl.exe --shutdown

В консоли Linux появится сообщение:

user@DESKTOP:~$
[process exited with code 1 (0x00000001)]


Вообще рекомендую команду «wsl.exe —shutdown» вводить после каждого изменения в WSL. Чтобы запустить WSL после остановки, нужно открыть заново консоль гостевой ОС.

Проверяем, что всё получилось:

user@DESKTOP:~$ systemctl list-unit-files --type=service
UNIT FILE                                  STATE           VENDOR PRESET
accounts-daemon.service                    masked          enabled
apparmor.service                           enabled         enabled
apport-autoreport.service                  static          -
apport-forward@.service                    static          -
apport.service                             generated       -
apt-daily-upgrade.service                  static          -
apt-daily.service                          static          -
atd.service                                masked          enabled
autovt@.service                            alias           -
blk-availability.service                   enabled         enabled
bolt.service                               static          -
clickhouse-server.service                  masked          enabled
cloud-config.service                       enabled         enabled
cloud-final.service                        enabled         enabled
cloud-init-hotplugd.service                static          -
.........

И, например, так

user@DESKTOP:~$ systemctl status networkd-dispatcher.service
● networkd-dispatcher.service - Dispatcher daemon for systemd-networkd
     Loaded: loaded (/lib/systemd/system/networkd-dispatcher.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2022-09-25 23:57:28 MSK; 37s ago
   Main PID: 133 (networkd-dispat)
      Tasks: 1 (limit: 9390)
     Memory: 16.8M
     CGroup: /system.slice/networkd-dispatcher.service
             └─133 /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers
Sep 25 23:57:27 DESKTOP systemd[1]: Starting Dispatcher daemon for systemd-networkd...
Sep 25 23:57:28 DESKTOP networkd-dispatcher[133]: No valid path found for iwconfig
Sep 25 23:57:28 DESKTOP networkd-dispatcher[133]: No valid path found for iw
Sep 25 23:57:28 DESKTOP systemd[1]: Started Dispatcher daemon for systemd-networkd.
Sep 25 23:57:28 DESKTOP networkd-dispatcher[133]: WARNING:Unknown index 7 seen, reloading interface list

Всё, можно пользоваться. Примеры использования есть на видео и в статье выше:

Ever since Windows added the support for Windows Subsystem for Linux (WSL), it has become easy for admins, developers, and power users to step into the world of Linux. Before WSL support was added, users had to rely on heavy virtualization tools (such as VirtualBox, VMware Workstation, and Hyper-V) or even dual-boot configurations to run a Linux instance.

Contents

  1. Introduction to Windows Subsystem for Linux
  2. Differences between WSL and traditional VM
    • When to choose WSL 2
    • When to choose a traditional VM
  3. Prerequisites for WSL
  4. Install WSL in Windows 11
    • Manually install Windows Subsystem for Linux
  5. Install and manage Linux distros in WSL
    • List the available Linux distros
    • Install a Linux distro
    • List installed Linux distros
    • Change the default WSL Distro
    • Run and terminate Linux distros
    • Change the WSL version
    • Remove a Linux distro
    • Mount a disk in WSL 2
    • Update the WSL Linux kernel
    • File sharing between Windows and the WSL distro
  • Author
  • Recent Posts

Surender Kumar has more than twelve years of experience in server and network administration. His fields of interest are Windows servers, Active directory, PowerShell, web servers, networking, Linux, virtualization, and Kubernetes. He loves writing for his blog.

In this article, I will cover the basics of Windows Subsystem for Linux, how to install it in Windows 11, and how to run an Ubuntu Linux container in WSL. You can also run any other version of Linux in WSL.

Introduction to Windows Subsystem for Linux

Windows Subsystem for Linux is an optional feature added to Windows 10 and later versions that allows users to run a Linux instance, including most command-line tools and applications, directly on Windows without using any traditional virtual machine or dual-boot configuration.

The WSL feature was originally added to Windows 10 version 1607 (Anniversary Update) and requires an x64-bit version of Windows. On Server operating systems, it is available for installation in Server 2016 version 1803.

The initial version of WSL (now known as WSL v1 or WSL 1) does not use the real Linux kernel. Instead, a translation layer between the Linux distribution and the Windows NT kernel translates and handles all the kernel-level operations.

Windows Subsystem for Linux v1 architecture

Windows Subsystem for Linux v1 architecture

A lot has changed since the initial launch of WSL. The newer version (known as WSL v2 or WSL 2) was released with Windows 10 version 1903, build 18362 (May 2019 Update); it included various architectural and performance improvements, particularly the use of the real Linux kernel. In WSL 2, in place of the translation layer, a real Linux kernel runs inside a lightweight utility virtual machine (VM), though this is not a traditional VM. This new architecture has resulted in a significant increase in file system performance and full system call compatibility.

Windows Subsystem for Linux v2 architecture

Windows Subsystem for Linux v2 architecture

Differences between WSL and traditional VM

While WSL 2 uses Microsoft’s Hyper-V as a hypervisor under the hood to run the utility VM, it does not require you to enable Windows’ Hyper-V role or feature; WSL works perfectly fine without it.

Please remember that WSL is not a full replacement for a traditional VM. Let me tell you why.

With the help of a hypervisor, a traditional VM creates an isolated environment in your host system that acts as a separate virtual computer with all the hardware components, such as CPU, RAM, and storage. This architecture allows a user to have a completely isolated system with a guest operating system.

However, this is not the case with WSL. While WSL 2 does run a real Linux kernel in a Hyper-V–based utility VM, it works completely behind the scenes; hence, the user does not need to install and manage the operating system or any other resources as with a traditional VM.

When to choose WSL 2

  • You have a less powerful computer.
  • You need a smaller memory or storage footprint.
  • You need faster I/O performance.
  • You don’t want to waste your time installing and managing the virtual machine.
  • You need to run a Linux distribution (distro) for development and testing purposes.

When to choose a traditional VM

  • You have a powerful computer for which resources (such as memory, CPU, and storage) are not a concern.
  • You need to run an operating system other than GNU/Linux.
  • You need a completely isolated and full-fledged system environment.
  • You want to manage the operating system, applications, and resources.
  • You want to run production-level workloads.
  • You need advanced virtualization features, such as snapshots and load balancing.

In a nutshell, both WSL and traditional VM have several pros and cons; whether you want to run a Linux distro within WSL or within a traditional virtualization platform (such as VirtualBox, Hyper-V, or VMware Workstation) depends entirely on your interest and use case. I hope the aforementioned points will help you make an informed decision.

Prerequisites for WSL

Your system must have certain prerequisites before you can run WSL.

  • It must have x64-bit and ARM64 processors.
  • To run WSL 1 on an x64 system, it must be running at least Windows 10 version 1607 (Anniversary Update).
  • To run WSL 2 on an x64 system, it must be running at least Windows 10 version 1903, build 18362 (May 2019 Update).
  • To run WSL 2 on an ARM64 system, it must be running at least Windows 10 version 2004 (build 19041 or higher).

To check the operating system version and build number, you can type the winver command in the RUN dialog and press Enter.

Install WSL in Windows 11

If your system is running Windows 10 version 2004 (build 19041 or higher) or Windows 11, Microsoft has made it incredibly easy to install WSL 2. Just launch the PowerShell console with an elevated privilege and run the following command:

wsl --install

This command enables the optional Windows features required for WSL, downloads the latest Linux kernel, sets WSL 2 as the default, and installs the Ubuntu Linux distro for you.

Install WSL using PowerShell The latest method

Install WSL using PowerShell The latest method

Once the command is finished, you can restart your computer using the Restart-Computer -Force command.

After the restart, the WSL installation will resume automatically, and you will see an Ubuntu Linux terminal, which will ask you to set the username and password for the Ubuntu WSL instance.

Ubuntu Linux running in the WSL instance

Ubuntu Linux running in the WSL instance

Manually install Windows Subsystem for Linux

If you are running an older Windows 10 build or prefer installing WSL manually, you can follow the manual installation steps laid out below.

Launch the Windows PowerShell console with an elevated privilege and run the following command:

Enable-WindowsOptionalFeature -Online -FeatureName 'Microsoft-Windows-Subsystem-Linux' -All -NoRestart

Enable the WSL feature using PowerShell The manual method

Enable the WSL feature using PowerShell The manual method

Many people still prefer using WSL 1. If you also want the same, you can restart your system at this stage and directly jump to Point 5 after rebooting. If you would rather use WSL 2, please continue to the next point. Make sure your system meets the prerequisites for running WSL 2.

The next step is to run the following command:

Enable-WindowsOptionalFeature -Online -FeatureName 'VirtualMachinePlatform' -All -NoRestart

Enable the Virtual Machine Platform feature using PowerShell The manual method

Enable the Virtual Machine Platform feature using PowerShell The manual method

Now use the following command to restart your system:

Restart-Computer -Force

After the system has restarted, download the latest kernel package for your system using the following links and install the package:

  • WSL 2 Linux kernel for x64 systems
  • WSL 2 Linux kernel for ARM64 systems

Once the kernel package is installed, your system should be running WSL 1 by default. To change the default version to WSL 2, run the following command in an elevated PowerShell console:

wsl --set-default-version 2

Now you can install any Linux distro of your choice. We will cover that in the next section.

Install and manage Linux distros in WSL

Now that you have installed WSL in your system, you can run and manage your Linux distros using PowerShell. Launch the PowerShell console with an elevated privilege and use the commands mentioned in this section.

List the available Linux distros

To see the list of all the Linux distros available for installation with WSL in the online store, you can use the following command:

wsl --list --online

WSL list online

WSL list online

You can also use the short-version command wsl -l -o, which will yield a list of all the supported Linux distros available online for installation in your system.

If you’re thinking that this list is quite small and that you cannot see the distro of your choice, rest assured that there is a way you can import any Linux distro in WSL. But that is a manual method involving multiple steps. Hopefully, we’ll discuss that later.

Install a Linux distro

Once you have the list of available distros for your system, you can use the following command for installation:

wsl --install -d kali-linux

Install a Linux distro in WSL

Install a Linux distro in WSL

This command installs Kali Linux in WSL. Of course, you can replace kali-linux with the name of the distro you want to install. Once installed, Kali Linux will be launched in a terminal.

Kali Linux in WSL Initial setup

Kali Linux in WSL Initial setup

List installed Linux distros

To see the list of all the Linux distros installed in your system, you can use the following command:

wsl --list --verbose

WSL list verbose

WSL list verbose

You can also use the short-version command wsl -l -v, which will show a list of all the Linux distros installed in your system.

To list only the instances that are currently running, you can use the following command:

wsl --list --running

List of only the running instances in WSL

List of only the running instances in WSL

Change the default WSL Distro

Have you noticed a small asterisk (*) right next to the distro name when you run the wsl -l -v command? This asterisk represents the default distro for WSL. The wsl —status command also shows the current default distro. The default distro is the one that runs when you run wsl in a command line without specifying the —distribution (or -d) parameter.

For example, in my system, docker-desktop is set as the default distro. Changing the default distro to kali-linux can be done with the following command:

wsl --set-default kali-linux

Changing the default distro in WSL

Changing the default distro in WSL

Run and terminate Linux distros

To run any distro and connect to it, you can directly use the following command in PowerShell or the command prompt:

wsl --distribution kali-linux --user surender

Run and connect a WSL distro with a specific user

Run and connect a WSL distro with a specific user

Run and connect a WSL distro with a specific user.

After using the above command, you will be directly logged in to the Kali Linux bash shell. The good thing is that your Windows drives are automatically mounted under /mnt, so you can seamlessly transfer the files between Windows and the WSL instance.

To terminate (or stop) a WSL instance, you can use the following command:

wsl --terminate kali-linux

Terminate or stop a single WSL instance

Terminate or stop a single WSL instance

This command stops a particular Linux distro (Kali Linux in this case). If your system has multiple Linux distros that are running, you can use the following command to stop them all at once:

wsl --shutdown

Stop all Linux instances using WSL shutdown

Stop all Linux instances using WSL shutdown

This command immediately stops all the running Linux distros as well as the utility VM.

Change the WSL version

As mentioned earlier, WSL 1 runs by default after installation. To change the WSL version globally, you can use the following command:

wsl --set-default-version 2

Set the default WSL version

Set the default WSL version

This command changes the default WSL to WSL 2. If you want to use WSL 1, you can type 1 instead of 2 in the command. Setting the default version to WSL 2 means that every Linux distro you will install in this system will be running in WSL 2.

Apart from changing the WSL version globally, which will affect all future WSL instances, you can set the WSL version specifically for the selected Linux distro. To do this, use the following command:

wsl --set-version kali-linux 1

This command converts the Kali Linux distro to WSL 1. It could take a while for the conversion process to finish and for the change to be verified; you will see the VERSION column of the wsl -l -v command, as shown in the following image:

Change the WSL version for a particular distro

Change the WSL version for a particular distro

Please note that the WSL instance will be stopped during the version change process.

Remove a Linux distro

To remove or uninstall a Linux distro from WSL, you need to unregister the distro using the following command:

wsl --unregister ubuntu

Unregister a distro from WSL

Unregister a distro from WSL

This command unregisters a Linux distro (Ubuntu in this case). Please note that this command will permanently erase all the data, settings, and applications within that distro.

Mount a disk in WSL 2

A cool feature available in WSL 2 is the ability to mount disks that are not supported by Windows. Please note that this feature is available only in WSL 2 running on Windows 11 (build 22000 or higher). Furthermore, the Linux distro in which you plan to mount the disk should be running in WSL 2.

This feature is particularly useful when you want to access the contents of a disk formatted with a Linux file system that is not supported by Windows. To do this, you can mount the disk using the wsl —mount command and then access the contents using WSL.

A quick overview—Windows can recognize FAT, NTFS, ReFS, exFAT, and a few other file systems, but the EXT3 and EXT4 file systems are not supported. exFAT is a cross-platform file system that is equally supported on Windows, Linux, and MacOS.

For demonstration purposes, I just connected a virtual disk formatted with the EXT4 file system. As this disk is formatted in EXT4, Windows won’t recognize it, and nothing will show up in File Explorer.

To access its contents, we can mount this storage device and make it available for Linux distros. However, before mounting the disk, we need to get the device ID for the particular disk using the following PowerShell command:

Get-CimInstance -query 'SELECT * from Win32_DiskDrive'

The Get CimInstance command used to obtain the device ID

The Get CimInstance command used to obtain the device ID

Note down the device ID returned by the above command and use it to mount the disk using the following command:

wsl --mount <DeviceID>

This command mounts the specified disk and makes it available to all the Linux distros in WSL. You can use the —bare parameter to make the disk available in WSL without mounting it to all distros. The —type parameter can be used to specify the file system for the disk. If you don’t know the file system, you can skip this parameter.

The image below displays the commands I used:

Mount and access a disk in WSL

Mount and access a disk in WSL

After entering the bash terminal, I used the lsblkid command to list the partitions available on the disk. Once I obtained the partition’s name, I mounted the partition inside the /mnt/vdisk/ directory using the regular mount command. Following this, I could read the contents of the disk.

Once you finish accessing the contents and want to unmount the disk, you can use the following command:

wsl --unmount <DeviceID>

Unmount the disk in WSL

Unmount the disk in WSL

Update the WSL Linux kernel

By default, the WSL Linux kernel will be automatically updated with Windows updates. However, to manually check and update the kernel, you can use the following commands:

wsl --status

This command shows the status of WSL, including the default distro name, WSL version, and kernel version.

wsl --update

This command forcefully checks and updates the kernel version if an update is available.

Check and update the kernel in WSL

Check and update the kernel in WSL

File sharing between Windows and the WSL distro

As mentioned above, your Windows drives are automatically mounted under /mnt inside the Linux distro; hence, you can seamlessly transfer files between Windows and the WSL instance. To transfer files, you should navigate to the mounted drive and start accessing the files as you normally would in the Linux terminal.

Access Windows drives in WSL

Access Windows drives in WSL

If you would like to view the Linux files directly inside Windows File Explorer, you can use the following command in the bash terminal of the Linux distro:

explorer.exe .

Please make sure you don’t miss the period (.) at the end of the command.

Launch File Explorer in WSL

Launch File Explorer in WSL

This will open File Explorer in Windows directly inside your current working directory in the Linux distro.

Open File Explorer in WSL

Open File Explorer in WSL

This is extremely helpful if you’re a developer. You can use this trick to manage your projects and files in Windows as well as in Linux distros, taking advantage of Linux build tools that are not normally available in Windows.

And that’s the end of this guide.

Subscribe to 4sysops newsletter!

In the next article, we will discuss how you can export your favorite Linux distro and make it available in WSL 2, assuming the distro is not available for installation from the Microsoft online store by default.

  • Wsat exe windows 10 скачать с официального сайта
  • Wsapxx что это за процесс windows 10
  • Write image to usb windows
  • Wsappx что это за процесс windows 10
  • Wpsystem что это за папка windows 10 на диске d