使用imgeBuilder能快速创建指定硬件的系统映像文件,openWRT自带了很多的软件,通过imgeBuilder定制,可以根据需要删减或增加自己需要的软件,并生成可以直接烧写的系统映像文件。下面就按步骤来生成一个映像文件吧。

1、环境介绍。一个运行64位Linux的虚拟机(我用的debain),预装gcc,make等开发工具。我的硬件是y1s路由器,MT7620的CPU。

apt-get install gcc make git-core unzip gawk libncurses5-dev build-essential libssl-dev libz-dev bzip2 binutils subversion

2、从国内镜像网站下载imagebuilder软件包,openwrt-imagebuilder-18.06.8-ramips-mt7620.Linux-x86_64.tar.xz

3、使用虚拟机提供的宿主机和虚拟机间共享文件夹或scp方式,将下载的文件拷贝到Linux中。

4、解压缩,释放文件到默认目录。

tar xvf openwrt-imagebuilder-18.06.8-ramips-mt7620.Linux-x86_64.tar.xz

5、进入imageBuilder目录,编辑文件repositories.conf,修改下载位置为国内镜像网站并保存。

cd openwrt-imagebuilder-18.06.8-ramips-mt7620.Linux-x86_64

vi repositories.conf

src/gz openwrt_core https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/18.06.8/targets/ramips/mt7620/packages
src/gz openwrt_base https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/18.06.8/packages/mipsel_24kc/base
src/gz openwrt_luci https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/18.06.8/packages/mipsel_24kc/luci
src/gz openwrt_packages https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/18.06.8/packages/mipsel_24kc/packages
src/gz openwrt_routing https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/18.06.8/packages/mipsel_24kc/routing
src/gz openwrt_telephony https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/18.06.8/packages/mipsel_24kc/telephony

6、试着创建一下

make image PROFILE=y1s

如果不知道自己硬件对应的项目名,可以使用make info查看。

编译的过程,会从网上下载需要的软件包,因为是从国内镜像下载,所以速度还是很快的,当然也可以自己下载,拷贝到dl目录,编译过程自动下载的文件也在这个目录下。

新创建的映像文件在这个目录下/root/openwrt-imagebuilder-18.06.8-ramips-mt7620.Linux-x86_64/bin/targets/ramips/mt7620

查看一下文件的大小

root@debian10:~/openwrt-imagebuilder-18.06.8-ramips-mt7620.Linux-x86_64/bin/targets/ramips/mt7620# ll
total 6416
-rw-r--r-- 1 root root    4367 Aug  5 17:56 openwrt-18.06.8-ramips-mt7620-device-y1s.manifest
-rw-r--r-- 1 root root 6553768 Aug  5 17:56 openwrt-18.06.8-ramips-mt7620-y1s-squashfs-sysupgrade.bin
-rw-r--r-- 1 root root     240 Aug  5 17:56 sha256sums

文件openwrt-18.06.8-ramips-mt7620-y1s-squashfs-sysupgrade.bin就是我们要的,把他拷贝出来,登录路由器升级选这个文件即可

7、好了,可以定制我自己映像,使用以下命令

make image PROFILE=y1s PACKAGES="luci luci-base luci-i18n-base-zh-cn luci-theme-bootstrap uhttpd snmp-utils snmpd snmp-mibs kmod-usb-core kmod-usb2 kmod-usb-ohci kmod-usb-storage kmod-fs-vfat kmod-fs-ext4 kmod-fs-ntfs ntfs-3g kmod-fs-ext4 mount-utils block-mount fdisk kmod-nls-cp437 kmod-nls-iso8859-1 luci-app-samba mosquitto-nossl mosquitto-client-nossl libmosquitto-nossl"

我自己选择的软件包有snmp,usb文件系统以及mosquitto

 

 

 

Logo

更多推荐