Introduction
This article is intended for the attention of system administrators who prepare typical workplaces on computers running Windows 10, including software developers.
It should be noted that there is a certain problem associated with the impossibility of integrating software obtained from the Microsoft Store online store for use in a custom Windows 10 image. Without going into details, I will clarify that this problem is related to the fact that programs installed from the Microsoft Store communicate with the Administrator service account, and when the custom image creation is completed by the utility sysprep
errors occur due to this circumstance.
The method discussed in this article avoids this problem when preparing a Windows 10 OS image with a pre-configured WSL2 subsystem, as well as a pre-prepared and configured Ubuntu 20.04 OS image with a KDE Plasma GUI, which in turn can have its own set of custom software.
There are a lot of examples and tutorials on the Internet for setting up WSL subsystems (i.e. WSL1 and the relatively new WSL2), with setting up a GUI interface for linux based OS systems from Ubuntu 16.04 to Ubuntu 20.04, but this mainly concerned desktops based on the so-called. "lightweight" xfce4, which has understandable limitations in user settings. But as far as the KDE Plasma GUI for Ubuntu 20.04 is concerned, there isn't much information found on the net. But it is this option that provides the end user with an almost unlimited set of settings for both the appearance of the system and hardware settings, of course, taking into account the current integration capabilities of linux systems implemented in the WSL2 subsystem.
Installing the required set of software and configuring WSL2
We check the current version of Windows, for this, in the Windows search bar, enter the command winver
and we get something like this:
It is important that the OS version is 1903 or 1909 (specified OS versions must be with the cumulative update KB4566116 installed), or 2004 (build number no less than 19041), the rest of the information does not matter. If the version number is less, it is recommended that you upgrade to the latest version of Windows to correctly reproduce the results in this article.
For the convenience of further actions, install the free Windows Terminal using the Microsoft Store (there is also the possibility of downloading 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
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
.
Ubuntu_2004.2020.424.0_x64
into something more acceptable, like Ubuntu-20.04
and copy it to directory C:wsl
(hereinafter simply wsl
).
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
If necessary,
We launch Windows Terminal and select the Command Prompt mode by pressing the 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
Change to the Ubuntu 20.04 standalone bootloader directory, in my case this 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:
A terminal prompt appears, the Ubuntu 20.04 kernel is installed. Let's check the correctness of the WSL2 mode settings, for this, in the Windows Terminal, select the Windows PowerShell tab 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 up Ubuntu 20.04
In the Windows Terminal, select the Command Prompt tab again and install updates for Ubuntu 20.04. To do this, on the command line, enter:
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
.
Install Russian localization and dictionaries Ubuntu 20.04. To do this, on the command line, enter:
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 customized Ubuntu-20.04 image to the directory we created wsl
. To do this, in the Windows Terminal, again select the Windows PowerShell tab 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, it will allow us to easily transfer it to another computer.
Preparing bat files and shortcuts to the Windows desktop
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 of Ubuntu 20.04 on a computer with an already configured WSL2 subsystem and an X server. If the username and password differ from those specified in the example, then you 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 the prepared image of 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
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 Ubuntu 20.04 requires you to log out of your user account in order to apply changes to the settings, or you need to restart the OS, to do this, in Windows Terminal, enter the command:
wsl -d Ubuntu20.04 --shutdown
With a shortcut Plasma-desktop
or Konsole
you can run the KDE Plasma Ubuntu 20.04 GUI. For example, install with 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 by 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.
Each time you start Ubuntu20.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 closes the Windows desktop, to switch between windows of linux and windows applications we use the 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