Wsl2: Windows native Linux subsystem

Song Baohua 2021-09-15 09:48:49
wsl2 wsl windows native linux



In the last article , We mainly talked about : stay Windows In the system , install WSL Subsystem .

In this paper :WSL: stay Windows Development in the system Linux Another artifact of the program

however WSL It just looks like Linux nothing more , Although in this subsystem , We can execute Linux Program , But at the bottom ,WSL The call is still win32 API.

in other words :WSL Just an adaptation layer .

later , Microsoft finally released WSL2 This real Linux Subsystem , This is a real Linux Full kernel , With traditional virtual machines VitualBoxVMWare equally , But it has better interoperability with the host .

For completeness , Let's continue to finish the process .

Problems encountered in this process 、 Required installation software and other resources , Has been uploaded to the network disk , There is a download address at the end of the text .

install WSL2 The premise of

Before we start , Let's take a look at the current computer WSL Version of .

stay Windows Command line window , Input instruction : wsl --list --verbose( Or enter a simplified version : wsl -l -v), Get the results :

You can see what we installed in our last article Ubuntu-18.04, and WSL The version is 1.

If you want to upgrade to WSL2,Windows The kernel version of the operating system must meet certain requirements , as follows :

We will follow the official requirements , Check if your computer meets your needs : choice Windows Winkey Win + R, Then type. winver, choice “ determine ”.

It seems that my system can meet the requirements , Then go on to the next step !

If your kernel version does not meet this requirement , Can search for keywords “WIN10 Get internal preview version ”, You can find a solution .

install WSL2

Continue to start as Administrator PowerShell, Then execute the command :

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

here , It's time to restart the computer again !

After reboot , Continue to PowserShell in , hold Ubuntu-18.04 Set to WSL2 edition .

The command entered is :

wsl --set-version Ubuntu-18.04 2

This step may encounter such problems :

resolvent : Download from Microsoft's official website WSL2 Linux Kernel upgrade package , Download address is :

WSL2 Linux Kernel upgrade package

You can also download it from the network disk at the end of the text

After downloading , All the way Next Can be installed .

here , stay PowerShell Re execute in wsl --set-version Ubuntu-18.04 2 Instructions ( Need to wait for a while , Probably 1 About minutes ):

meanwhile , hold WSL The default version of is changed to 2wsl --set-default version 2.

here , Let's execute the instructions wsl -l -v Let's have a look at , It becomes WSL2 Version of the :

Now? , Restart Ubuntu-18.04 System , Although it is still a dark window , But it's a complete 、 Pure Linux operating system !

Install desktop environment

The operation of this part , Reference resources :https://autoize.com/xfce4-desktop-environment-and-x-server-for-ubuntu-on-wsl-2/.

About Linux Desktop environment for , It is associated with Windows There are some differences in the concept of desktop environment .

stay Linux In the system , The desktop environment is a stand-alone application , Not part of the operating system .

In other words , Even without a desktop environment , You can also have a good time Linux System , Such as those servers and other devices .

Linux The desktop in consists of client and server , They communicate through a protocol , Be commonly called :X11.

Server side : Responsible for graphic display ;

client : According to the system settings DISPLAY environment variable , Send the request to display graphics to the server ;

therefore , To make our Ubuntu Display the graphical interface , We need to install a server software and client software .

Be careful : The server software here is installed in Windows In the system , The client is installed in Ubuntu-18.04 In the system .

Install client

stay Ubuntu-18.04 In the terminal window , Execute the following instructions to install the client software xfce4

sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install xfce4

To configure DISPLAY environment variable

because Ubuntu Client in xfce4 You need to send the display request , Send to... Over the network Windows The server on , So we need to know Windows Systematic IP Address , stay Windows View... In the command line window in the system :ipconfig

And then in Ubuntu-18.04 Middle handle this IP Address , Configure... In the home directory .bashrc In file :

$ cd
$ vi .bashrc

Add at the end of the file :

export DISPLAY=192.168.192.1:0

preservation 、 After closing the file , perform :source ~/.bashrc Update can .

Install server

The graphical interface has VcXsrv and Xming Two software , We choose the front VcXsrv.

alike , I have already put vcxsrv-64.1.20.9.0.installer.exe Put it in the net disk , Download all the way Next install .

After installation , start-up Windows On the table XLaunch Program :

then , Follow the configuration in the reference document , as follows :

In the last step , You can save the configuration information on the desktop .

Start client

stay Ubuntu-18.04 Command line window in the system , Execution instruction :startxfce4

At the moment , The artifact happened : Yours Windows Does the system jump out of the following window :

You can open it on the desktop File System, Did you see many familiar figures ?

In the open mnt Catalog , Did you see Windows Drive letter in the system ?

however , Chinese information is displayed in garbled code ! Then let's install the Chinese language support package .

Chinese support

stay Ubuntu-18.04 System command line window , Set up locale:

here , Windows in our desktop environment can be used , As shown in the figure below :

sudo vi /etc/locale.gen

Copy the blue line in the figure below , Then remove the front # and Space , Then save 、 sign out .

Then execute instructions in the terminal :sudo locale-gen

The user name in the upper right corner of the stand-alone , choice 【Log Out..】

here ,Ubuntu The virtual machine WSL Window xfce4 The client will exit , Re execution startxfce4 Start client :

Again , In the terminal window on the desktop , hold locale Change to Chinese :

sudo vi /etc/default/locale

hold LANG=C.UTF-8 Change it to LANG=zh_CN.UTF-8

then , Install the following Chinese language packs into it :

sudo apt install language-pack-zh-hans
sudo apt install language-pack-gnome-zh-hans
sudo apt install language-pack-kde-zh-hans

At the moment , Look at those random codes just now , Have you displayed Chinese correctly ?


------ End ------

Next , You can also install various IDE, Explore how they share files ...

The software to be installed in this article , It has been uploaded to the network disk .

Please reply in official account. 721( It's not a message area ), You can receive the download address , thank you !

Recommended reading

【1】C Language pointer - From basic principles to fancy techniques , With graphics and code to help you explain thoroughly
【2】 Step by step analysis - How to use C Implement object-oriented programming
【3】 original gdb The underlying debugging principle is so simple
【4】 Is inline compilation terrible ? After reading this article , End it !

Other series : Selected articles C Language Linux operating system Application design The Internet of things


Official account of star standard , You can find me faster !

版权声明
本文为[Song Baohua]所创,转载请带上原文链接,感谢
https://javamana.com/2021/09/20210909145259963E.html

  1. The first starcoin & move hacksong source code analysis - P (a)
  2. Zhaijia 36 days Salt Fish turn into Tencent, Zookeeper Consistency level analysis,
  3. Traitement de l'interception des champs de demande communs de Spring Cloud, plus de 500 personnes interviewent Ali,
  4. About JavaScript modules
  5. Object oriented programming (2)
  6. Java日期时间API系列42-----一种高效的中文日期格式化和解析方法
  7. Java日期時間API系列42-----一種高效的中文日期格式化和解析方法
  8. 宅家36天鹹魚翻身入職騰訊,Zookeeper一致性級別分析,
  9. Java Date Time API Series 42 - - a efficient Chinese Date Format and Analysis Method
  10. 已成功拿下字节、腾讯、脉脉offer,7年老Java一次操蛋的面试经历,
  11. 小米Java社招面试,每次面试必问的二叉树的设计与编码,
  12. 小米Java校招面试,阿里、百度、美团、携程、蚂蚁面经分享,
  13. 小米Java校招面試,阿裏、百度、美團、攜程、螞蟻面經分享,
  14. Xiaomi Java School Recruitment interview, Ali, baidu, meituan, ctrip, ant Facebook Sharing,
  15. La conception et le codage de l'arbre binaire requis pour chaque entrevue d'embauche de la société Java millet;
  16. A remporté avec succès Byte, Tencent, Pulse offer, 7 ans Java une expérience d'entrevue de baise,
  17. 干货来袭,Java岗面试12家大厂成功跳槽,
  18. 常用Java框架面试题目,现在做Java开发有前途吗?
  19. 常用Java框架面試題目,現在做Java開發有前途嗎?
  20. Les questions d'entrevue couramment utilisées pour le cadre Java sont - elles prometteuses pour le développement Java?
  21. L'arrivée de marchandises sèches, l'entretien d'emploi Java 12 grandes usines ont réussi à changer d'emploi,
  22. Multiple postures for handling container time in k8s environment
  23. Echarts remove left Gap, Blank
  24. Hotspot Weekly | zoom $100 million, docker fees, $38 billion Data bricks
  25. JsonMappingException: No serializer found for class org.apache.ibatis.executor.loader.javassist.JavassistProxyFactory...
  26. Java. Security. Securerandom source code analysis Java. Security. EGD = file: / dev /. / urandom
  27. When using IntelliJ idea, jump directly and quickly from the mapper interface to mapper.xml
  28. When idea writes SQL in mybatis XML, the solution to the problems of table name, field and red reporting
  29. Spring cloud integrates Nacos
  30. 应届毕业生Java笔试题目,2021大厂Java社招最全面试题,
  31. Liver explosion! Take you to understand Hadoop serialization
  32. linux系列之:告诉他,他根本不懂kill
  33. java版gRPC实战之三:服务端流
  34. RabbitMQ核心知识总结!
  35. linux系列之:告诉他,他根本不懂kill
  36. java版gRPC实战之三:服务端流
  37. RabbitMQ核心知识总结!
  38. 10天拿到字节跳动Java岗位offer,学习Java开发的步骤
  39. 10天拿到字节跳动Java岗位offer,Java知识点思维导图
  40. Résumé des connaissances de base de rabbitmq!
  41. 10天拿到字節跳動Java崗比特offer,Java知識點思維導圖
  42. 10 jours pour obtenir un Byte Jump Java post offer, Java Knowledge point Mind Map
  43. 10 jours pour obtenir l'octet Jump Java post offer, apprendre les étapes du développement Java
  44. Java version of gppc Reality Three: server side stream
  45. Linux Series: Dites - lui qu'il ne connaît pas kill du tout
  46. "Data structure and algorithm" of front end -- binary search
  47. 2020-2021京东Java面试真题解析,如何才能通过一线互联网公司面试
  48. 13 SpringBoot整合RocketMQ实现过滤消息-根据SQL表达式过滤消息
  49. 12 SpringBoot整合RocketMQ实现过滤消息-根据TAG方式过滤消息
  50. 11 SpringBoot整合RocketMQ实现事务消息
  51. 11 springboot Consolidated rocketmq Implementation transaction message
  52. 12 springboot Consolidated rocketmq Implements Filtering messages - Filtering messages according to tag method
  53. 13 springboot Consolidated rocketmq Implementation Filtering messages - Filtering messages according to SQL expressions
  54. linux系列之:告诉他,他根本不懂kill
  55. (1)java Spring Cloud+Spring boot企业快速开发架构之微服务是什么?它的优缺点有哪些?
  56. Oracle 检查 DATE 列 RANGE 分区表已有分区的最大日期时间
  57. ConcurrentHashMap--原理
  58. 2020 - 2021 JD Java interview Real question Analysis, How can interview through First - Line Internet Company
  59. Concurrenthashmap - - Principes
  60. Oracle vérifie l'heure de date maximale d'une partition existante dans la colonne date