win10離線安裝WSL2 Ubuntu20.04系統(tǒng)

雖然微軟官方提供了方便的APP Store安裝方式,和自動(dòng)的命令安裝方式,單由于國內(nèi)限制因素,導(dǎo)致官方網(wǎng)速巨慢,而且很不穩(wěn)定。

這不得不迫使我們探索一種不依賴官方網(wǎng)站的安裝方式。步驟如下。

準(zhǔn)備

設(shè)置BIOS,開啟CPU的虛擬功能。

步驟 1 - 啟用適用于 Linux 的 Windows 子系統(tǒng)

需要先啟用“適用于 Linux 的 Windows 子系統(tǒng)”可選功能,然后才能在 Windows 上安裝 Linux 分發(fā)。

以管理員身份打開 PowerShell 并運(yùn)行:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

步驟 2 - 檢查運(yùn)行 WSL 2 的要求

若要更新到 WSL 2,需要運(yùn)行 Windows 10。

  • 對(duì)于 x64 系統(tǒng):版本 1903 或更高版本,采用 內(nèi)部版本 18362 或更高版本。
  • 對(duì)于 ARM64 系統(tǒng):版本 2004 或更高版本,采用 內(nèi)部版本 19041 或更高版本。
  • 低于 18362 的版本不支持 WSL 2。 使用 Windows Update 助手更新 Windows 版本。

若要檢查 Windows 版本及內(nèi)部版本號(hào),選擇 Windows 徽標(biāo)鍵 + R,然后鍵入“winver”,選擇“確定”。 更新到“設(shè)置”菜單中的最新 Windows 版本。

備注

如果運(yùn)行的是 Windows 10 版本1903 或 1909,請(qǐng)?jiān)?Windows 菜單中打開“設(shè)置”,導(dǎo)航到“更新和安全性”,然后選擇“檢查更新”。 內(nèi)部版本號(hào)必須是 18362.1049+ 或 18363.1049+,次要內(nèi)部版本號(hào)需要高于 .1049。 閱讀詳細(xì)信息:WSL 2 即將支持 Windows 10 版本 1903 和 1909。 請(qǐng)參閱疑難解答說明。

步驟 3 - 啟用虛擬機(jī)功能

安裝 WSL 2 之前,必須啟用“虛擬機(jī)平臺(tái)”可選功能。 計(jì)算機(jī)需要虛擬化功能才能使用此功能。

以管理員身份打開 PowerShell 并運(yùn)行:

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

重新啟動(dòng) 計(jì)算機(jī),以完成 WSL 安裝并更新到 WSL 2。

步驟 4 - 下載 Linux 內(nèi)核更新包

下載最新包:

https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi

適用于 x64 計(jì)算機(jī)的 WSL2 Linux 內(nèi)核更新包

備注

如果使用的是 ARM64 計(jì)算機(jī),請(qǐng)下載 ARM64 包。 如果不確定自己計(jì)算機(jī)的類型,請(qǐng)打開命令提示符或 PowerShell,并輸入:systeminfo | find "System Type"。 警告: 在非英語 Windows 版本中,你可能需要修改搜索文本,例如在德語中為 systeminfo | find "Systemtyp"。

運(yùn)行上一步中下載的更新包。 (雙擊以運(yùn)行 - 系統(tǒng)將提示你提供提升的權(quán)限,選擇“是”以批準(zhǔn)此安裝。)

安裝完成后,請(qǐng)繼續(xù)執(zhí)行下一步 - 在安裝新的 Linux 分發(fā)時(shí),將 WSL 2 設(shè)置為默認(rèn)版本。 (如果希望將新的 Linux 安裝設(shè)置為 WSL 1,請(qǐng)?zhí)^此步驟。)

備注

有關(guān)詳細(xì)信息,請(qǐng)參閱 Windows 命令行博客上的文章對(duì)更新 WSL2 Linux 內(nèi)核的更改。

步驟 5 - 將 WSL 2 設(shè)置為默認(rèn)版本

打開 PowerShell,然后在安裝新的 Linux 發(fā)行版時(shí)運(yùn)行以下命令,將 WSL 2 設(shè)置為默認(rèn)版本:

wsl --set-default-version 2

步驟 6 - 下載ubuntu20.04安裝包。

進(jìn)入

https://docs.microsoft.com/en-us/windows/wsl/install-manual

選擇合適的系統(tǒng)安裝包。這里選擇ubuntu20.04

由于這個(gè)包比較大,在瀏覽器里點(diǎn)擊下載鏈接右鍵,提取下載地址,打開迅雷或者其他第三方下載工具,新建下載任務(wù),由于迅雷有國內(nèi)的CDN加速,一般下載可以跑滿帶寬。原來需要8個(gè)小時(shí)的任務(wù),現(xiàn)在幾分鐘就好了。

下載完成后,雙擊安裝完成。一般第一次進(jìn)入U(xiǎn)buntu系統(tǒng),需要設(shè)置用戶名,密碼等。安裝系統(tǒng)提示操作即可。

步驟 7 - 安裝 Windows 終端(可選)

Windows 終端可啟用多個(gè)選項(xiàng)卡(在多個(gè) Linux 命令行、Windows 命令提示符、PowerShell 和 Azure CLI 等之間快速切換)、創(chuàng)建鍵綁定(用于打開或關(guān)閉選項(xiàng)卡、復(fù)制粘貼等的快捷方式鍵)、使用搜索功能,以及使用自定義主題(配色方案、字體樣式和大小、背景圖像/模糊/透明度)。 了解詳細(xì)信息。

安裝 Windows 終端。
https://docs.microsoft.com/zh-cn/windows/terminal/get-started

Windows 終端


image

步驟 8 - 更換ubuntu系統(tǒng)軟件倉庫源為國內(nèi)鏡像(可選)

Ubuntu 20.04 是 Ubuntu 的第 8 個(gè) LTS 版本,其重大更新和改進(jìn)將在 2030 年前終止,計(jì)劃于2020年 4 月 23 日發(fā)布。

國內(nèi)有很多Ubuntu的鏡像源,包括阿里的、網(wǎng)易的,還有很多教育網(wǎng)的源,比如:清華源、中科大源。

我們這里以清華源為例講解如何修改Ubuntu 20.04里面默認(rèn)的源。
編輯/etc/apt/sources.list文件, 在文件最前面添加以下條目(操作前請(qǐng)做好相應(yīng)備份):

清華源

# 默認(rèn)注釋了源碼鏡像以提高 apt update 速度,如有需要可自行取消注釋
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse

# 預(yù)發(fā)布軟件源,不建議啟用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse

然后執(zhí)行命令:

sudo apt-get update
sudo apt-get upgrade

其他幾份國內(nèi)源如下:

阿里源

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

中科大源

deb https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse

網(wǎng)易163源

deb http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ focal-backports main restricted universe multiverse
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 背景 由于新款Mac性價(jià)比走低,近期轉(zhuǎn)為使用Windows作為主力開發(fā)系統(tǒng)。但是在開發(fā)過程中需要上Linux測(cè)試,...
    AlienPaul閱讀 77,858評(píng)論 12 81
  • 環(huán)境 windows10 2004 前言 一開始是想在自己的電腦上使用docker,所以理所當(dāng)然地裝了docker...
    湖與月閱讀 4,578評(píng)論 0 0
  • 安裝WSL2 我將會(huì)按照 Windows Subsystem for Linux Installation Gui...
    Zoom1111閱讀 826評(píng)論 0 1
  • 1、適用于 Linux 的 Windows 子系統(tǒng)安裝 (1) 參考官方教程進(jìn)行安裝[https://docs.m...
    jerry_bio閱讀 3,588評(píng)論 2 0
  • 16宿命:用概率思維提高你的勝算 以前的我是風(fēng)險(xiǎn)厭惡者,不喜歡去冒險(xiǎn),但是人生放棄了冒險(xiǎn),也就放棄了無數(shù)的可能。 ...
    yichen大刀閱讀 7,832評(píng)論 0 4

友情鏈接更多精彩內(nèi)容