今天一早起床,打開debian,居然出現 錯誤: 0x80070040 。不知道是怎麼回事,網上有篇文章詳細介紹了windows linux子系統,打算參考來做做:https://www.jianshu.com/p/bc38ed12da1d 。非常有技術的一篇文章。用wslconfig /u Deb... ...
今天一早起床,打開debian,居然出現 錯誤: 0x80070040 。不知道是怎麼回事,網上有篇文章詳細介紹了windows linux子系統,打算參考來做做:https://www.jianshu.com/p/bc38ed12da1d 。非常有技術的一篇文章。
用wslconfig /u Debian刪了系統,輸入debian重新安裝。過程倒是很簡單快捷,就是想不到這個子系統那麼容易完蛋。
既然如此就整理一下安裝的步驟吧:
1. 安裝Linux子系統
2.微軟商店搜索linux
選debian 安裝就行了。
3.配置Linux 更新源
因為linux很多東西都是網上更新的,而且是外國,網速是一大問題,必須要找到快速的更新源。所以第一步就是要更改更新源,否則什麼都別想幹了。註意:win10自帶的debian是版本9。
debian 的配置放在/etc 這個目錄,而更新工具叫apt,所以在/etc/apt 目錄下麵的sources.list 文本文件就是我們要修改的對象。
阿裡巴巴的源替換一下,用#可以註釋掉原來的內容。
阿裡巴巴有各種linux的備份源,非常棒: https://opsx.alibaba.com/mirror (不知道騰訊有沒有做這方面的工作)
命令:sudo nano /etc/apt/sources.list
#deb http://deb.debian.org/debian stretch main
#deb http://deb.debian.org/debian stretch-updates main
#deb http://security.debian.org/debian-security/ stretch/updates main
#阿裡源
deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb http://mirrors.aliyun.com/debian-security stretch/updates main
deb-src http://mirrors.aliyun.com/debian-security stretch/updates main
deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
其中sudo表示提升許可權,nano是一個命令行編輯器,linux的命令行工具真是非常強大,這麼簡單的工具都有語法識別,上色功能。
下麵的是菜單,^表示ctrl 按鍵。ctrl + O 寫入,然後ctrl + X退出即可。
4.自動更新
sudo apt-get update
5.安裝dotnet core sdk
微軟官方指導:https://www.microsoft.com/net/download/linux-package-manager/debian9/sdk-current
wget https://packages.microsoft.com/keys/microsoft.asc --no-check-certificate
下載微軟的證書,不知道為什麼不能下載,用—no-check-certificate參數避免檢查證書。linux這方面是很嚴格的,有點煩。
wget是一個下載工具。
gpg --dearmor microsoft.asc
gpg是一個加密工具,這裡面是將文本編碼microsoft.asc 解碼成二進位的 microsoft.asc.gpg。 gpg尾碼是一個密鑰文件。
sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
mv移動文件
wget https://packages.microsoft.com/config/debian/9/prod.list --no-check-certificate
同樣也要不檢查網站證書才能下載成功,這次不知道是怎麼回事,上次沒這個問題。
sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list
移動,並把文件的擁有者改成root 和root組。
這些操作的目的大概就是把微軟的源增加進去。
sudo apt-get update 自動更新,結果提示沒有 apt-transport-https 庫,先安裝一下:
sudo apt-get install apt-transport-https
註意:原來之前沒有https組件的支持,所以wget才會出現這種錯誤,我把順序搞亂了。
在更新一次就ok了。然後就可以正常安裝dotcore了。
sudo apt-get install dotnet-sdk-2.1
會增加412m。安裝過程會卡半天,要等待回到命令提示符狀態即可。
6.備份一下
這個環境那麼難配置,嘗試備份一下。
找到C:\Users\zhouy\AppData\Local\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState\ 用xcopy把rootfs 備份一份,暫時還無法驗證這個方法有沒有用。
7.配置遠程開發
繼續今天的目標,就是在windows上用vscode 連接 debian上的netcore來開發。嘗試了remote vscode 擴展,確實可以打開遠程文件,但是這有什麼用呢?怎麼編譯?暫時沒什麼好思路,先放下了。
發現官方是有文檔支持遠程調試,特別是支持linux子系統調試的,看來我的需求是得到支持的,不過是英文資料,需要慢慢啃。
wsl 官方文檔:https://github.com/OmniSharp/omnisharp-vscode/wiki/Windows-Subsystem-for-Linux
待續