安装Windows子系统到指定位置

在Mircosoft Store里直接安装安装Linux子系统虽然方便,但是安装后的子系统却是共用C盘的,如果子系统需要较大空间,而系统盘较小,则无法满足需求

  • 前提:Windows子系统功能已开启

    • 开启方法:

      • 第一种:在控制面板-程序-启用与关闭Windows功能中,勾选“适用于Linux的Windows子系统”

      • 第二种:直接在PowerShell(管理员身份)中执行命令:

        Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
        

        显示如下信息则表示成功:

        Path          :
        Online        : True
        RestartNeeded : False
        
  • 安装:

    1. 首先需要创建一个文件夹,用来存放子系统,在需要的位置创建即可,文件夹名任意

      • 如果使用PowerShell创建,则命令如下:
      New-Item E:\WSL\Debian -ItemType Directory
      Set-Location E:\WSL\Debian
      
    2. 手动下载Windows子系统发行版包,下载完需要的发行版包后,将后缀名为.appx的文件解压至上一步中的目录

      • 可使用PowerShell解压,也可以使用解压缩软件
    3. 如果上述步骤正确执行,此时文件夹中已产生一个Debian.exe(与下载的发行版一致,若是Ubuntu则为Ubuntu.exe)的文件,直接双击执行即可,会自动弹出一个控制台窗口

    4. 稍候片刻,子系统会自动安装,安装完成后会提示Enter new UNIX username,即输入新的用户名

    5. 输入完用户名后,再输入两遍用户密码,完成后会直接登入系统

  • 使用:

    • 每次需要使用的时候,直接双击该文件夹下的.exe文件就会自动打开控制台

    • 安装完成后,与平时的终端中操作表现一致

  • 附:Debian 9 阿里源

    deb http://mirrors.aliyun.com/debian stretch main contrib non-free
    deb-src http://mirrors.aliyun.com/debian stretch main contrib non-free
    deb http://mirrors.aliyun.com/debian stretch-updates main contrib non-free
    deb-src http://mirrors.aliyun.com/debian stretch-updates main contrib non-free
    deb http://mirrors.aliyun.com/debian-security stretch/updates main contrib non-free
    deb-src http://mirrors.aliyun.com/debian-security stretch/updates main contrib non-free
    

    其中stretch对应Debian 9 版本号,Debian 8 为jessie,Debian 10为buster,执行cat /etc/issue后根据对应系统版本更换相应文本即可

猜你喜欢

转载自www.cnblogs.com/hiragi/p/13402776.html