windows10下安裝子系統linux(centos)


前提條件:

​ 1.打開WSL

​ 1.1方式一:使用管理員權限打開 powershell,執行

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

​ 1.2方式二:控制面板->程序->啟用或關閉windows功能->找到適用於Linux的Windows子系統勾選,確定后需要重啟電腦生效。

方式一:微軟商店安裝centos

微軟商店的centos均需要收費,放棄。

方式二:Github開源工具WSL-Distribution-Switcher

注意:該方式前提是系統內需要有一個linux子系統,可以在微軟商店安裝免費的ubuntu。

原因:WSL-Distribution-Switcher需要依賴一個ubuntu,現在不裝,后期也需要安裝。

參考網址:GitHub - RoliSoft/WSL-Distribution-Switcher: Scripts to replace the distribution behind Windows Subsystem for Linux with any other Linux distribution published on Docker Hub.

出現下載鏡像報錯:cmd切換為管理員模式

1.下載WSL-Distribution-Switcher

​ 下載地址:https://github.com/RoliSoft/WSL-Distribution-Switcher/archive/master.zip

2.安裝python3,如果有跳過這步

​ 下載地址:Welcome to Python.org

​ 下載windows的exe執行文件直接安裝即可

3.通過WSL-Distribution-Switcher下載Centos7

​ 3.1在WSL-Distribution-Switcher的目錄下使用cmd,可以到dockerhub上去查看具體的tag,也可以在WSL-Distribution-Switcher目錄下打開Redme.md查看tag。

​ 3.2.獲取centos鏡像和依賴鏡像

​ 獲取鏡像-》python get-source.py centos:latest 或者 python get-source.py centos:centos7

​ 獲取依賴鏡像-》比如python get-prebuilt.py centos:latest 或者python get-prebuilt.py centos:centos7

​ 3.3安裝

注意:部分鏡像采用了SquashFS 格式,需要安裝一個python插件。指令:pip3 install PySquashfsImage

python install.py centos:centos7

​ 報錯:暫未解決。。。。

The Linux subsystem is not installed. Please go through the standard installation procedure first.

方式三:LxRunOffline工具

1.安裝LxRunOffline

方法一:下載 https://github.com/DDoSolitary/LxRunOffline/releases 解壓

方法二:powershell中運行(會安裝到C:\tools下):choco install lxrunoffline

2.下載系統鏡像

​ 例如:rootfs_centos_centos7.tar.xz

​ 方式一:https://github.com/RoliSoft/WSL-Distribution-Switcher第二步的工具可以下載

​ 方式二:https://docs.microsoft.com/en-us/windows/wsl/install-manual (微軟來源)

3.操作目錄為D:\WSL作為安裝使用目錄,可任意更換

准備工作:

​ 1.將LxRunOffline.exe和rootfs_centos_centos7.tar.xz復制到D:\WSL目錄下。

​ 2.如果想隨處使用LxRunOffline.exe,請加入系統環境變量,則不需要拷貝LxRunOffline.exe。

4.安裝鏡像

#其中 -d 后面是要安裝到的目錄,-f 是前面下載的鏡像, -n 用來指定名稱。
D:\WSL>D:\WSL\LxRunOffline.exe install -n centos7 -d D:\WSL\centos7 -f D:\WSL\rootfs_centos_centos7.tar.xz

5.查看鏡像

D:\WSL>LxRunOffline.exe list
Ubuntu
centos7

6.運行鏡像

D:\WSL>LxRunOffline.exe run -n centos7

7.卸載鏡像

D:\WSL\LxRunOffline.exe uninstall -n centos7

8.創建快捷方式(一般命令行創建失敗,則使用管理員模式打開cmd)

D:\WSL>lxrunoffline s -n centos7 -f 'C:\Users\lingyang\Desktop\centos7.lnk'


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM