
Introduction
This article is intended for the attention of system administrators who prepare standard workstations on computers running OS Windows 10, including for software developers.
It should be noted that there is a specific issue related to the inability to integrate software obtained from the Microsoft Store for use in a custom image. Windows 10Without going into details, I will clarify that this problem is related to the fact that programs installed from the Microsoft Store are associated with the Administrator service account, and when the utility completes creating a custom image sysprep errors occur due to this circumstance.
The method discussed in this article allows you to avoid this problem when preparing an OS image. Windows 10 with a pre-configured WSL2 subsystem, as well as a pre-prepared and configured OS image Ubuntu 20.04 with the KDE Plasma GUI, which in turn can have its own set of user software.
There are a large number of examples and guides on the Internet for setting up WSL subsystems (i.e. WSL1 and the relatively new WSL2), with GUI interface settings for Linux systems based on OS starting from version Ubuntu 16.04 and ending Ubuntu 20.04, but this mostly concerned desktops based on the so-called "lightweight" xfce4, which has understandable limitations in user settings. But as for the KDE Plasma GUI for Ubuntu As of April 20.04, no significant information was found online. However, this particular version provides the end user with a virtually unlimited set of customization options for both the system's appearance and hardware settings, taking into account the current Linux system integration capabilities implemented in the WSL2 subsystem.
Installing the required set of software and configuring WSL2
Checking the current version Windows, for this in the search bar Windows enter the command winver and we get something like this:
It's important that your OS version is 1903 or 1909 (these OS versions must have cumulative update KB4566116 installed), or 2004 (build number at least 19041). Otherwise, it's not important. If the version number is lower, we recommend upgrading to the latest version to ensure the results described in this article are replicated correctly. Windows.
For convenience of further actions, we install a free one Windows Terminal, using the Microsoft Store (it is also possible to download from other sources):
We install X Server X410 through the same Microsoft Store, this software is paid, but there is a free period of 15 days, which is enough for various tests.
As a free alternative to X410 and install the VcXsrv X server.
In any convenient place on the disk, we create a directory in which we will store our files. As an example, let's create a directory C:wsl.
and install the standalone installer Ubuntu April 20.04, unzip the resulting file using an archiver (e.g. 7-zip). Rename the unpacked directory with a long name. Ubuntu_2004.2020.424.0_x64 into something more acceptable, like Ubuntu-20.04 and copy it to directory C:wsl (hereinafter simply wsl).
and unpack into a directory wsl cross-platform sound server PulseAudio v.1.1., we also make corrections to its configuration files.
In file wslpulseaudio-1.1etcpulsedefault.pa In chapter Load audio drivers statically edit the line:
load-module module-waveout sink_name=output source_name=input record=0
and in the section Network access edit the line:
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1
In file wslpulseaudio-1.1etcpulsedaemon.conf uncomment and change the line
exit-idle-time = -1
We configure the WSL2 subsystem in accordance with Microsoft. The only caveat is the distribution. Ubuntu We've already downloaded it, and we'll install it in the next step. Basically, the setup comes down to enabling additional components of the "Subsystem" Windows for Linux" and "Virtual Machine Platform", and then reboot to apply the changes to the computer settings:
If necessary, and install the kernel update package Linux in WSL2.
Run Windows Terminal and select the Command Prompt operating mode by pressing keys Ctrl+Shift+2.
First of all, we set the WSL2 mode of operation, for this we enter the command:
wsl --set-default-version 2
Go to the directory with the standalone bootloader Ubuntu 20.04, in my case it is wslUbuntu-20.04 and run the file ubuntu2004.exe. When prompted for a username, enter the username engineer (you can enter any other name), enter your password and confirm the entered password for the specified account:
The terminal prompt appeared, the kernel Ubuntu 20.04 is installed. Let's check that the WSL2 mode is configured correctly. To do this, Windows Terminal, select the bookmark Windows PowerShell and enter the command:
wsl -l -v
the result of execution should be like this:
We configure the Microsoft Defender firewall, i.e. disable it for the public network:
Setting Ubuntu 20.04
Π Windows In Terminal, select the Command Prompt tab again and install updates for Ubuntu 20.04. To do this, enter the following in the command line:
sudo apt update && sudo apt upgrade βy
Install the KDE Plasma desktop:
sudo apt install kubuntu-desktop -y
installation takes up to 30 minutes, depending on the performance of the computer and the bandwidth of the Internet access channel, when prompted by the installer, we confirm OK.
Installing Russian localization and dictionaries Ubuntu 20.04. To do this, enter the following in the command line:
sudo apt install language-pack-ru language-pack-kde-ru -y
sudo apt install libreoffice-l10n-ru libreoffice-help-ru -y
sudo apt install hunspell-ru mueller7-dict -y
sudo update-locale LANG=ru_RU.UTF-8
sudo dpkg-reconfigure locales # ΠΏΡΠΈΠΌΠ΅ΡΠ°Π½ΠΈΠ΅: Π²ΡΠ±ΠΈΡΠ°Π΅ΠΌ ru_RU.UTF-8 UTF-8, ΡΠΌ. ΡΠΊΡΠΈΠ½ΡΠΎΡΡ Π½ΠΈΠΆΠ΅.
sudo apt-get install --reinstall locales
Add the latest version of the KDE Plasma desktop:
sudo add-apt-repository ppa:kubuntu-ppa/backports
sudo apt update && sudo apt full-upgrade -y
We add our own set of console applications, for example mc ΠΈ neofetch:
sudo apt install mc neofetch -y
We check what happened, enter into the command line neofetch, see screenshot:
Editing the WSL config file /etc/wsl.conf:
sudo nano /etc/wsl.conf
copy the text into the empty text editor window that opens:
[automount]
enabled = true
root = /mnt
options = Β«metadata,umask=22,fmask=11Β»
mountFsTab = true
[network]
generateHosts = true
generateResolvConf = true
[interop]
enabled = true
appendWindowsPath = true
save changes (Ctrl+O), confirm the operation and exit the text editor (Ctrl+X).
Exporting the configured image Ubuntu-20.04 in the catalog we created wsl. For this purpose, Windows Terminal again select the bookmark Windows PowerShell and enter the command:
wsl --export Ubuntu-20.04 c:wslUbuntu-plasma-desktop
The created image will help us automate the operations of launching/reinstalling the configured Ubuntu 20.04, if necessary, will allow you to easily transfer it to another computer.
Preparing bat files and desktop shortcuts Windows
Using the Notepad ++ editor, create bat files (required in OEM-866 encoding for the correct output of Cyrillic characters):
File Install-Ubuntu-20.04-plasma-desktop.bat β designed to automate the initial installation of the created image Ubuntu 20.04 on a computer with a pre-configured WSL2 subsystem and X server. If the username and password differ from those specified in the example, you will need to make the appropriate changes to this .bat file:
@echo off
wsl --set-default-version 2
cls
echo ΠΠΆΠΈΠ΄Π°ΠΉΡΠ΅ ΠΎΠΊΠΎΠ½ΡΠ°Π½ΠΈΡ ΡΡΡΠ°Π½ΠΎΠ²ΠΊΠΈ Π΄ΠΈΡΡΡΠΈΠ±ΡΡΠΈΠ²Π° Ubuntu-20.04...
wsl --import Ubuntu-20.04 c:wsl c:wslUbuntu-plasma-desktop
wsl -s Ubuntu-20.04
cls
echo ΠΠΈΡΡΡΠΈΠ±ΡΡΠΈΠ² Ubuntu-20.04 ΡΡΠΏΠ΅ΡΠ½ΠΎ ΡΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½!
echo ΠΠ΅ Π·Π°Π±ΡΠ΄ΡΡΠ΅ ΡΠΌΠ΅Π½ΠΈΡΡ ΡΡΠ΅ΡΠ½ΡΡ Π·Π°ΠΏΠΈΡΡ ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ Β«rootΒ» Π½Π° ΡΡΡΠ΅ΡΡΠ²ΡΡΡΡΡ ΡΡΠ΅ΡΠ½ΡΡ Π·Π°ΠΏΠΈΡΡ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ,
echo Π»ΠΈΠ±ΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠΉΡΠ΅ ΠΏΡΠ΅Π΄ΡΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½Π½ΡΡ ΡΡΠ΅ΡΠ½ΡΡ Π·Π°ΠΏΠΈΡΡ Β«engineerΒ», ΠΏΠ°ΡΠΎΠ»Ρ: Β«passwordΒ».
pause
File Reinstall-Ubuntu-20.04-plasma-desktop.bat β designed to reinstall a prepared image Ubuntu 20.04 on the computer.
@echo off
wsl --unregister Ubuntu-20.04
wsl --set-default-version 2
cls
echo ΠΠΆΠΈΠ΄Π°ΠΉΡΠ΅ ΠΎΠΊΠΎΠ½ΡΠ°Π½ΠΈΡ ΠΏΠ΅ΡΠ΅ΡΡΡΠ°Π½ΠΎΠ²ΠΊΠΈ Π΄ΠΈΡΡΡΠΈΠ±ΡΡΠΈΠ²Π° Ubuntu-20.04...
wsl --import Ubuntu-20.04 c:wsl c:wslUbuntu-plasma-desktop
wsl -s Ubuntu-20.04
cls
echo ΠΠΈΡΡΡΠΈΠ±ΡΡΠΈΠ² Ubuntu-20.04 ΡΡΠΏΠ΅ΡΠ½ΠΎ ΠΏΠ΅ΡΠ΅ΡΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½!
pause
File Set-default-user.bat - to set the default user.
@echo off
set /p answer=ΠΠ²Π΅Π΄ΠΈΡΠ΅ ΡΡΡΠ΅ΡΡΠ²ΡΡΡΡΡ ΡΡΠ΅ΡΠ½ΡΡ Π·Π°ΠΏΠΈΡΡ Π² Ubuntu (engineer):
c:wslUbuntu-20.04ubuntu2004.exe config --default-user %answer%
cls
echo Π£ΡΠ΅ΡΠ½Π°Ρ Π·Π°ΠΏΠΈΡΡ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ %answer% Π² Ubuntu-20.04 ΡΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½Π° ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ!
pause
File Start-Ubuntu-20.04-plasma-desktop.bat - the actual launch of the KDE Plasma desktop.
@echo off
echo ===================================== ΠΠ½ΠΈΠΌΠ°Π½ΠΈΠ΅! ============================================
echo ΠΠ»Ρ ΠΊΠΎΡΡΠ΅ΠΊΡΠ½ΠΎΠΉ ΡΠ°Π±ΠΎΡΡ GUI Ubuntu 20.04 Π² WSL2 Π½Π΅ΠΎΠ±Ρ
ΠΎΠ΄ΠΈΠΌΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ X Server.
echo ΠΡΠΈΠΌΠ΅ΡΠ°Π½ΠΈΠ΅: Π² ΡΠ»ΡΡΠ°Π΅ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΡ VcXsrv Windows X Server Π½Π΅ΠΎΠ±Ρ
ΠΎΠ΄ΠΈΠΌΠΎ ΡΠ°ΡΠΊΠΎΠΌΠΌΠ΅Π½ΡΠΈΡΠΎΠ²Π°ΡΡ
echo ΡΡΡΠΎΠΊΠΈ Π² ΡΠ°ΠΉΠ»Π΅ Start-Ubuntu-20.04-plasma-desktop.bat, ΡΠΎΠ΄Π΅ΡΠΆΠ°ΡΠΈΠ΅ "config.xlaunch" ΠΈ
echo "vcxsrv.exe", ΠΈ Π·Π°ΠΊΠΎΠΌΠΌΠ΅Π½ΡΠΈΡΠΎΠ²Π°ΡΡ Π²ΡΠ΅ ΡΡΡΠΎΠΊΠΈ, ΡΠΎΠ΄Π΅ΡΠΆΠ°ΡΠΈΠ΅ "x410".
echo ============================================================================================
rem start "" /B "c:wslvcxsrvconfig.xlaunch" > nul
start "" /B x410.exe /wm /public > nul
start "" /B "c:wslpulseaudio-1.1binpulseaudio.exe" --use-pid-file=false -D > nul
c:wslUbuntu-20.04Ubuntu2004.exe run "if [ -z "$(pidof plasmashell)" ]; then cd ~ ; export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0 ; setxkbmap us,ru -option grp:ctrl_shift_toggle ; export LIBGL_ALWAYS_INDIRECT=1 ; export PULSE_SERVER=tcp:$(grep nameserver /etc/resolv.conf | awk '{print $2}') ; sudo /etc/init.d/dbus start &> /dev/null ; sudo service ssh start ; sudo service xrdp start ; plasmashell ; pkill '(gpg|ssh)-agent' ; fi;"
rem taskkill.exe /F /T /IM vcxsrv.exe > nul
taskkill.exe /F /T /IM x410.exe > nul
taskkill.exe /F /IM pulseaudio.exe > nul
File Start-Ubuntu-20.04-terminal.bat - launching a graphical terminal without the KDE Plasma desktop.
@echo off
echo ===================================== ΠΠ½ΠΈΠΌΠ°Π½ΠΈΠ΅! ============================================
echo ΠΠ»Ρ ΠΊΠΎΡΡΠ΅ΠΊΡΠ½ΠΎΠΉ ΡΠ°Π±ΠΎΡΡ GUI Ubuntu 20.04 Π² WSL2 Π½Π΅ΠΎΠ±Ρ
ΠΎΠ΄ΠΈΠΌΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ X Server.
echo ΠΡΠΈΠΌΠ΅ΡΠ°Π½ΠΈΠ΅: Π² ΡΠ»ΡΡΠ°Π΅ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΡ VcXsrv Windows X Server Π½Π΅ΠΎΠ±Ρ
ΠΎΠ΄ΠΈΠΌΠΎ ΡΠ°ΡΠΊΠΎΠΌΠΌΠ΅Π½ΡΠΈΡΠΎΠ²Π°ΡΡ
echo ΡΡΡΠΎΠΊΠΈ Π² ΡΠ°ΠΉΠ»Π΅ Start-Ubuntu-20.04-plasma-desktop.bat, ΡΠΎΠ΄Π΅ΡΠΆΠ°ΡΠΈΠ΅ "config.xlaunch" ΠΈ
echo "vcxsrv.exe", ΠΈ Π·Π°ΠΊΠΎΠΌΠΌΠ΅Π½ΡΠΈΡΠΎΠ²Π°ΡΡ Π²ΡΠ΅ ΡΡΡΠΎΠΊΠΈ, ΡΠΎΠ΄Π΅ΡΠΆΠ°ΡΠΈΠ΅ "x410".
echo ============================================================================================
rem start "" /B "c:wslvcxsrvconfig.xlaunch" > nul
start "" /B x410.exe /wm /public > nul
start "" /B "c:wslpulseaudio-1.1binpulseaudio.exe" --use-pid-file=false -D > nul
c:wslUbuntu-20.04Ubuntu2004.exe run "cd ~ ; export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0 ; export LIBGL_ALWAYS_INDIRECT=1 ; setxkbmap us,ru -option grp:ctrl_shift_toggle ; export PULSE_SERVER=tcp:$(grep nameserver /etc/resolv.conf | awk '{print $2}') ; sudo /etc/init.d/dbus start &> /dev/null ; sudo service ssh start ; sudo service xrdp start ; konsole ; pkill '(gpg|ssh)-agent' ;"
taskkill.exe /F /T /IM x410.exe > nul
rem taskkill.exe /F /T /IM vcxsrv.exe > nul
taskkill.exe /F /IM pulseaudio.exe > nul
Also for ease of use in the catalog wsl we prepare shortcuts pointing to the corresponding bat-files. Then the contents of the directory wsl is as follows:
Launching the KDE Plasma Desktop
We check that all the preparatory steps have been completed, we try to launch the shortcut Plasma-desktop. A password request appears, enter the password for the account and ... the window closes. It's okay the first time. We try again - and we see the familiar KDE Plasma taskbar. We customize the appearance of the taskbar, in the example, for ease of use, the panel is moved to the right side of the screen and centered. We check the localization settings, if necessary, add the Russian language:
If necessary, we bring shortcuts for installed linux applications to the KDE Plasma taskbar.
If there's no Ubuntu 20.04 requires you to log out of your user account to apply changes to the settings, or you need to reboot the OS, for this in Windows In Terminal, enter the command:
wsl -d Ubuntu20.04 --shutdown
With a shortcut Plasma-desktop or Konsole you can run the KDE Plasma GUI Ubuntu 20.04. For example, we will install using Konsole GIMP graphics editor:
After installation is complete, run from Konsole GIMP graphics editor:
GIMP works, which is what I wanted to check.
And here is how various linux applications work in KDE Plasma in WSL2:
the customized KDE Plasma taskbar is on the right side of the screen. and the video in the Firefox window plays with sound.
If necessary, you can configure access to Ubuntu20.04 p.m. SSH ΠΈ RDP, for this you need to install the appropriate services with the command:
sudo apt install ssh xrdp -y
note: to enable password access by SSH you need to edit the file /etc/ssh/sshd_config, namely the parameter PasswordAuthentication no must be set to PasswordAuthentication yes, save changes and reboot Ubuntu20.04.
At every startup UbuntuOn April 20.04, the internal IP address changes. Before setting up remote access, you need to check the current IP address using the command ip a:
Accordingly, this ip-address must be entered in the session settings SSH ΠΈ RDP before starting.
This is what remote access looks like SSH using MobaXterm:
And this is what remote access looks like RDP:
Using x server vcxsrv instead of x410
Launching and setting up vcxsrv, carefully set the appropriate checkboxes:




Saving the configured configuration in the directory wslvcxsrv with standard name config.xlaunch.
Editing bat files Start-Ubuntu-20.04-plasma-desktop.bat ΠΈ Start-Ubuntu-20.04-terminal.bat according to their instructions.
Launching the shortcut Plasma-desktop, and this is what we get:
The KDE Plasma desktop completely covers the desktop WindowsTo switch between Linux and Windows application windows, we use a well-known key combination Alt+Tab, which is not very convenient.
In addition, an unpleasant feature of the X server was revealed vcxsrv - it crashes when launching some applications, in particular the same GIMP or LibreOffice Writer. Perhaps we should wait until the developers remove the noticed "bugs", but this is not certain ... So, to get acceptable results, it is better to use the X Server Microsoft x410.
Conclusion
Still, we must pay tribute to Microsoft, the WSL2 product turned out to be quite working, and in my inexperienced opinion, very successful. And as far as I know, the developers continue to intensively "finish" it, and perhaps - in a year or two, this subsystem will appear in all its functional completeness.
Source: habr.com
