linux子系统折腾记 (二)

今天一早起床,打开debian,居然出现 错误: 0x80070040 。不知道是怎么回事,网上有篇文章详细介绍了windows linux子系统,打算参考来做做:https://www.jianshu.com/p/bc38ed12da1d 。非常有技术的一篇文章。

用wslconfig /u Debian删了系统,输入debian重新安装。过程倒是很简单快捷,就是想不到这个子系统那么容易完蛋。

既然如此就整理一下安装的步骤吧:

1. 安装Linux子系统

imageimage

2.微软商店搜索linux

image

选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的命令行工具真是非常强大,这么简单的工具都有语法识别,上色功能。

image

下面的是菜单,^表示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。安装过程会卡半天,要等待回到命令提示符状态即可。

image

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

待续

posted @ 2018-09-26 22:53  诺贝尔  阅读(768)  评论(0编辑  收藏  举报