WSL 部署记录

1. 管理员打开PowerShell,开启WSL功能:

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

2. 应用商店下载安装ubuntu

  默认工作路径:

C:\Users\abnk\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs
\\wsl$ # 文件资源管理器直接输入

  Ubuntu中由apt-get获得的文件包保存在:

/var/cache/apt/archives

3. VMWare和Hyper-v冲突的解决:

bcdedit /set hypervisorlaunchtype off

  重启或手动停止Hyper-v服务

bcdedit /set hypervisorlaunchtype auto

  用VM就关,用Hyper-v就开

4. 更改源:

  参考

sudo cp /etc/apt/sources.list /etc/apt/sources.list_bak
# sudo vim /etc/apt/sources.list

  修改:

# :%s#security.ubuntu.com#mirrors.tuna.tsinghua.edu.cn#g
# :%s#archive.ubuntu.com#mirrors.tuna.tsinghua.edu.cn#g
# :%s#cn.mirrors.tuna.tsinghua.edu.cn#mirrors.tuna.tsinghua.edu.cn#g

# 18,20版本就用下面的就OK :
%s#archive.ubuntu.com#mirrors.tuna.tsinghua.edu.cn#g

# 一行命令搞定
sed -i "s#archive.ubuntu.com#mirrors.tuna.tsinghua.edu.cn#g"  /etc/apt/sources.list
# 对于CentOS,更改源先yum update, 然后 yum grouplist 再安装
sed -e 's|^mirrorlist=|#mirrorlist=|g' -e 's|^#baseurl=http://mirror.centos.org|baseurl=https://mirrors.tuna.tsinghua.edu.cn|g' -i.bak /etc/yum.repos.d/CentOS-*.repo

  其它:

sudo mv /etc/yum.repos.d/CentOS-Local.repo /etc/yum.repos.d/CentOS-Local.repo_bak
yum clean all && yum makecache

  生效:

sudo apt update

5. 安装gcc、g++

  参考

sudo apt-get install build-essential
sudo apt install gcc g++           # 不要用这个了

  以下内容将被安装:

The following NEW packages will be installed:
  binutils binutils-common binutils-x86-64-linux-gnu build-essential cpp cpp-9 dpkg-dev fakeroot g++ g++-9 gcc gcc-9
  gcc-9-base libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan5 libatomic1 libbinutils
  libc-dev-bin libc6-dev libcc1-0 libcrypt-dev libctf-nobfd0 libctf0 libdpkg-perl libfakeroot libfile-fcntllock-perl
  libgcc-9-dev libgomp1 libisl22 libitm1 liblsan0 libmpc3 libquadmath0 libstdc++-9-dev libtsan0 libubsan1
  linux-libc-dev make manpages-dev
Log

6. 升级WSL2

  参考   官方指南(安装内核升级包)   重装发生的问题解决

  ① 下载安装 Linux 内核升级包:参考

  ② powershell开启管理员权限:

Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform
wsl -l -v
wsl --set-version Ubuntu-20.04 2
wsl --set-default-version 2

7. 其它

ssh -i ~/.ssh/id_rsa root@192.168.40.174

  默认的源:

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://archive.ubuntu.com/ubuntu/ focal main restricted
# deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted
# deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://archive.ubuntu.com/ubuntu/ focal universe
# deb-src http://archive.ubuntu.com/ubuntu/ focal universe
deb http://archive.ubuntu.com/ubuntu/ focal-updates universe
# deb-src http://archive.ubuntu.com/ubuntu/ focal-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://archive.ubuntu.com/ubuntu/ focal multiverse
# deb-src http://archive.ubuntu.com/ubuntu/ focal multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-updates multiverse
# deb-src http://archive.ubuntu.com/ubuntu/ focal-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
# deb-src http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu focal partner
# deb-src http://archive.canonical.com/ubuntu focal partner

deb http://security.ubuntu.com/ubuntu/ focal-security main restricted
# deb-src http://security.ubuntu.com/ubuntu/ focal-security main restricted
deb http://security.ubuntu.com/ubuntu/ focal-security universe
# deb-src http://security.ubuntu.com/ubuntu/ focal-security universe
deb http://security.ubuntu.com/ubuntu/ focal-security multiverse
# deb-src http://security.ubuntu.com/ubuntu/ focal-security multiverse
View Code

 

posted @ 2019-08-04 15:03  AlexOne  阅读(417)  评论(0编辑  收藏  举报