找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 39749|回复: 80

[openwrt(x86)] 从零开始打造自己的openwrt x86-64固件

 火.. [复制链接]
本帖最后由 99010 于 2016-4-20 14:59 编辑

openwrt官方(Chaos Calmer)x86-64固件默认支持多核大内存以及U盘启动,免去了以往要修改内核的麻烦。

请准备好2个U盘(或者1个U盘和1个硬盘),其中一个U盘是安装openwrt系统,另一个用来打包固件。(如果对linux熟悉,一个U盘就可以完成这项工作)
用到的软件winscp、putty。

1.把U盘插到任意一台刷了openwrt的路由上,不要挂载(如果自动挂载了,需umount)。其中/dev/sda可改为实际的。
ssh登陆路由,执行如下命令:
  1. cd /tmp
  2. wget http://downloads.openwrt.org/chaos_calmer/15.05.1/x86/64/openwrt-15.05.1-x86-64-combined-squashfs.img
  3. dd if=/tmp/openwrt-15.05.1-x86-64-combined-squashfs.img of=/dev/sda
  4. sync
复制代码

2.把写好固件的U盘插到要做路由用的x86电脑上(注:1.起码是双网卡。2.cpu必须支持64位,32位的不能启动。),在bios里设置U盘启动。
接好网线,内网一般是靠近cpu的那个。
用另一台电脑登陆,在luci界面修改路由密码、配置网络,然后ssh登陆
  1. opkg update
  2. opkg install luci-i18n-base-zh-cn
  3. opkg install kmod-usb-storage block-mount kmod-fs-ext4 blkid fdisk e2fsprogs
  4. reboot
复制代码
重启路由后,插入另一个U盘并将其格式化
  1. mkfs.ext4 /dev/sdb
复制代码
在luci界面挂载sdb分区,(可用blkid查看sdb的uuid,方便用uuid挂载)

3.下载安装基本debian
  1. opkg update
  2. opkg install debootstrap binutils objdump bash xz
  3. debootstrap  --arch=amd64  jessie /mnt/sdb/debian-jessie http://mirrors.163.com/debian/
复制代码
一段时间后,debian下载完成,备份一下
cd /mnt/sdb
tar zcvf debian-jessie.tar.gz debian-jessie
然后用winscp把debian-jessie.tar.gz下载下来做备份。

4.加载并进入debian
  1. mount -o bind /proc /mnt/sdb/debian-jessie/proc
  2. mount -o bind /dev /mnt/sdb/debian-jessie/dev
  3. mount --bind /dev/pts /mnt/sdb/debian-jessie/dev/pts
  4. chroot /mnt/sdb/debian-jessie /bin/bash
复制代码
安装组件
  1. apt-get update
  2. apt-get install bzip2 make
复制代码
建一个工作目录,并下载固件生成器
  1. mkdir -p openwrt
  2. cd openwrt
  3. wget http://downloads.openwrt.org/chaos_calmer/15.05.1/x86/64/OpenWrt-ImageBuilder-15.05.1-x86-64.Linux-x86_64.tar.bz2
  4. tar -xvjf OpenWrt-ImageBuilder-15.05.1-x86-64.Linux-x86_64.tar.bz2
  5. cd OpenWrt-ImageBuilder-15.05.1-x86-64.Linux-x86_64
复制代码
建一个files文件夹,里面放一些个人配置进去,比如系统名字、系统时区、中文界面

生成固件(要打包的组件太多,所以用\做分行,组件可自行添加或删减)。这里只是打包官方组件,如果要打包第三方组件,可以上传ipk到dl目录一起打包。
  1. make image PACKAGES="luci luci-ssl luci-app-p910nd luci-app-ddns luci-app-hd-idle luci-app-samba luci-app-transmission \
  2. luci-app-upnp luci-app-wol \
  3. luci-i18n-base-zh-cn luci-i18n-ddns-zh-cn luci-i18n-firewall-zh-cn luci-i18n-hd-idle-zh-cn \
  4. luci-i18n-p910nd-zh-cn luci-i18n-samba-zh-cn luci-i18n-transmission-zh-cn transmission-web \
  5. luci-i18n-upnp-zh-cn luci-i18n-wol-zh-cn \
  6. ipset ip iptables-mod-nat-extra ppp-mod-pptp \
  7. iptables-mod-ipopt iptables-mod-filter iptables-mod-u32 \
  8. kmod-usb-storage block-mount kmod-fs-ext4 blkid fdisk e2fsprogs \
  9. kmod-usb2 kmod-usb3 kmod-usb-ohci kmod-usb-printer \
  10. debootstrap binutils objdump bash xz \
  11. base-files libc libgcc busybox dropbear mtd uci 6to4 \
  12. opkg netifd fstools kmod-e1000e kmod-e1000 kmod-r8169 \
  13. -dnsmasq dnsmasq-full iptables ip6tables \
  14. ppp ppp-mod-pppoe kmod-nf-nathelper firewall odhcpd odhcp6c" FILES=files/
复制代码
后面有个报错,不用管,能生成固件就行。

打包生成固件可以用winscp下载回电脑在luci界面直接升级,也可以在ssh里面dd写到系统U盘上。

附送一个本人自用的files文件:


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×

评分

参与人数 1恩山币 +1 收起 理由
lc*** + 1 支付宝已转500w给你!

查看全部评分

我的恩山、我的无线 The best wifi forum is right here.
up
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

写得不是一般的复杂。写入img,在win下只需要用winhex就可以了。
imagebuilder,虚拟机就完成的事,竟然还要debian live ??

点评

为何我写入U盘总是出错?求解  详情 回复 发表于 2016-11-14 00:53
虚拟机不是更复杂? 在openwrt系统里面chroot debian,不是一般的方便。  详情 回复 发表于 2016-4-20 14:54
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| | 显示全部楼层
本帖最后由 99010 于 2016-4-20 15:13 编辑
prohy 发表于 2016-4-20 14:39
写得不是一般的复杂。写入img,在win下只需要用winhex就可以了。
imagebuilder,虚拟机就完成的事,竟然还 ...

虚拟机不是更复杂?
在openwrt系统里面chroot debian,而且那个debian才200M大小,网络好下载回来才几分钟,比用虚拟机方便多了。这个debian还能做很多用途。。。
跑着迅雷网页监工。。。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×

点评

我承认这个debian很有用,问题是坛里面大部分都是连cd ls 、甚至“ / ” 是什么都不知道的小白, 你写得这么深奥,对别人的帮助实在有限  详情 回复 发表于 2016-4-20 16:18
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

跟高人学习下!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

学习下。。。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

看看,你的教程。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

99010 发表于 2016-4-20 14:54
虚拟机不是更复杂?
在openwrt系统里面chroot debian,而且那个debian才200M大小,网络好下载回来才几分 ...

我承认这个debian很有用,问题是坛里面大部分都是连cd ls 、甚至“ / ” 是什么都不知道的小白, 你写得这么深奥,对别人的帮助实在有限

点评

是啊,小白过来露个脸,确实可以当作进阶教程了  详情 回复 发表于 2016-4-20 19:04
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

绝世好文,不得不顶
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

学习下 谢谢
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

支持一下  感谢分享。。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

学习,学习
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

有没有多播功能啊?
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

有点晕
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

imagebuilder
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

欢迎大家光临恩山无线论坛上一条 /1 下一条

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-29 22:00

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表