wsl2启动桌面_「原创」windows10下自定义WSL安装路径及启动WSL2

win10是目前在win系列的个人操作系统中,个人觉得是最好用的,没有之一。现在又能拥有WSL2的功能,让ubuntu与win10无缝的结合。简直就是完美的不能再完美了。享受着win10的强大桌面系统及完善的周边应用软件外,又能拥有ubuntu系统环境,完美的让不同环境的应用与服务,整合在同一个桌面下,各自互不干涉的运行着。相信这是每个喜欢ubuntu又舍弃不掉win的朋友们一大福音。

84913f2b9ceb959b176498a903ed9faa.png

由于C盘(系统盘)的资源一般都是很紧张,所以,需要将WSL安装在其他的目录下。

一、安装LxRunOffline。

下载链接:https://github.com/DDoSolitary/LxRunOffline/releases

下载完解压后,将里面的文件直接复制到C:windowssystem32下,省去配置环境的麻烦 。

在Windows PowerShell下,执行LxRunOffline,得到下面的结果,说明已正确安装。

PS C:WINDOWSsystem32> LxRunOffline[ERROR] No action is specified.Supported actions are:   l, list            List all installed distributions.   gd, get-default    Get the default distribution, which is used by bash.exe.   sd, set-default    Set the default distribution, which is used by bash.exe.   i, install         Install a new distribution.   ui, uninstall      Uninstall a distribution.   rg, register       Register an existing installation directory.   ur, unregister     Unregister a distribution but not delete the installation directory.   m, move            Move a distribution to a new directory.   d, duplicate       Duplicate an existing distribution in a new directory.   e, export          Export a distribution's filesystem to a .tar.gz file, which can be imported by the "install" command.   r, run             Run a command in a distribution.   di, get-dir        Get the installation directory of a distribution.   gv, get-version    Get the filesystem version of a distribution.   ge, get-env        Get the default environment variables of a distribution.   se, set-env        Set the default environment variables of a distribution.   ae, add-env        Add to the default environment variables of a distribution.   re, remove-env     Remove from the default environment variables of a distribution.   gu, get-uid        Get the UID of the default user of a distribution.   su, set-uid        Set the UID of the default user of a distribution.   gk, get-kernelcmd  Get the default kernel command line of a distribution.   sk, set-kernelcmd  Set the default kernel command line of a distribution.   gf, get-flags      Get some flags of a distribution. See https://docs.microsoft.com/en-us/previous-versions/windows/desktop/api/wslapi/ne-wslapi-wsl_distribution_flags for details.   sf, set-flags      Set some flags of a distribution. See https://docs.microsoft.com/en-us/previous-versions/windows/desktop/api/wslapi/ne-wslapi-wsl_distribution_flags for details.   s, shortcut        Create a shortcut to launch a distribution.   ec, export-config  Export configuration of a distribution to an XML file.   ic, import-config  Import configuration of a distribution from an XML file.   sm, summary        Get general information of a distribution.   version            Get version information about this LxRunOffline.exe.
51ca9b3fcbc9af3a90a7239bf3a0b7f1.png

二、启用虚拟机及Linux子系统功能

以管理员身份,打开Windows PowerShell,执行下面的语句。

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestartdism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestartEnable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatformEnable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
aab047a780d45811cd2a8b65a9e5504e.png
24f7f8780f33165a3c545946f7c2adcb.png

按要求,执行完后,会提示你重启计算机,按“Y”允许重启。

重启后,我们可以在这里面确认是否安装成功。当然了,也可以直接使用手工的方式,点击这个地方进行安装。

9c591dd85403bf7c0d1e5af41fa9d7de.png

三、安装Ubuntu18.04。

由于是需要安装到其他目录,而非系统默认自带的,所以,需要先下载一下Ubuntu18.04。

下载地址:https://docs.microsoft.com/en-us/windows/wsl/install-manual

系统及版本,自己看着选择。喜欢就好。

Ubuntu 18.04Ubuntu 18.04 ARMUbuntu 16.04Debian GNU/LinuxKali LinuxOpenSUSE Leap 42SUSE Linux Enterprise Server 12Fedora Remix for WSL
c1957c3f0d549e2a12901432da6de4fb.png

下载下来后,是一个Appx后缀的文件,我们直接把Appx改为zip,然后再解压。

解压后,得到的结果如下:

1a5cd471fd49ca03dd3af6f2660b7114.png

install.tar.gz这个文件就是我们等下要用到的。目录要记住一下。

以管理员的身份,打开Windows PowerShell

格式:

LxRunOffline i -n  -d  -f 

对照这个,森哥我这里的安装名称是:ubuntu-18.04,安装路径是在:D:甥畢瑮u,刚刚提到的那个安装文件,是在E:甥畢瑮u里面。

LxRunOffline i -n ubuntu-18.04 -d D:甥畢瑮u  -f E:甥畢瑮uinstall.tar.gz
49eed84c0e46c0cf7bc632ca8261d2a1.png
a21c2e88d2bc3b59cdd6f36263b9e7e9.png

启动ubuntu系统

wsl

若忘记安装名称,使用下面命令查询

LxRunOffline list

查看版本号

在运行中,输入bash,即可打开。

查询版本号看是否安装我们所需要的。

root@zerolife:~# cat /etc/issueUbuntu 18.04.1 LTS  lxxxxxxxxxx root@zerolife:~# cat /etc/issueUbuntu 18.04.1 LTS  lcat /etc/issue
727d6ffc19596a902c38de03bb8a9825.png

四、卸载WSL中的系统。

wslconfig /l# 从列表中选择要卸载的发行版(例如Ubuntu)并键入命令wslconfig /u Ubuntu

五、启用WSL2

查看现在的wsl状态。

PS C:WINDOWSsystem32> wsl -l -v NAME            STATE           VERSION* ubuntu-18.04    Running         1

转换为wsl2

wsl --set-version ubuntu-18.04 2
89dbc5af77763aef780a0adaa18e83d3.png

检查一下。

刚转换完,系统是处理注销关机。所以,我们需要再运行一下wsl,就恢复了。

PS C:WINDOWSsystem32> wsl -l -v NAME            STATE           VERSION* ubuntu-18.04    Stopped         2PS C:WINDOWSsystem32> wslroot@zerolife:/mnt/c/WINDOWS/system32# exitlogoutPS C:WINDOWSsystem32> wsl -l -v NAME            STATE           VERSION* ubuntu-18.04    Running         2
29e982c8d26ad3f6161ec309c6a60b90.png

好了。终于可以使用了。

完美

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值