1.WSL Ubuntu-20.04 安装

1).请在 控制面板>>程序与功能>>启用或关闭windows功能>>适用于linux的windows子系统 中勾选,并点击确定保存更改
2).请在Microsoft Store中搜索 Ubuntu-20.04 LTS 下载 并打开,建立一个非root的用户后退出
3).WSL Ubuntu-20.04 安装路径(告知一下给你,没什么用)
C:\Users\Username\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState

C:\Program Files\WindowsApps\CanonicalGroupLimited.Ubuntu20.04onWindows_2004.2021.610.0_x64__79rhkp1fndgsc

2.WSL Ubuntu-20.04 卸载与转移安装位置

C盘空间少可以使用本方法

以下命令均在PowerShell管理员模式下运行


关机命令
wsl --shutdown

查询当前已安装的WSL子系统
wsl -l -v

导出Ubuntu-20.04系统到D:\utd\下的ubuntu.tar文件
wsl --export Ubuntu-20.04 D:\utd\ubuntu.tar

卸载ubuntu-20.04
wslconfig /u ubuntu-20.04

导入D:\utd\ubuntu.tar到D:\ubuntu
wsl --import Ubuntu-20.04 D:\ubuntu D:\utd\ubuntu.tar
设置默认启动为ubuntu-20.04
wslconfig /s ubuntu-20.04

!!! 到目前为止,转移ubuntu-20.04已经完成 !!!


强制删除
del /F /S /Q D:\ubuntu

设置默认启动用户为hi(任君选择)
ubuntu2004.exe config --default-user hi
重启WSL Ubuntu
net stop LxssManager
net start LxssManager

3.为当前用户设置代理

1).永久设置
sudo vi /etc/profile

按一下键盘的A或者 i 后 把以下内容添加到文件中(自行更改IP)

export all_proxy="http://192.168.2.100:1080"
export http_proxy="http://192.168.2.100:1080"
export https_proxy="http://192.168.2.100:1080"
# export all_proxy="socks5://192.168.2.100:1080"

按ESC后输入 :wq 即可保存文件 然后输入

source /etc/profile

2).临时设置
export all_proxy="http://192.168.2.100:1080"
export http_proxy="http://192.168.2.100:1080"
export https_proxy="http://192.168.2.100:1080"
# export all_proxy="socks5://192.168.2.100:1080"
3).设置DNS

参考:https://zhuanlan.zhihu.com/p/348583848


4.更换Ubuntu apt官方源为清华源

1).查看Ubuntu版本代号
sudo lsb_release -a
2).在shell中输入命令
sudo rm -rf /etc/apt/sources.list
sudo vi /etc/apt/sources.list

按一下键盘的 A 或者 i 后 复制以下内容到sources.list

# Ubuntu 20.04.2.0 LTS (Focal Fossa)
deb 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 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 https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# 参考
https://wiki.ubuntu.org.cn/%E6%A8%A1%E6%9D%BF:Ubuntu_source
# 其他源(替换域名即可)
https://mirrors.163.com/ubuntu/
https://mirrors.aliyun.com/ubuntu/
https://mirrors.sohu.com/ubuntu/
https://mirrors.cloud.tencent.com/ubuntu/
https://mirrors.ustc.edu.cn/ubuntu/

按ESC后输入 :wq 即可保存文件


5.环境准备

1).在shell中输入以下命令
sudo apt-get update
sudo apt-get -y install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch python3 python2.7 unzip zlib1g-dev lib32gcc1 libc6-dev-i386 subversion flex uglifyjs git-core gcc-multilib p7zip p7zip-full msmtp libssl-dev texinfo libglib2.0-dev xmlto qemu-utils upx libelf-dev autoconf automake libtool autopoint device-tree-compiler g++-multilib antlr3 gperf wget curl swig rsync grep libc-dev perl ack bison ccache cmake cpio ecj fastjar haveged help2man intltool libgmp3-dev libltdl-dev libmpc-dev libmpfr-dev libreadline-dev lrzsz mkisofs nano ninja-build pkgconf python3-pip python3-ply python-docutils re2c scons squashfs-tools upx-ucl xxd
2).天灵大佬的环境
sudo apt update -y
sudo apt full-upgrade -y
sudo apt install -y ack antlr3 asciidoc autoconf automake autopoint binutils bison build-essential \
  bzip2 ccache cmake cpio curl device-tree-compiler ecj fastjar flex gawk gettext git git-core gperf haveged \
  help2man intltool lib32gcc1 libc6-dev-i386 libelf-dev libglib2.0-dev libgmp3-dev libltdl-dev libmpc-dev \
  libmpfr-dev libncurses5-dev libncurses5-dev libreadline-dev libssl-dev libtool libz-dev lrzsz mkisofs msmtp \
  nano ninja-build p7zip p7zip-full patch pkgconf python2.7 python3 python3-pip python3-ply python-docutils \
  qemu-utils re2c rsync scons squashfs-tools subversion swig texinfo uglifyjs upx-ucl unzip vim wget xmlto \
  xxd zlib1g-dev
3).一条命令即可完成环境准备
curl -s https://build-scripts.project-openwrt.eu.org/init_build_environment.sh | sudo bash

等待环境部署完成


4).克隆仓库
git clone -b master --single-branch https://github.com/coolsnowwolf/lede

贴几个地址openwrt(排名不分先后)

git clone -b openwrt-18.06 --single-branch https://github.com/immortalwrt/immortalwrt
git clone -b master --single-branch  https://github.com/x-wrt/x-wrt
git clone -b master --single-branch https://github.com/openwrt/openwrt
git clone -b main --single-branch https://github.com/Lienol/openwrt
git clone -b lede-17.01 --single-branch https://github.com/coolsnowwolf/openwrt

6.编译准备

1).进入系统目录
cd lede
# cd i
2).设置软件包源(可选)
sed -i '$a src-git NueXini_Packages https://github.com/NueXini/NueXini_Packages.git' feeds.conf.default
3).替换路由IP为192.168.3.1(可选
sed -i 's/192.168.1.*.1/192.168.3.1/g' package/base-files/files/bin/config_generate
4).更新软件包
./scripts/feeds update -a
./scripts/feeds install -a
5).替换默认主题为luci-theme-argon(可选)
sed -i 's/luci-theme-bootstrap/luci-theme-argon/g' feeds/luci/collections/luci/Makefile

(version release)

sed -i 's#%D#&/NueXini#g' package/base-files/files/etc/openwrt_release
sed -i 's#ImmortalWrt#&/NueXini#g' include/version.mk
sed -i 's#_DIST),OpenWrt#&/NueXini#g' include/version.mk
6).选择机型
make menuconfig
7).下载支持库
make -j8 download
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;

如果有错误请用

make -j1 V=sc download

7.开始编译

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin make -j4

(make -j4 这里用的是4线程)

(也可以导入路径,免去路径输入的烦恼)

sudo vi /etc/profile

输入以下内容后保存

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
export PATH

8.编译完成

编译完成后输出路径:bin/targets


9.二次编译

cd lede
# cd openwrt
# cd immortalwrt
git pull
./scripts/feeds update -a && ./scripts/feeds install -a
# 编译有出错的请使用(清除bin和build_dir目录)
make clean

# make clean + 清除交叉编译工具
# make dirclean

# 你想回到最初状态的话
# make distclean
1).保留原机型编译
make defconfig
make -j8 download
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin make -j4
2).重新设置机型
rm -rf ./tmp && rm -rf .config
make menuconfig
make -j8 download
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin make -j4
Logo

更多推荐