直接在windows 10系统中安装Ubuntu及Openwrt编译环境
对于喜欢折腾路由器固件的朋友来说,要下载源码并自己编译喜欢的openwrt固件,首先得搭建一个linux的系统环境——一般来说都是用VMware或者Hyper-V或者virtualBox等虚拟软件来部署——,今天看到还有一种直接在windows10系统中原生支持的部署方法,与大家分享:
一、在windows10中安装Ubuntu
1、首先打开开发人员模式
2、开启windows的子功能
3、重启电脑
4、 在Microsoft Store中搜索Ubuntu,并安装
5、安装完后,就可以直接打开Ubuntu了
默认是一个终端,先设置用户名和密码
Ubuntu默认把磁盘挂载到/mnt目录下,可以直接cd /mnt/d进入d盘,进而操作文件。
二、【安装openwrt编译环境】
1、安装依赖库
sudo apt-get install build-essential subversion libncurses5-dev zlib1g-dev gawk gcc-multilib flex git-core gettext libssl-dev unzip python
2、下载openwrt源码
比如安装在D盘:
cd /mnt/d
git clone https://github.com/openwrt/openwrt
cd openwrt/
切换到18.06.1发布分支,方便以后可以用官方源来安装插件
git checkout openwrt-18.06
git checkout 70255e3d624cd393612069aae0a859d1acbbeeae
3、配置
make menuconfig
选择要编译的设备和模块
4、编译
编译前建议先关掉win10自带的windows defender的实时保护,可加快编译速度
第一次编译建议单核编译,便于问题定位(-j1)
make V=99 -j1
编译完成,固件在/mnt/d/openwrt/bin/targets目录
如果用SDK编译,可能会出现如下错误:
.xargs.bin: loadlocale.c:129: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))’ failed.
则需要执行如下命令来解决: export LC_ALL=C
修改软件包仓库为国内阿里云镜像点的方法——修改/etc/apt/sources.list文件为下述语句:
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
按此方法我在编译lede固件时提示系统文件夹非大小写敏感,然后出错,到微软的官网https://blogs.msdn.microsoft.com/commandline/2018/02/28/per-directory-case-sensitivity-and-wsl/去看了一下,说要修改/etc/wsl.conf文件或/etc/fstab文件来改变大小写敏感的选项设置,但我打开这两个文件是空的,没有找到设置样板,还是没有改成功。
看另外一篇文章:http://iask.xya.in/1309.html
关于重启子系统,我无法用reboot方式重启,查找了一下,在windows的命令行模式(必须是管理员方式运行cmd)
CMD (Administrator)
net stop LxssManager
net start LxssManager
就ok了!
安装wsl子系统后mount的缺省状态为:
mount
rootfs on / type lxfs (rw,noatime)
none on /dev type tmpfs (rw,noatime,mode=755)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
devpts on /dev/pts type devpts (rw,nosuid,noexec,noatime,gid=5,mode=620)
none on /run type tmpfs (rw,nosuid,noexec,noatime,mode=755)
none on /run/lock type tmpfs (rw,nosuid,nodev,noexec,noatime)
none on /run/shm type tmpfs (rw,nosuid,nodev,noatime)
none on /run/user type tmpfs (rw,nosuid,nodev,noexec,noatime,mode=755)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noatime)
C: on /mnt/c type drvfs (rw,noatime,uid=1000,gid=1000,case=off)
D: on /mnt/d type drvfs (rw,noatime,uid=1000,gid=1000,case=off)
E: on /mnt/e type drvfs (rw,noatime,uid=1000,gid=1000,case=off)
F: on /mnt/f type drvfs (rw,noatime,uid=1000,gid=1000,case=off)
G: on /mnt/g type drvfs (rw,noatime,uid=1000,gid=1000,case=off)
H: on /mnt/h type drvfs (rw,noatime,uid=1000,gid=1000,case=off)
I: on /mnt/i type drvfs (rw,noatime,uid=1000,gid=1000,case=off)
好不容易解决了区分大小写问题,在make V=99编译的最后阶段有出错了:
make[4]: *** No rule to make target ‘compat/column.in’, needed by ‘po/quilt.pot’. Stop.
make[4]: Leaving directory ‘/mnt/i/lede/build_dir/host/quilt-0.65’
Makefile:36: recipe for target ‘/mnt/i/lede/build_dir/host/quilt-0.65/.built’ failed
make[3]: *** [/mnt/i/lede/build_dir/host/quilt-0.65/.built] Error 2
make[3]: Leaving directory ‘/mnt/i/lede/tools/quilt’
time: tools/quilt/compile#2.01#37.17#103.90
tools/Makefile:155: recipe for target ‘tools/quilt/compile’ failed
make[2]: *** [tools/quilt/compile] Error 2
make[2]: Leaving directory ‘/mnt/i/lede’
tools/Makefile:153: recipe for target ‘/mnt/i/lede/staging_dir/target-x86_64_musl/stamp/.tools_compile_yynyyyyynyyyyynyynnnyyyynyyyyyyyyyyyyyyynyyynynnyyynnyy’ failed
make[1]: *** [/mnt/i/lede/staging_dir/target-x86_64_musl/stamp/.tools_compile_yynyyyyynyyyyynyynnnyyyynyyyyyyyyyyyyyyynyyynynnyyynnyy] Error 2
make[1]: Leaving directory ‘/mnt/i/lede’
/mnt/i/lede/include/toplevel.mk:216: recipe for target ‘world’ failed
make: *** [world] Error 2
最后的解决方案:翻看编译错误日志中出错的是哪些工具包,单独把这些文件事先重新下载下来,然后拷贝到/mnt/i/lede/dl目录,再用make编译就成功了!