找回密码
 注册

QQ登录

只需一步,快速开始

查看: 81517|回复: 97

F650/450、8145、K662等ARM平台,LXC容器内运行OpenWRT子系统

  [复制链接]
发表于 2020-2-17 02:14:04 | 显示全部楼层 |阅读模式
本帖最后由 songee 于 2022-4-27 21:04 编辑 & C0 ]7 Y' }, \/ `

/ A/ S1 E! a" a6 y5 Y8 g家里装宽带,电信200M,送了个中兴F650A。自带的天翼3.0web界面看着不错可惜几乎没有可玩性,闲来无事研究一番。  x) V1 K. @4 j5 M
    借鉴论坛前辈achaoge的帖子:中兴 F450A/F650A 免 TTL 持久开 ssh顺利开启telnet,发现该光猫的运作机制是 主系统负责底层的硬件驱动、sendcmd管理系统(telnet、超密、ppp拨号、网络及WiFi、ftp等)、以httpd为基础的8080端口电信web管理界面,最后启动saf(lxc容器管理)程序。, X) d  j7 L- J- P
    saf程序在华为和中兴的很多光猫上都存在,根据该程序在F650A中的功能,我认为其主要作用是自动管理lxc容器。开机有 ‘saf service 6 7 11’进程,意为将 mtd6 或 mtd7 作为saf子系统的firmware(rootfs)分区,mtd11 作为APPS数据overlay分区。至于是 mtd6 还是 mtd7,由 saf setactive 命令指定,默认 mtd6,如果子系统启动失败自动指定 mtd7;从 mtd7 启动失败可能导致整个 mtd11 分区被擦除,mtd11 分区同时也是主系统的overlay数据存放区,操作时需要特别注意!!1 g. \& Y' w" E  }; |; E
  1. root@F650A:/usr/sbin # saf9 n0 d% w7 d1 m2 ?; Y  A
  2. Usage: saf service FWK_MTD_ID1 FWK_MTD_ID2 APPS_MTD_ID (eg. saf service 9 10 7)5 U" N- m3 |2 c' D! l8 p
  3. saf console5 s) p- H* D8 b% D6 |" p2 r
  4. saf info2 A1 m1 E. z  f7 |; @* C3 `. M
  5. saf version
    - t4 y. T+ W' Y3 i- E$ i
  6. saf getfwkver+ X: O' t1 }2 A; ~, ^* X
  7. saf getbakfwkver
    5 ]# r# G5 r7 Z/ M6 F
  8. saf getactive
    ' L9 D- |& i2 D6 i, K9 h
  9. saf setactive FWK_MTD_ID [AFTER_REBOOT] (eg. ./saf setactive 17 1)
复制代码
  1. root@F650A:~ # cat /proc/mtd  N8 o* j6 N/ Q; P
  2. dev:    size   erasesize  name: r7 ?2 c. M$ S  [' P/ V7 i
  3. mtd0: 08000000 00020000 "whole flash"
    + z; r; P3 R2 h1 n' A
  4. mtd1: 00100000 00020000 "u-boot"
    ; y2 w+ n$ }% j% S; H* t$ y* T
  5. mtd2: 00080000 00020000 "others"
    ! N2 Q6 U+ ^, T+ z& q8 o) p
  6. mtd3: 00100000 00020000 "parameter tags"
    : W. V9 U, y& n& h6 @* X
  7. mtd4: 00100000 00020000 "wlan"+ l# T/ P8 |  D8 V
  8. mtd5: 00200000 00020000 "usercfg"
    9 g, N, X$ s! R! P) U! l+ r- l
  9. mtd6: 00800000 00020000 "framework"- D3 L  c8 N. H1 m& p$ e
  10. mtd7: 00800000 00020000 "framework1"
    * I1 T/ L3 ~. ?2 y* N7 L9 O: c
  11. mtd8: 00780000 00020000 "dbus"
    ) Q1 m# H  X# F7 u
  12. mtd9: 01280000 00020000 "kernel1"4 y! ~. `0 D1 Y+ @/ ^
  13. mtd10: 01280000 00020000 "kernel2"6 S! d8 {) p  D
  14. mtd11: 03e00000 00020000 "plugin_data"% |9 z& w- D  R' k' {  R, @
  15. mtd12: 01240000 00020000 "rootfs"
复制代码
( }8 a% p' R1 U
    saf程序管理子系统,是通过系统的lxc容器实现的,在/dbus/usr/bin/目录下有lxc相关程序,但并非标准的官方版,而是定制的,lxc.lxcpath即lxc容器存放位置设定为/usr/var/lib/lxc,暂时没有发现更改的方法(也没什么必要)。
root@F650A:~ # ls -l /dbus/usr/bin0 q9 ?! o; L) c
total 377
  Q3 h+ u) f0 `3 D9 Y-rwxr-xr-x    1 root     root         10143 Nov 15  2018 dbus-cleanup-sockets
% C  ?3 t" N* Y6 C1 x/ f- y  K7 n-rwxr-xr-x    1 root     root         18867 Nov 15  2018 dbus-launch) s% c4 P" ^) ~& t" F, b* I+ G
-rwxr-xr-x    1 root     root         22537 Nov 15  2018 dbus-monitor; j$ B# y1 }& i7 ]
-rwxr-xr-x    1 root     root         11049 Nov 15  2018 dbus-run-session
: D0 R6 G* l6 A-rwxr-xr-x    1 root     root         23431 Nov 15  2018 dbus-send
& F7 J2 f3 N& I3 T/ M$ @-rwxr-xr-x    1 root     root         19495 Nov 15  2018 dbus-test-tool
+ T: [1 p7 s( I% I-rwxr-xr-x    1 root     root         12257 Nov 15  2018 dbus-update-activation-environment
* \+ }) s' ~! V) f$ N% ~7 J-rwxr-xr-x    1 root     root          8365 Nov 15  2018 dbus-uuidgen
1 I% Y  Q6 b! ?; |3 W6 w4 A' t-rwxr-xr-x    1 root     root         33112 Nov 15  2018 gdbus; t+ m0 s6 f. q4 P$ o. B
-rwxrwxrwx    1 root     root         12332 Nov 15  2018 lxc-attach
1 X6 F. I: Q- r1 ^1 `-rwxrwxrwx    1 root     root         14241 Nov 15  2018 lxc-autostart- m. x3 n/ s4 X9 r
-rwxrwxrwx    1 root     root          9122 Nov 15  2018 lxc-cgroup
2 B+ z9 h, Q2 _1 X# B( j-rwxrwxrwx    1 root     root          4414 Nov 15  2018 lxc-checkconfig0 P+ c+ ?% o9 K
-rwxrwxrwx    1 root     root         10175 Nov 15  2018 lxc-clone
  L1 {3 S8 r4 a$ z8 c: p6 U& M-rwxrwxrwx    1 root     root          6181 Nov 15  2018 lxc-config
$ x( S" H  y5 y+ x; [* B6 i-rwxrwxrwx    1 root     root          8590 Nov 15  2018 lxc-console
3 |+ D  S1 Q3 E# Z- @5 e4 U-rwxrwxrwx    1 root     root         14556 Nov 15  2018 lxc-create
3 m& u/ h4 N! _% C-rwxrwxrwx    1 root     root          8540 Nov 15  2018 lxc-destroy
6 P9 _- ?) k2 o7 r/ \: r-rwxrwxrwx    1 root     root         10027 Nov 15  2018 lxc-execute
. W0 l1 O! E1 ^/ K-rwxrwxrwx    1 root     root          8630 Nov 15  2018 lxc-freeze" E5 j! j  J& @; X, F# e
-rwxrwxrwx    1 root     root         18956 Nov 15  2018 lxc-info
% `4 d4 _& G6 T9 F/ _4 n, H! d8 ^-rwxrwxrwx    1 root     root          2834 Nov 15  2018 lxc-ls
) @( S5 p3 U  S) C  T3 i-rwxrwxrwx    1 root     root         11122 Nov 15  2018 lxc-monitor+ i( {/ }) R+ {/ N* ~* d  a
-rwxrwxrwx    1 root     root         12270 Nov 15  2018 lxc-snapshot, K$ O' O. F6 m& D# ]
-rwxrwxrwx    1 root     root         15356 Nov 15  2018 lxc-start
, ?. C4 U/ k2 f% }# M9 m' K-rwxrwxrwx    1 root     root         10055 Nov 15  2018 lxc-stop) G" P, b, I+ j/ H+ M
-rwxrwxrwx    1 root     root          8634 Nov 15  2018 lxc-unfreeze0 a; O& M7 `- y( _# R8 ?  }
-rwxrwxrwx    1 root     root         12380 Nov 15  2018 lxc-unshare
3 Y0 C+ A, M* |/ z% o: ^-rwxrwxrwx    1 root     root         13324 Nov 15  2018 lxc-usernsexec
6 F6 m' l, d3 i8 B+ P# w; V) P5 I-rwxrwxrwx    1 root     root          8561 Nov 15  2018 lxc-wait
  1. root@F650A:~ # lxc-config -l. k' X+ E; T; M' u5 l: O
  2. lxc.default_config
    - r4 w% Y- I8 n
  3. lxc.lxcpath
    / d" I8 c: L' p8 e, e0 z# j
  4. lxc.bdev.lvm.vg# Q6 `! K8 w8 n7 f
  5. lxc.bdev.lvm.thin_pool
    6 E# i5 P6 Z" {/ V' h
  6. lxc.bdev.zfs.root# o) @" c. P3 G2 W& G7 Y
复制代码
  1. root@F650A:~ # lxc-config lxc.default_config
    2 {$ k& g% j) W0 M
  2. /usr/etc/lxc/default.conf: C" @7 x) e4 a$ p& `3 A  q
复制代码
  1. root@F650A:~ # lxc-config lxc.lxcpath
    6 S3 o& `3 E1 p$ ~1 {- H
  2. /usr/var/lib/lxc
复制代码
5 o9 n. \5 Q. ~
    了解系统运作机制之后,我最初打算借用saf方式管理容器,将 mtd6 分区用 'dd' 命令输出到U盘,Ubuntu下'unsquashfs',然后用官方版openwrt中的 /bin、/sbin、/usr 、/lib 等替换 mtd6 中rootfs下相应文件后 'mksqushfs' 再回光猫 'mtd write' ,但只在15.05.1版本中成功,怀疑是因为从17.01版本开始,openwrt的libc用 musl 取代了15.05及之前的 uClibc,导致saf运行所需的appmgr等程序无法正常运行。鉴于此,索性完全抛弃saf,以lxc方式开启新世界,操作步骤在本文回复中细谈。2 A  i1 A: V7 L8 v- V( T; c; F
    经过几番折腾,已将系统原有的openwrt中兴定制版saf子系统完全替换为官方openwrt19.07.1(lxc方式启动),不影响光猫拨号且可在线安装及更新非kmod类app,如ariang离线下载,samba文件共享,甚至各类科学上网工具(性能及安全原因不推荐)。
8 Q( s2 V& l  @2 p" G5 O% v/ K. P' y, T- t

" M' W+ J  }1 I+ _: @4 J4 V: b7 u. ]# i1 C6 n

+ u8 U2 E! T0 j1 N8 s" |9 C
' ?/ k+ F4 S. s# O) o: H6 K# {/ N5 e0 m/ D
0 a5 ?1 G! A/ ]# `/ u: O  ~

本帖子中包含更多资源

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

×
 楼主| 发表于 2020-2-19 14:34:03 | 显示全部楼层

简化并更新OpenWRT22.03.0 RC1版本

本帖最后由 songee 于 2022-4-26 23:39 编辑
/ H$ J% c7 [% ]0 q7 t$ e- n# ]- Z$ v! X0 c
因二楼原帖过程过于繁琐,近期尝试了一种较为简单的办法。1 z% o- ]) ?! c9 x# _. L6 ]0 M) r
- A/ P2 ^+ o3 a6 p: m% |+ x! d6 v
2 ^0 L7 ?# `/ _6 J% N8 V, D) d
1、下载openwrt.org固件,我选的是openwrt-22.03.0-rc1-bcm53xx-generic-tenda_ac9-squashfs.trx,binwalk分析squashfs偏移量并用dd取出,unsquashfs提取rootfs,打包为rootfs2203rc1.tar.gz,传入光猫临时目录,如 /run/shm 。: F, F: E( t' u  m' T4 c

+ W& e8 m' n  G6 N' I% k2、将rootfs2203rc1.tar.gz提取至 (lxc-config lxc.lxcpath)/openwrt/rootfs 。* O. j( L5 P5 d: d
  1. root@F650A:/usr/var/lib/lxc/openwrt/rootfs # tar -xzvf /run/shm/rootfs2203rc1.tar.gz -C ./
复制代码

1 z  s$ {5 x! j: |2 |* X5 f8 X5 m$ g- J+ V- B3 z
3、修改rootfs。openwrt的网络配置与主系统有冲突,需要清除。' o* d6 O: F7 s# h( C* I; a/ L, G
    3.1 移除 ./etc/board.d/ 目录下 01_leds 、02_network 、99-default_network 三个文件。
4 W* a- ?* W+ T, g) @% G    3.2 移除 ./etc/rc.d/ 目录下 K21wpad 、K85odhcpd 、K90network 、S19dnsmasq 、S19firewall 、S19wpad 、S20network 、S35odhcpd 、S96led。
8 L. |$ x' I* o; [- E% U    3.3 移除 ./etc/modules.d/ 和 ./etc/modules-boot.d/ 及 ./lib/modules/5.10.111/目录下所有文件,openwrt的kernel modules与光猫内核不兼容。- {( Q" Y$ r% ^6 q0 b. ^
% L0 [6 }3 h2 b/ b* U- U8 [. B! D
    3.4 修改opkg源 ./etc/opkg/distfeeds.conf(可选)4 p% [& x! Y& o% J  ^
  1. src/gz openwrt_core https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/targets/bcm53xx/generic/packages
    " y5 I; G: B$ {
  2. src/gz openwrt_base https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/base7 k+ ?  V2 h3 `3 ~
  3. src/gz openwrt_luci https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/luci+ S0 h" L9 M1 k+ H
  4. src/gz openwrt_packages https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/packages
    " l2 D; _# p+ \2 j$ D
  5. src/gz openwrt_routing https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/routing% B: Y# t- n7 C) h
  6. src/gz openwrt_telephony https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/telephony
    . c; r8 @, Q# Q; V" C2 k6 R
复制代码
  3.5 修改 ./etc/inittab 实现启动项自启(参考https://github.com/mikma/lxd-ope ... r/files/etc/inittab
2 A1 D1 E" n! T
  1. ::sysinit:/etc/init.d/rcS S boot1 B+ t, n: I, x/ z8 z
  2. ::shutdown:/etc/init.d/rcS K shutdown& _! e/ l+ i1 \# S
  3. console::askfirst:/usr/libexec/login.sh
复制代码
  3.6 修改密码 ( root 密码 chinadsl- c1 L3 K4 U1 i, m
  1. root@F650A:/usr/var/lib/lxc/openwrt/rootfs # chroot ./) B! R, }( Z- a5 V1 r- F. J$ u2 G) Z: k
  2. : i( R- K, L# M8 Q4 {
  3. 3 v. x" B2 Q5 g
  4. BusyBox v1.35.0 (2022-04-20 10:37:37 UTC) built-in shell (ash)+ @& w2 }7 {; V; P: T. l

  5.   Q; [: d5 H; C4 u9 E( ~, G' F
  6. root@F650A:/ # passwd
    4 `& n2 X7 V% O% P$ u9 S
  7. Changing password for root) ^4 [$ v3 l- Z* l
  8. New password:
    5 V( {& [6 S1 r& r5 R% c
  9. Bad password: too weak
    - U! C7 D" @& J$ ]4 @
  10. Retype password:
    ; Z% y* u7 J9 i8 c! B
  11. passwd: password for root changed by root
复制代码
  3.7 删除 ./etc/resolv.conf 软连接并新建./etc/resolv.conf,否则openwrt无法解析域名
* n- g) i7 }! H( p: @
  1. nameserver 223.5.5.5
    " @+ B4 X6 D. O4 h8 W& |% S1 }
  2. nameserver 2001:da8::666
    # ]- |  e% s/ X8 a) }
复制代码
4 z- |6 t+ d8 o' n5 w2 `1 d  ~

+ R# n6 q% Y# F3 O% K7 V$ _4、修改lxc配置文件 /usr/var/lib/lxc/openwrt/config ,根据各自光猫环境修改测试,这个配置我的F650A可正常使用。. b- K( B4 t2 Q
  1. lxc.arch = arm
    1 q9 X/ i- Y( T, k
  2. lxc.utsname = openwrt
    2 S) ~: ^% G; W% y% S
  3. #lxc.rootfs.mount = /usr/var/lib/lxc/openwrt/rootfs
    8 f* p# [( v8 ^; ?  u4 H" e
  4. #lxc.rootfs.path = overlayfs:/opt/upt/framework1/rootfs:/opt/upt/apps/openwrt-rootfs
    , s" u# L! h/ c6 G1 q0 @1 A. g7 ]
  5. lxc.rootfs = /usr/var/lib/lxc/openwrt/rootfs
    ( J# C8 y3 @, v
  6. lxc.haltsignal = SIGUSR1; f/ P+ Z) e0 o' U9 S9 w% D
  7. lxc.tty = 1
    ( l; h2 o/ Y* ]7 Z
  8. lxc.pts = 1$ X. |$ z5 _4 f$ X9 w" V
  9. #lxc.hook.pre-start = /usr/var/lib/lxc/openwrt/pre-start.sh9 |0 [: G* Y& p
  10. lxc.aa_profile = lxc-container-default-with-nesting& B( R2 |% I1 b% p  X7 N1 J* V
  11. lxc.network.type = none
    8 v6 A2 E9 i+ }/ f$ {* Z3 ~5 o( w
  12. lxc.mount.auto = cgroup-full:rw' j, w; n2 _/ c: E" B8 M- T; g
  13. #lxc.mount.auto = proc sys cgroup
    . w) C3 w. J& p# B
  14. lxc.mount.entry = sysfs sys sysfs defaults 0 0$ [% ?; {  ?; X7 M$ V9 k, t/ Z
  15. lxc.mount.entry = proc proc proc defaults 0 0
复制代码

; Q% @9 ^: q( s2 w, ^# W2 h, \3 G; w
5、启动,根据提示按enter进入控制台。
3 Z! d/ M- r0 [/ ?0 Z% ?9 I; |! t
  1. root@F650A:~ # lxc-start -n openwrt0 @% _/ U# S8 ?' f+ Z
  2. <6>init: Console is alive  `7 N/ ]+ o5 J2 ^/ x
  3. <3>init: Failed to redirect stdin to /dev/null: No such file or directory- R% n/ ^4 K+ W7 M8 l
  4. <3>init: Failed to redirect stdout to /dev/null: No such file or directory& S5 e$ ?0 h  z2 i9 z: `" X; V
  5. <3>init: Failed to redirect stderr to /dev/null: No such file or directory3 Y1 a7 ]7 E+ c7 }
  6. <6>kmodloader: loading kernel modules from /etc/modules-boot.d/*
    $ @- @4 x0 [& @5 Q
  7. <6>kmodloader: done loading kernel modules from /etc/modules-boot.d/*
    - u3 F. R* V4 E' L! l. l
  8. <6>init: - preinit -
    ' x% c7 b2 @" q" @' w
  9. ls: /etc/board.d/*: No such file or directory
    4 A2 \/ k$ B- a$ i
  10. Press the [f] key and hit [enter] to enter failsafe mode: K3 u4 y5 H& {) s$ g
  11. Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level" i8 s: p% y5 T. H& O6 _+ A
  12. <3>mount_root: Could not open mtd device: /dev/mtd12) a/ G6 [8 V% R2 I0 z
  13. <3>mount_root: reading rootfs failed- q% P; k$ N- q
  14. <5>mount_root: mounting /dev/root! B+ N7 S# m' k' d
  15. urandom-seed: Something is wrong with /dev/urandom9 ]) C+ V. W+ x7 N
  16. <6>procd: - early -
    ) w) B: h2 w6 I. T( C8 F
  17. <6>procd: - ubus -! s" |3 ~9 W! H' Z
  18. <6>procd: - init -- _% @/ g2 x4 ~" S$ U& l
  19. Please press Enter to activate this console.: j: A) \2 n* W# N
  20. <6>kmodloader: loading kernel modules from /etc/modules.d/*# L% C4 ~$ i: b9 w; E% U  Y
  21. <6>kmodloader: done loading kernel modules from /etc/modules.d/*
    " N% `; H" J0 q: _
  22. <6>urngd: v1.0.2 started.' U/ i2 O9 j8 ?/ f

  23. 9 L3 V5 q5 H/ d0 D* n% C

  24. % E: p- @2 H( i. I5 X3 y  {# {- |" h

  25. : y1 @' |! Z' m* l/ W% F
  26. BusyBox v1.35.0 (2022-04-20 10:37:37 UTC) built-in shell (ash)
    5 i5 |0 X: G9 a/ l" H5 }

  27. . s; j1 `7 Q- k, X* R! z: E
  28.   _______                     ________        __* M0 d3 |8 C' J
  29. |       |.-----.-----.-----.|  |  |  |.----.|  |_
    4 A% A( }* D* p; L/ b. @1 M  ^4 \
  30. |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
    ( w  _' O5 S* {. O
  31. |_______||   __|_____|__|__||________||__|  |____|8 K0 c8 j) F0 n) `+ ~2 B0 {: ^
  32.           |__| W I R E L E S S   F R E E D O M
    7 V; R% _7 ^( H! N, I- X
  33. -----------------------------------------------------* I" `6 ]2 m  ?1 M% {
  34. OpenWrt 22.03.0-rc1, r19302-df622768da
    8 u3 n0 a2 U, H! ~5 `
  35. -----------------------------------------------------
    5 M2 z" l/ {/ _. o
  36. root@openwrt:/#
复制代码
* \3 o7 R7 a+ N: W; v: \
7 n+ k0 J; h$ a$ G! h0 B  W* d/ _9 {$ Y
  1. root@openwrt:/# ps" X2 S- B7 b  z- V, y9 a
  2.   PID USER       VSZ STAT COMMAND
    8 _5 c* x* g* p+ u
  3.     1 root      1452 S    /sbin/procd
    4 w5 E* w  I/ ?) W( w. x. x
  4.    58 ubus      1112 S    /sbin/ubusd, ^& e5 I0 p; K0 z% G3 A& A8 P
  5.    59 root      1196 S    /bin/ash --login; ?9 ^  X; [- `! d
  6.    93 root       908 S    /sbin/urngd
    $ k* P: W( Z9 f
  7.   204 root      3736 S    /usr/sbin/uhttpd -f -h /www -r OpenWrt -x /cgi-bin -u /ubus -t 60 -T 30- p8 I0 ^. y1 ^# q* O* B9 y9 p& d
  8.   487 root      1952 S    /sbin/rpcd -s /var/run/ubus/ubus.sock -t 309 q. i4 _1 S7 p( e# ~1 p% J6 ?
  9.   556 root       956 S    /usr/sbin/dropbear -F -P /var/run/dropbear.1.pid -p 22 -K 300 -T 3
    9 C. P7 {* K  A4 w9 i: p
  10. 1065 root      1200 R    ps
    " V6 a9 c/ N( B8 O
  11. root@openwrt:/#
复制代码

& L, a$ m" A% y7 p" \5 T
9 F0 Y7 o5 u! i' Y: ]/ `$ Q/ }: _1 L) d* U
  1. root@openwrt:/# opkg update
    6 d. P2 {) b7 @0 `
  2. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/targets/bcm53xx/generic/packages/Packages.gz( w$ v4 l" m# a5 g# n
  3. Updated list of available packages in /var/opkg-lists/openwrt_core
    ) W1 m& f. s4 V2 Q9 k1 F1 ^8 m
  4. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/targets/bcm53xx/generic/packages/Packages.sig6 x! i) w7 y! p8 O" v* ?
  5. Signature check passed.  P# y& l2 ]3 U; }& o
  6. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/base/Packages.gz
    + p( b1 ?; k& t2 ]! f
  7. Updated list of available packages in /var/opkg-lists/openwrt_base6 K8 O' ?3 y* Z0 z0 i# f, n. G! e5 t
  8. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/base/Packages.sig
    & C) a- A/ j# o* V$ W
  9. Signature check passed.
    / G) ]+ \7 ]9 S- b/ k- q
  10. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/luci/Packages.gz
    % p4 H* q4 ^8 N9 b9 V1 w% f
  11. Updated list of available packages in /var/opkg-lists/openwrt_luci2 U  i% {4 V. W( P. `3 |* x. L
  12. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/luci/Packages.sig
    ) w" t$ H- @/ V& i: f5 k
  13. Signature check passed.
    6 m( w, _# q8 z! p$ m
  14. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/packages/Packages.gz1 H4 y  ]  ^8 S) a2 ~3 |
  15. Updated list of available packages in /var/opkg-lists/openwrt_packages5 ]8 _: h( c, J* e/ f3 \4 e" Q+ p
  16. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/packages/Packages.sig
    . M0 o5 x* D/ v6 e0 o
  17. Signature check passed.
    5 {9 S9 R2 N! I/ ^5 ^5 q2 T
  18. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/routing/Packages.gz! s& W: t8 U" D5 i' W+ H6 [
  19. Updated list of available packages in /var/opkg-lists/openwrt_routing
    7 y- S  \0 K5 f( ]
  20. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/routing/Packages.sig
    - |# W* b5 o& G3 p( y( N& _
  21. Signature check passed.0 I+ f! X) ~# y; D$ y, I
  22. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/telephony/Packages.gz
      h) ^! D$ K" {4 X  v5 S6 f4 `2 ~8 U" s) t
  23. Updated list of available packages in /var/opkg-lists/openwrt_telephony
    8 j, |* P% ~$ C1 x, b) M4 o6 J
  24. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/telephony/Packages.sig4 s0 a. F+ g6 O: X) `: ]
  25. Signature check passed.1 X! ]/ O+ {  s, @/ \
  26. root@openwrt:/#
复制代码

( e) ?+ r  |% u4 a3 l. l/ O, n- R
# T9 o: _# A) A  i, j% H此时临时的openwrt系统已建好,运行的服务有两个:http占用主系统的80和443端口,ssh占用22端口。9 j; _; f* E& o! V' `

/ |( C- S# }$ u% o1 M如果光猫有公网IP,请务必关闭ssh密码登录并使用密钥。
. F4 C9 v2 k, I: }' a+ U, C$ y
8 J# z: E2 X. [7 P3 G9 `8 L1 q后期使用建议使用 lxc-start -dn openwrt 后台启动,使用 lxc-stop -kn openwrt 命令关闭。openwrt管理使用ssh密钥登录。) ~8 c4 B( R2 {; A" O# S) K6 h
需要固化openwrt到固件的,可以打包rootfs和config(需修改配置),mksquashfs制作成squashfs,用mtd写入saf分区,就不用担心恢复出厂设置了。  u' M" @- X) G6 e* u
随光猫启动可以参考二楼。8 D4 G2 V' C) Z+ r: |( X4 l  Z

$ O" s! R) p; q. C1 F

本帖子中包含更多资源

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

×
 楼主| 发表于 2022-4-27 23:10:13 | 显示全部楼层
因光猫原系统的busybox功能不完整,也没有nano和dropbear,调试lxc可能会不方便,现分享出来。' f: _, T  [6 f; K

% N( B# O( S  H* D4 B: T! T2 p
  1. root@F650A:~ # /usr/bin/busybox5 `# x% x1 Q) B" i# W- B( c
  2. BusyBox v1.23.2 (2020-06-16 16:53:26 CST) multi-call binary.
    8 U/ G* Q+ @4 x( ]
  3. BusyBox is copyrighted by many authors between 1998-2012.
    3 B; Y# @2 e$ X  I6 r+ v) y* k- ^
  4. Licensed under GPLv2. See source distribution for detailed3 g+ }2 P4 N* ^% ^
  5. copyright notices.
      r- y- J7 p$ b: o2 }& e- k$ R
  6. & b- d: R* K8 D2 Z9 y0 v$ m: a
  7. Usage: busybox [function [arguments]...]5 j. c1 |, N  k( w, z8 p
  8.    or: busybox --list[-full]
    - g/ B* }( Y; C( N. @
  9.    or: busybox --install [-s] [DIR]7 A0 _& [% w* i/ _
  10.    or: function [arguments]...) O8 M" _5 E% k

  11. ( }; l! F# w3 S1 r  p
  12.         BusyBox is a multi-call binary that combines many common Unix3 v: d) k) M" U2 Q9 k& \! {6 ?
  13.         utilities into a single executable.  Most people will create a
    " @/ }$ c0 Y3 u( s2 Q8 K
  14.         link to busybox for each function they wish to use and BusyBox$ f6 s1 l, X5 t; ]# ]
  15.         will act like whatever it was invoked as.
    ' l; q5 J( c' {$ W0 v7 {
  16. $ F* y& N& T9 y) ]7 u6 s4 g* _/ t6 b
  17. Currently defined functions:( X# Y9 {7 u! |2 ?# e; W8 d
  18.         [, [[, addgroup, adduser, ar, arp, arping, ash, awk, basename, blkid, brctl, bunzip2,3 _; K4 X3 Z1 V( P0 g0 N
  19.         bzcat, cat, catv, chattr, chgrp, chmod, chown, chroot, chrt, chvt, cksum, clear, cmp, cp,
    1 l* @* X* ?  {# ?; c+ n/ D1 V1 `
  20.         cpio, crond, crontab, cut, date, dc, dd, deallocvt, delgroup, deluser, depmod, devmem, df,6 n: U+ G- Y0 u+ g, r
  21.         diff, dirname, dmesg, dnsd, dnsdomainname, dos2unix, du, dumpkmap, echo, egrep, eject, env,
    6 q. U3 l8 R# D* v
  22.         ether-wake, expr, false, fbset, fdflush, fdformat, fdisk, fgrep, find, flock, fold, free,3 i! ?: R; k! w8 k
  23.         freeramdisk, fsck, fstrim, fuser, getopt, getty, grep, gunzip, gzip, halt, hdparm, head,7 V# R3 L5 L7 U5 ?+ J' L' u" O6 M
  24.         hexdump, hostid, hostname, hwclock, id, ifconfig, ifdown, ifup, inetd, init, insmod,* K. ~0 W3 R2 e
  25.         install, ip, ipaddr, ipcrm, ipcs, iplink, iproute, iprule, iptunnel, kill, killall,
    5 B3 I7 f& M& C; M$ e: q
  26.         killall5, klogd, last, less, linux32, linux64, linuxrc, ln, loadfont, loadkmap, logger,
    ! B6 N$ _2 ~& e7 l, x% i" [" j
  27.         login, logname, losetup, ls, lsattr, lsmod, lsof, lspci, lsusb, lzcat, lzma, makedevs,, y3 r& A, ?6 a
  28.         md5sum, mdev, mesg, microcom, mkdir, mke2fs, mkfifo, mkfs.ext2, mknod, mkswap, mktemp,
    8 m" u; t6 @: k8 C- I; R
  29.         modinfo, modprobe, more, mount, mountpoint, mt, mv, nameif, nanddump, nandwrite, netstat,, o% i% i2 F3 Z3 |9 ~# x6 l+ E
  30.         nice, nohup, nslookup, od, openvt, passwd, patch, pidof, ping, pipe_progress, pivot_root,# l2 Z0 K: m1 m" i
  31.         poweroff, printenv, printf, ps, pwd, rdate, readlink, readprofile, realpath, reboot,
    $ y' k7 C3 c8 x' ?: x: y
  32.         renice, reset, resize, rm, rmdir, rmmod, route, run-parts, runlevel, sed, seq, setarch,8 D( T& l+ X5 C: W
  33.         setconsole, setkeycodes, setlogcons, setserial, setsid, sh, sha1sum, sha256sum, sha3sum,
    9 U. @5 p0 h4 V, h4 m
  34.         sha512sum, sleep, sort, start-stop-daemon, strings, stty, su, sulogin, swapoff, swapon,
    2 G$ n+ ?$ w7 q, \% J
  35.         switch_root, sync, sysctl, syslogd, tail, tar, tee, telnet, telnetd, test, tftp, time, top,
    9 b, O7 |" l' b# s! E- v) I
  36.         touch, tr, traceroute, traceroute6, true, tty, ubiattach, ubidetach, ubimkvol, ubirmvol,9 ~+ z$ X2 r" \
  37.         ubirsvol, ubiupdatevol, udhcpc, umount, uname, uniq, unix2dos, unlink, unlzma, unxz, unzip,$ x( f% `7 l' U. ~2 d. w
  38.         uptime, usleep, uudecode, uuencode, vconfig, vi, vlock, watch, watchdog, wc, wget, which,1 i3 S1 s' g0 u! w+ a3 \
  39.         who, whoami, xargs, xz, xzcat, yes, zcat! ]( I! ~+ v; X

  40.   r7 Q; K+ ~0 }9 O/ A( N- ?4 q
复制代码
  1. root@F650A:~ # nano -h! k; e0 _+ V* o& M1 C. u/ r' A
  2. Usage: nano [OPTIONS] [[+LINE,COLUMN] FILE]...
    9 g, U. V/ D  T
  3. , v5 E! k8 k& {% }) W8 C
  4. Option          GNU long option         Meaning& v* q4 B" l3 F% \5 n
  5. +LINE,COLUMN                           Start at line LINE, column COLUMN
    / t  }& g+ ]6 d, Q) q  A# G8 ^
  6. -D             --boldtext              Use bold instead of reverse video text
    % l: \0 Z; L. m) Q5 k& s+ F
  7. -K             --rebindkeypad          Fix numeric keypad key confusion problem
    % D' y) K2 S0 r9 D4 L& J
  8. -L             --nonewlines            Don't add newlines to the ends of files$ j7 U  F6 {  `0 u
  9. -O             --morespace             Use one more line for editing
    4 I4 ^5 h; l- v! g3 U
  10. -R             --restricted            Restricted mode
    ; t  T; M& J7 J: H! y
  11. -T <#cols>     --tabsize=<#cols>       Set width of a tab to #cols columns
    4 K' {; t. u- D
  12. -V             --version               Print version information and exit
    & G) G8 @' m/ n# n" H. Y
  13. -c             --const                 Constantly show cursor position
    9 W; ^; Q( w# ?
  14. -d             --rebinddelete          Fix Backspace/Delete confusion problem! }$ d: ~; r) P
  15. -h             --help                  Show this help text
    : _. K4 }0 b- N/ W8 ^, d: p) A/ W) Z
  16. -l             --nofollow              Don't follow symbolic links, overwrite! B: y1 p% \" @6 M# q7 E% N- K4 ]
  17. -n             --noread                Do not read the file (only write it)
    : V' _, z0 |  F6 m- y7 ~
  18. -p             --preserve              Preserve XON (^Q) and XOFF (^S) keys3 ^" I/ N+ g1 `: _7 L
  19. -t             --tempfile              Auto save on exit, don't prompt# Y' D9 o; `5 q$ ?2 @# i6 x( W
  20. -v             --view                  View mode (read-only)
    / R5 d! z- D3 B, g
  21. -x             --nohelp                Don't show the two help lines
    + T$ L! Z* P0 A( C) s
  22. -z             --suspend               Enable suspension. m1 A+ d( I% t9 w6 p, T9 }4 I
  23. root@F650A:~ # nano -V: C( P4 e) T& j$ Q- m, W, P
  24. GNU nano, version 2.4.21 T- `3 ?% }9 B- F
  25. (C) 1999..2015 Free Software Foundation, Inc.
    # f/ p2 k) m+ K3 g6 w* C( u
  26. Email: nano@nano-editor.org    Web: http://www.nano-editor.org/
    % N8 j, b. U6 ~2 ~1 H% S
  27. Compiled options: --enable-tiny --disable-utf8* `: _( H3 X* d6 G2 w
复制代码
  1. root@F650A:~ # dropbear -h
    & _4 T/ m' _; x
  2. Dropbear server v2015.67 https://matt.ucc.asn.au/dropbear/dropbear.html
    + A8 L4 J. D+ m
  3. Usage: dropbear [options]
    ( s, f. l4 p4 ?
  4. -b bannerfile   Display the contents of bannerfile before user login
    5 X4 \0 I* j5 `0 R  o, m
  5.                 (default: none)
    8 z( p+ j' X- m& b* h  M
  6. -r keyfile  Specify hostkeys (repeatable)# z: {8 M% z# V/ x( v* F2 ]
  7.                 defaults:
    . q$ @9 p& z7 i
  8.                 dss /etc/dropbear/dropbear_dss_host_key, T# |) O+ O5 P" R; m
  9.                 rsa /etc/dropbear/dropbear_rsa_host_key& ^; A0 P/ Z6 X1 x" B. V
  10.                 ecdsa /etc/dropbear/dropbear_ecdsa_host_key
    2 y; T( |% D# V! ^
  11. -R              Create hostkeys as required  N) u" v$ i% k& Q3 x
  12. -F              Don't fork into background
    . _/ W" S; @8 q, x  G
  13. -E              Log to stderr rather than syslog) C0 j2 p1 i9 O0 J
  14. -m              Don't display the motd on login& a8 G. Y4 [$ A1 c
  15. -w              Disallow root logins
    # o, w) }  O3 {% L  w4 T* h
  16. -s              Disable password logins
    8 I+ O4 u, C* e( ?0 W# r6 s
  17. -g              Disable password logins for root
    - E4 M4 b' ]6 w" g! f. P) R
  18. -B              Allow blank password logins
    , D7 m. C3 u" b: i
  19. -j              Disable local port forwarding9 h. u/ H$ [( j7 Y* C( T
  20. -k              Disable remote port forwarding
    7 K0 W* v4 _! K" S
  21. -a              Allow connections to forwarded ports from any host/ P! W4 @0 a, z5 d* P9 [- M
  22. -p [address:]port2 M4 z$ y; [) `0 }" o; C) ]
  23.                 Listen on specified tcp port (and optionally address),
    + d9 N! P) m! \( u/ i! E
  24.                 up to 10 can be specified
    $ w+ q& u9 H$ T, \- ?' g
  25.                 (default port is 22 if none specified)
    9 l0 o: W( J# U1 d" J  E! Y. W6 x. |
  26. -P PidFile      Create pid file PidFile- a" L0 T& ~+ A# Q) l
  27.                 (default /var/run/dropbear.pid)4 U. B. N, [  t" T) Q( a+ b
  28. -i              Start for inetd, E. h9 ~/ Z- J+ V  o
  29. -W <receive_window_buffer> (default 24576, larger may be faster, max 1MB)
    ' V! P+ ]3 H4 |. `
  30. -K <keepalive>  (0 is never, default 0, in seconds)$ h5 }$ \' _$ g& z7 K
  31. -I <idle_timeout>  (0 is never, default 0, in seconds)% }- Q# |# J( B% K) O& T
  32. -V    Version
    ) |1 b: A* F9 A# J# V
复制代码
3 x" J$ B8 S& r7 g

' E# D7 e8 {' U* ~( W3 j7 O

本帖子中包含更多资源

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

×
发表于 2021-11-27 21:38:54 | 显示全部楼层
本帖最后由 btworm 于 2021-11-27 21:41 编辑
5 M% ^# M. s6 P! B. R* m
songee 发表于 2021-11-27 04:15; X* \4 Z5 F5 p2 N2 m+ r
1.只要lxc相关命令可以正常运行,写好配置文件,选择符合CPU架构的rootfs,就可以把容器跑起来。9 V4 v% ~% T6 e; J1 L# y& V
2.我的 ...
! Y. X8 d- J( y& d  _+ R0 ]$ j
感谢指点!
3 I- H% A* y; h4 q9 h5 |$ t! o: i! v' C6 o6 _8 I
关于第2点
6 T+ s9 y, ]# U; j* v华为光猫 / 只读,/etc,/usr,/lib这些目录也都依附于/, 所以都不可写, /opt目录不存在,当然也无法创建。7 g( D- t- n  ], Y$ h

" [* @4 H1 S+ I, \1 e之前担心/dev/pts, /proc, /sys只读,是因为以前玩路由器时,有个chroot脚本使用过这些目录,刚又看了遍那个脚本,使用的是 "-o bind"参数,所以主机目录是否可写就无所谓了。在华为猫上跑lxc应该没问题了
% f, n' T3 P3 Z6 |( a
$ m7 z2 H( ^" l4 \2 @另外想问问,光猫容器内的应用对端口的监听是:8 T. U  @. Z' }, ^* I' W
1.直接监听光猫的端口?
7 [7 g' ^: Q; p/ V- J2.还是只能监听容器内的端口,并需要光猫iptables做端口转发给容器?
 楼主| 发表于 2020-2-22 18:37:10 | 显示全部楼层
anysoft 发表于 2020-2-22 17:50# E+ V3 A  @1 @9 v' v
HS8145V HS8145V5  F650A 都是512MB+256MB 2.4G+5G方案
# A! m& ^9 t, g* k; u3 ~价格都还好,特别F650A 因为会玩的人少价格特别便 ...

. @# Z4 J3 i% I0 X4 ?hs8145v技术成熟,更适合玩,而且其实f650a是512/128,nand flash少了一半,CPU一个尿性,价格差别不大的话,能hs8145v还是别选650。
0 w" Q, e. \9 t( m' F" }- v还有个大胆想法,lxc可以通过配置文件config修改子系统网络,从eth0桥接是不是就能在子系统多拨了,子系统专门离线和网络存储,不影响猫后面接的手机电脑上网,还是蛮有趣的
) `0 R! F8 b0 b4 a
9 z; V& O2 t! |
8 y0 z. t0 N5 K; {( x( D1 T* d( K4 b' r* d
 楼主| 发表于 2020-2-17 02:19:26 | 显示全部楼层

二楼原帖,仅保留做参考

本帖最后由 songee 于 2022-4-27 21:17 编辑   C$ V  R* t6 z7 ]5 E7 W6 {8 p
1 j" s' G9 d; d  P
/ E0 {2 m5 P! ]" p( U5 M
(2020年原帖初步摸索,过程过于繁杂,不建议再按这部分思路操作)$ o" I+ F; e8 F5 k
中兴、华为等带有saf模块的光猫,以官方版openwrt替换厂商定制版的思路总结一下,供大家参考。
' d- A+ k2 Y+ d0 k1、准备工具
' `) q2 g4 T& g! o# K+ x: j8 T    F650A主系统没有 mtd 、 dd 和 vi 等工具,而自带的saf子系统正好都有,子系统位于framework分区即mtd6,挂载于/opt/upt/framework,cp过来可以直接使用。
root@F650A:~ # cp /opt/upt/framework/saf/rootfs/sbin/mtd /usr/bin/5 q, |# j8 y0 Y9 V5 A& W
root@F650A:~ # cp /opt/upt/framework/saf/rootfs/lib/libubox.so /lib/
; B$ D) E  J  S" d$ p# x9 Oroot@F650A:~ # cp /opt/upt/framework/saf/rootfs/bin/busybox /usr/bin/5 Y! Q+ {- K( P6 e. E9 R/ f
root@F650A:~ # cd /usr/bin/  B0 b  h1 f6 {* n- s
root@F650A:/usr/bin # ln -s busybox dd% m/ J2 s; _; u- |$ s
root@F650A:/usr/bin # ln -s busybox vi

) O2 E& \$ P. P: l( t2、改进lxd-openwrt生成代码。* @9 x# v1 N; C* m
    本节参考https://github.com/mikma/lxd-openwrt,系统推荐Ubuntu 18.04以上。目前该项目支持x86_64|i686|aarch64架构,而F650A的CPU型号 ZTE ZX279128 的架构是 ARMv7 Processor rev 1 (v7l) ,不属于以上三种,只能调整build.sh部分代码。ZX279128架构bcm53xx的相同,借用它的SDK。可以git clone 或者网页内 Download ZIP,我浏览器挂的有代理,网页下载之后解压,修改build.sh。修改后的build.sh与原文件build.sh.origin的diff如下
3 F- F! e4 p. i- Q4 F
*** build.sh                2020-02-19 01:50:10.972675562 -0100
" f/ G, P' ~0 E2 r; b--- build.sh.origin        2020-02-14 19:10:45.000000000 -0100
$ l: u4 n* W+ V***************0 S0 `* z' o# X. f/ ?* L- s. u$ ?4 g
*** 72,81 ****
' G; l* l6 a, L6 G- g4 |& \. U                  subarch=64
5 E# R/ Q4 r4 V* t. I1 s                  arch_ipk=x86_64
2 T, T( W6 x7 |; r, D                  ;;" {5 Q# d; _9 h" o8 C0 O1 h* m  C
!         arm)
* N5 y: F+ z4 O9 n- v3 @!                 arch=bcm53xx; C, c* f; U- \, j
!                 subarch=generic" ^% N% w4 M5 e& d) W+ U' q
!                 arch_ipk=arm_cortex-a9% B) c3 O( P& ^1 B& C
                  ;;
" D+ e/ \! U: p          *)
# N& a: Q# v0 k- ^& ~                  usage3 k' M. t% T+ }
--- 72,81 ----
) b! m% x* H/ b                  subarch=64
- H4 L) R! `. g; [                  arch_ipk=x86_64* [; E4 e2 ~7 D1 G# J
                  ;;7 x# n. j- _1 a% d
!         aarch64)3 x, C& y, R# J1 d5 n" i8 [
!                 arch=armvirt- z, g! m- b* {7 y  J0 P
!                 subarch=645 j* q/ o# x, l$ O  L* C. t* Z/ S
!                 arch_ipk=aarch64_generic9 h. p; B, v+ [5 Q, g' _7 a/ G; l
                  ;;
" ?* z. c1 B2 t$ k# N          *)/ D/ g) {$ ?) g! w$ I# W
                  usage( o7 Y; s  u+ i) Q1 t- h
***************
/ T  j5 o6 o" m4 H*** 87,97 ****$ r3 F: B& C) t; k1 A) `3 X
  if test $ver = snapshot; then1 h: t, n2 P3 Y) ?8 Z
          openwrt_branch=snapshot* q3 `! r, `) Q
          procd_url=https://github.com/openwrt/openwrt/trunk/package/system/procd' x5 W( @  J* [, d
!         openwrt_url=https://mirrors.cloud.tencent.com/lede/snapshots/targets/${arch}/${subarch}) m% x5 c  c+ Q" J
  else
# r* G1 A3 U. I  x7 D8 l. e          openwrt_branch=${dist}-${branch_ver}; p  \' ?; B3 i  X
          procd_url=https://github.com/openwrt/openwrt/branches/${openwrt_branch}/package/system/procd3 D  O6 p$ l. h7 c
!         openwrt_url=https://mirrors.cloud.tencent.com/lede/releases/${ver}/targets/${arch}/${subarch}
( p9 |6 y: @- g, \& m/ L2 Z2 ^  fi
, }7 O8 O/ {$ ]: g  6 J. W: n, F8 m0 U* Q# Z  ]! y' U
  procd_extra_ver=lxd-3
! W2 V9 H. T/ p2 \5 b--- 87,97 ----6 h0 Z6 E' H! ~/ W* }# N
  if test $ver = snapshot; then) p: h& _" }% V" z+ z
          openwrt_branch=snapshot5 i: k( o8 [- T- U
          procd_url=https://github.com/openwrt/openwrt/trunk/package/system/procd
7 H: X( n2 t5 o+ `$ A$ M!         openwrt_url=https://downloads.openwrt.org/snapshots/targets/${arch}/${subarch}
2 G- n/ D8 f1 k+ S9 L4 p  else
* k4 c3 J8 x+ |) C1 k- |, _! y5 ~          openwrt_branch=${dist}-${branch_ver}6 t7 q) a- h2 p' l- D
          procd_url=https://github.com/openwrt/openwrt/branches/${openwrt_branch}/package/system/procd9 T. Z& _  n3 q: A3 N
!         openwrt_url=https://downloads.openwrt.org/releases/${ver}/targets/${arch}/${subarch}
# R+ o5 G# \/ r/ ?  fi; M4 U' J& t! Z& Y5 E  l1 s
  / N, k7 `$ ]5 n' R; C
  procd_extra_ver=lxd-3
% `; m* c2 {; _% q1 p***************0 |1 k% |' Z9 w' J* k5 ^. s) p1 w! t
*** 112,125 ****- F% ?. t1 x& e6 w. V+ W
  }
. Z3 S8 A( j  m/ `  5 |8 s2 B4 f3 U  M3 `# P
  download_rootfs() {; x& x- p7 b6 Z
! #        detect_url "rootfs\.tar") {% o+ D+ D* j8 Y, |. o
! #        local rootfs_url=$openwrt_url/$return
9 k6 X6 E1 }" `' l  ) _( T/ W& e, i$ L/ V. l
          # global $rootfs* J" h' K9 x* e' B$ `) _% W7 Q
!         rootfs=dl/openwrt-19.07.1-bcm53xx-generic-rootfs.tar.gz' q2 e1 P, x* M0 U1 |
  ) `. ?) J& [' i
! #        download $rootfs_url $rootfs $rootfs
0 ?: t& L" I# r" n% _$ j9 R* L! #        check $rootfs $rootfs_url
9 @3 s/ m4 h" T9 j* H+ F0 _- ]  }+ M$ V5 Z/ q3 v# h9 F7 R
  
& D! q# B: p' F  x$ I  download_sdk() {! h$ I- v- t4 l& E2 w) K) f7 I
--- 112,125 ----
+ [4 b0 U; ~" ]9 R  }! |1 y1 i; O8 o
  
' e5 U" M1 H! u9 n- X  download_rootfs() {
2 L: P+ L' v0 g, P!         detect_url "rootfs\.tar"
9 I0 K: Y6 m4 s# V6 p4 E9 [4 K!         local rootfs_url=$openwrt_url/$return
. @1 N  L7 Z$ b1 y, P8 R: n) T  
0 f% l) ]. d, [; b2 U' ~          # global $rootfs
, @& Q( @4 ]+ J4 g  i# i!         rootfs=dl/$(basename $rootfs_url)
0 p8 \# B) T# O- ~( B# q  
- _! d4 N' C2 j4 s- p4 l0 q!         download $rootfs_url $rootfs9 a+ O5 C* v/ n/ C: Y
!         check $rootfs $rootfs_url
6 p$ z/ t' ]8 ~( K3 z# C  }
" i4 y! d0 M- H% N& P1 K  
3 I& E  w8 |6 t4 a8 u  download_sdk() {
- j/ O4 X1 G  M% F
3、从腾讯镜像下载openwrt-19.07.1-bcm53xx-tplink-archer-c9-v1-squashfs.bin,从固件中提取rootfs并预处理。( v1 R/ c. f( w7 _
  1. x@x-Surface-Pro-3:~/下载$ binwalk openwrt-19.07.1-bcm53xx-tplink-archer-c9-v1-squashfs.bin
    2 Y* B: A# a7 W! b" L( j/ D8 Y

  2. 1 f* m' c2 m' @! H% ]/ J1 p/ O. N4 X
  3. DECIMAL       HEXADECIMAL     DESCRIPTION
      H* C5 s+ R7 J- B% P/ k2 f
  4. --------------------------------------------------------------------------------' l  z' r  P! m7 t$ ~4 j& W
  5. 8317          0x207D          TRX firmware header, little endian, image size: 1810432 bytes, CRC32: 0xBCD36218, flags: 0x0, version: 1, header size: 28 bytes, loader offset: 0x1C, linux kernel offset: 0x0, rootfs offset: 0x0
    - n/ S2 b2 r( H0 ?1 N( C# r
  6. 8345          0x2099          LZMA compressed data, properties: 0x5D, dictionary size: 65536 bytes, uncompressed size: 1801662 bytes
    6 w3 B3 J$ J) h& K1 f: M
  7. 1818749       0x1BC07D        Squashfs filesystem, little endian, version 4.0, compression:xz, size: 1856770 bytes, 1174 inodes, blocksize: 262144 bytes, created: 2020-01-29 16:05:35( y8 R  {; K2 v1 _
  8. 8 |) Q/ T3 T2 P9 K
  9. x@x-Surface-Pro-3:~/下载$ dd if=openwrt-19.07.1-bcm53xx-tplink-archer-c9-v1-squashfs.bin of=rootfs-squashfs.bin bs=1 skip=1818749
    # _; L5 {& Q) T+ ^0 A8 ~% Q+ ]
  10. 记录了1900548+0 的读入
    . i* q7 s* s# ?) n
  11. 记录了1900548+0 的写出: G; T7 P" {$ S+ b1 n
  12. 1900548 bytes (1.9 MB, 1.8 MiB) copied, 5.16823 s, 368 kB/s* V! B2 X: o5 r# Z1 Z3 D
  13. x@x-Surface-Pro-3:~/下载$ binwalk rootfs-squashfs.bin + O, `8 d1 @7 H; [# j$ Q
  14. - y: \- e+ L6 e3 W9 H" f
  15. DECIMAL       HEXADECIMAL     DESCRIPTION4 e1 m+ e# v& f1 p+ X4 n0 \  A9 T" Y
  16. --------------------------------------------------------------------------------$ f( Q/ A8 j* i8 l4 X
  17. 0             0x0             Squashfs filesystem, little endian, version 4.0, compression:xz, size: 1856770 bytes, 1174 inodes, blocksize: 262144 bytes, created: 2020-01-29 16:05:35! W; r9 p% i7 s* y  V. X

  18. " [( p) T' v. K; }8 ]6 R# y1 L
  19. x@x-Surface-Pro-3:~/下载$ unsquashfs rootfs-squashfs.bin ! Z3 {. X% R5 {( Q3 A) g: p
  20. Parallel unsquashfs: Using 4 processors
    ! i9 h5 ^1 z9 {3 D7 w, O9 e
  21. 1071 inodes (1066 blocks) to write
    9 I8 B% b+ ^4 p9 S6 L

  22. 6 ~$ U; w& T" u9 U9 @; q
  23. 7 f9 Z* O' H% J  w: C
  24. create_inode: could not create character device squashfs-root/dev/console, because you're not superuser!
    6 I' ?. p* d; n
  25. [====================================================================================================| ] 1065/1066  99%3 q, V- ]  i' \2 x6 |$ ]
  26. 7 \# v$ c  `$ a6 q( W! m6 c
  27. created 875 files) @) V8 `3 g. o/ g! l& C
  28. created 103 directories  y7 f" \- i4 u$ b. X- ?; A' f
  29. created 195 symlinks
    ' C2 F4 m+ ]8 k: c& s
  30. created 0 devices
    4 [* s+ [; a; S# f) T
  31. created 0 fifos9 J5 D6 u% Q# t3 I7 o; U" P6 j& l% p
  32. x@x-Surface-Pro-3:~/下载$ cd ./squashfs-root/
      X. ~- ?; l9 d* A3 h+ R3 S0 Z
  33. x@x-Surface-Pro-3:~/下载/squashfs-root$ gedit etc/opkg/distfeeds.conf
复制代码
将opkg软件源改为腾讯镜像
9 s6 N/ N0 r+ C) u
src/gz openwrt_core https://mirrors.cloud.tencent.co ... xx/generic/packages
7 O, W# t* g" v5 U0 x3 P& g8 xsrc/gz openwrt_kmods https://mirrors.cloud.tencent.co ... 92b7d7eca715b1ee0b89 ^3 @% r; a5 m. |, m( \; E
src/gz openwrt_base https://mirrors.cloud.tencent.co ... /arm_cortex-a9/base
, h9 t. m0 Y6 A: ^9 Usrc/gz openwrt_luci https://mirrors.cloud.tencent.co ... /arm_cortex-a9/luci  O; i  f5 E0 K8 t9 G8 g- R
src/gz openwrt_packages https://mirrors.cloud.tencent.co ... _cortex-a9/packages" H6 `0 m; T* H1 g2 z% Q
src/gz openwrt_routing https://mirrors.cloud.tencent.co ... m_cortex-a9/routing
3 ^1 g3 X8 _- c8 W- A! Jsrc/gz openwrt_telephony https://mirrors.cloud.tencent.co ... cortex-a9/telephony
  1. x@x-Surface-Pro-3:~/下载/squashfs-root$ tar czf ../openwrt-19.07.1-bcm53xx-generic-rootfs.tar.gz ./
    9 |. w7 a4 F3 |. @: S. J  |
  2. x@x-Surface-Pro-3:~/下载/squashfs-root$ cd ../
    : O+ i: ]# F8 E8 e
  3. x@x-Surface-Pro-3:~/下载$ mkdir lxd-openwrt-master/dl  O0 Z% @1 u8 h( P) j
  4. x@x-Surface-Pro-3:~/下载$ mv openwrt-19.07.1-bcm53xx-generic-rootfs.tar.gz lxd-openwrt-master/dl/
复制代码
执行修改过的build.sh, x6 V& o. n- `' b) N. |/ w
  1. x@x-Surface-Pro-3:~/下载$ cd lxd-openwrt-master/4 S7 q$ s) _! e6 L3 [
  2. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ ./build.sh -a arm -v 19.07.1
    . s. _& g* p2 l2 x
  3. ......
    0 p8 X' c( `, r4 }. A3 Q
  4. Pack rootfs* P! P$ p1 a2 b# E+ e% ^
  5. Tarball built: bin/openwrt-19.07.1-bcm53xx-generic-lxd.tar.gz
    : B" }/ ~$ K3 j! y
  6. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ mkdir ../openwrt-19.07.1-bcm53xx-generic-lxc
    2 A( s# f6 ?) j$ _2 M% L
  7. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ tar zxf bin/openwrt-19.07.1-bcm53xx-generic-lxd.tar.gz -C ../openwrt-19.07.1-bcm53xx-generic-lxc- ~9 o3 d- f& B4 L+ L" m
  8. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ cd ../openwrt-19.07.1-bcm53xx-generic-lxc/
    : Q" c; T5 U8 ~& y
  9. x@x-Surface-Pro-3:~/下载/openwrt-19.07.1-bcm53xx-generic-lxc$ ls
    , H6 }9 H) A, R7 R0 x, \  ?4 I
  10. metadata.yaml  rootfs  templates1 {9 Q3 u+ |. E' G+ _! {
  11. x@x-Surface-Pro-3:~/下载/openwrt-19.07.1-bcm53xx-generic-lxc$
复制代码

) w. R6 O3 l* X7 M3 i5 B  h4、这时我们已经创建好lxc下可运行的openwrt19.07.1的rootfs,接下来处理lxc及rootfs的配置文件。' ]" G; `5 `3 ^5 `) P2 k2 o
进光猫复制自带子系统的两个文件,再通过U盘或ftp传到Ubuntu的openwrt-19.07.1-bcm53xx-generic-lxc目录下,: N: [4 z$ a* }, G# l4 y
  1. root@F650A:~ # cp /opt/upt/framework/saf/config /mnt/USB_disc1/1 X! N- Z1 g5 B. {+ J4 J
  2. root@F650A:~ # cp /opt/upt/framework/pre-start.sh /mnt/USB_disc1/
复制代码
config为saf系统的配置文件,新系统下稍作修改,
2 i# b1 r5 s6 L2 x( f1 v) E6 Z
lxc.arch = arm
" u- z7 x$ S$ X% v/ jlxc.utsname = openwrt2 ]; z- E. B9 d9 a! ]- j& A6 d' ]
lxc.rootfs.mount = /usr/var/lib/lxc/openwrt/rootfs
  f# u, k% E4 [+ [; g0 J9 Zlxc.rootfs.path = overlayfs:/opt/upt/framework1/rootfs:/opt/upt/apps/openwrt-rootfs
3 e) F) l* Y* o9 G& \# lxc.rootfs = /usr/var/lib/lxc/openwrt/rootfs 3 k: K! {( _6 g
lxc.haltsignal = SIGUSR1
3 N2 p+ p' u% L; Z4 I5 [* llxc.tty = 1
4 K/ a/ J3 G% i$ F! R+ o8 hlxc.pts = 14 ]1 b3 o: i) q* E
lxc.hook.pre-start = /usr/var/lib/lxc/openwrt/pre-start.sh
6 q. \( ]! W" o# h' r/ N7 tlxc.aa_profile = lxc-container-default-with-nesting% C" C3 H9 j! ~! }( H3 {- p
lxc.network.type = none
% h( A" l; V; Y2 U& _9 K+ ^, T0 L( Dlxc.mount.entry = sysfs sys sysfs defaults 0 0! ]# W0 ?9 x7 m# Y% J* p6 Q/ [1 u
lxc.mount.auto = cgroup-full:rw) ]4 Q' y+ m2 H1 A8 o
lxc.mount.entry = proc proc proc defaults 0 0) T3 u  M5 @( Y
lxc.mount.entry = /mnt mnt none rw,rbind 0 0  V) g- m# E1 Q) h/ a. _* }
lxc.start.auto = 1
+ P) H9 d. i5 y) v4 V8 C* k
pre-start.sh处理模拟终端,为避免重复挂载devpts,添加一行卸载代码,+ m! P$ E$ N6 K4 ^
#!/bin/sh
- b/ ^( {' R: k# W: Qumount /dev/pts /dev/ptmx% n( x& B9 K  Z: d- r
mount -t devpts -o newinstance -o ptmxmode=0666,nosuid devpts /dev/pts) }1 ]- C: f8 o
mount -o bind /dev/pts/ptmx /dev/ptmx
( \6 @: |! c; Q( P; F3 u# P$ Y
再删除rootfs/etc目录下网络和防火墙相关启动及配置文件如uci-defaults/09_fix_crc、uci-defaults/12_network-generate-ula、uci-defaults/70_fill-dhcp-checksum、uci-defaults/odhcpd.defaults、board.d/01_leds、board.d/02_network、board.d/99-default_network、config/dhcp、config/firewall、rc.d/K10gpio_switch、rc.d/K85odhcpd、rc.d/K90network、rc.d/S19dnsmasq、rc.d/S19firewall、rc.d/S20network、rc.d/S35odhcpd、rc.d/S94gpio_switch、modules.d/、modules-boot.d/、ppp/、sysctl.d/ 等,创建squashfs镜像,, @2 z1 I3 j; u) @. k1 _
  1. x@x-Surface-Pro-3:~/下载$ mksquashfs openwrt-19.07.1-bcm53xx-generic-lxc openwrt-19.07.1-bcm53xx-lxc.bin6 D9 V; W, ]  c+ N9 c( `
  2. Parallel mksquashfs: Using 4 processors
    + d) m: y, F( N0 V7 T
  3. Creating 4.0 filesystem on openwrt-19.07.1-bcm53xx-lxc.bin, block size 131072.
    * ^# n' n6 F( p( B  Z: _& `1 [
  4. [=======================================================================================================/] 881/881 100%
    & p( q. u/ N( E' A+ i% V

  5. ; [0 ?8 d: U* k  Q, |
  6. Exportable Squashfs 4.0 filesystem, gzip compressed, data block size 131072
    & D/ F) b1 q$ |- v. |2 k; V' G
  7.         compressed data, compressed metadata, compressed fragments,1 s/ A2 H  A0 }$ E
  8.         compressed xattrs, compressed ids
    3 B5 z+ `" {$ c6 v6 t9 d7 @
  9.         duplicates are removed
    1 O* ^- u: k; w. `) K  h
  10. Filesystem size 3163.90 Kbytes (3.09 Mbytes)
    5 g4 g/ P6 {2 B" R/ d; G' ?
  11.         48.94% of uncompressed filesystem size (6464.54 Kbytes)* o! q5 c9 Y5 ~5 d  z, T6 ]
  12. Inode table size 9693 bytes (9.47 Kbytes)5 ~# _4 c1 `2 f+ e9 J
  13.         25.72% of uncompressed inode table size (37693 bytes)
    & [( L2 z1 w7 f& p
  14. Directory table size 11372 bytes (11.11 Kbytes)6 A1 s/ k8 z+ H  @
  15.         47.17% of uncompressed directory table size (24108 bytes)
    / l% [0 V: z* y' ^: v# y6 f
  16. Number of duplicate files found 136/ ]; @7 ~1 ^5 n% R4 A- p0 ?
  17. Number of inodes 1145' \* E' o6 y! W, p
  18. Number of files 8737 Q# L1 W; f. C4 S& w
  19. Number of fragments 39! L2 ?( |9 b8 Z5 c& V) e
  20. Number of symbolic links  171* {, w6 a7 W+ G# t6 _5 z
  21. Number of device nodes 0/ X# U" x: s! r  e
  22. Number of fifo nodes 0* Y: ~+ y0 p6 g9 c
  23. Number of socket nodes 0: W, f+ k4 g0 ~) W- o
  24. Number of directories 101# p- ?, c. ]# a/ t- J" a
  25. Number of ids (unique uids + gids) 1
    & C) I; G$ t$ L
  26. Number of uids 1
    : h  v0 y  D% n; ?2 u4 G
  27.         x (1000)
    0 D, J( P3 |  E) s- b
  28. Number of gids 1
    ! E. R0 L( z6 y% d" f, F  B
  29.         x (1000)
    5 i0 D( G+ g% w: W5 J4 g
  30. x@x-Surface-Pro-3:~/下载$
复制代码
* Y  `" K' F. t3 A, V

( [! ?6 u& V, M5、生成的openwrt-19.07.1-bcm53xx-lxc.bin传入光猫,'mtd' 写入mtd7分区。( F9 J  ^- M) c- Y  T  C& Y
刷之前先关掉saf,因saf有lxc-monitord进程守护,kill掉之后会自动运行,只好修改saf程序名,重启光猫。5 b: l' j7 E0 t5 g4 O2 e7 K4 Z
  1. root@F650A:~ # mv /usr/sbin/saf /usr/sbin/saf.bak% K4 w! {/ w9 z! z
  2. root@F650A:~ # reboot
复制代码
重启后telnet登录,'ps' 确认进程列表没有saf,备份然后写入并挂载。
root@F650A:~ # ps& C2 o% Z& d/ |2 q9 P9 E
  PID USER     VSZ   RSS  STAT  CPU COMMAND9 T* u3 [9 R) w/ E, P- ]
    1 root     23160   600  S     <1>  init: j3 O  E3 o& l2 M( f  d- i1 L
    ......
) h8 G0 `' P( |root@F650A:~ # dd if=/dev/mtd7 of=/mnt/USB_disc1/mtd7.bin bs=1M
. q( n( b7 d& s. h& C) u8+0 records in
" h# V4 r) D: j1 Y7 r+ I7 S3 N3 [8+0 records out
& E) M0 ~4 O1 V7 G% o' |root@F650A:~ # mtd write /mnt/USB_disc1/openwrt-19.07.1-bcm53xx-lxc.bin /dev/mtd7* T( p+ w% _8 a6 l7 D3 e0 ]: v
Unlocking /dev/mtd7 .... {0 G6 e( x- H

2 A2 z' _% }8 ?2 jWriting from /mnt/USB_disc1/openwrt-19.07.1-bcm53xx-lxc.bin to /dev/mtd7 ...* N3 r6 h$ Q( z' _/ _8 m, U
root@F650A:~ # mount /dev/mtdblock7 /opt/upt/framework1
" L6 E4 O; K9 Y7 c
6、开启OpenWRT新世界
* V5 d: C) p/ ]. ]    写入mtd7分区并挂载之后,开始首次启动的准备工作。F650A的lxc默认路径在/usr/var/lib/lxc(一楼有说明),按config文件创建相应文件及文件夹,
2 I" T; j& P4 i2 E/ v
4 m+ T* m  h! I1 a5 p- J% ]! y: H
  1. root@F650A:~ # mkdir -p /usr/var/lib/lxc/openwrt, H* V, d8 a$ m( ~2 `
  2. root@F650A:~ # cd /usr/var/lib/lxc/openwrt( W% T+ u, Q+ D. d. ~
  3. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/pre-start.sh pre-start.sh0 [; d9 }, N+ l' Y
  4. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/config config  Z1 Z" F3 _( v, H( B3 @2 W  B9 w
  5. root@F650A:/usr/var/lib/lxc/openwrt # mkdir rootfs1 J" W/ c+ W+ v8 h, ?6 k
  6. root@F650A:/usr/var/lib/lxc/openwrt # mkdir /opt/upt/apps/openwrt-rootfs2 |5 C! s3 L+ m; G
  7. root@F650A:/usr/var/lib/lxc/openwrt # lxc-start -dn openwrt0 y. L& ^- Q# P4 j' q  u/ D
  8. root@F650A:/usr/var/lib/lxc/openwrt # ps
复制代码
此时的进程列表应该可以看到/usr/sbin/uhttpd、dropbear等,或者可以尝试打开浏览器 http://光猫ip/或ssh登录,如果看到Authorization Required提示登录或ssh提示登录用户名密码,表明lxc已成功运行,但此时无密码状态无法网页和ssh登录,只能通过控制台方式添加密码后才能实现。关闭openwrt容器,'ps' 确认,前台启动。
8 c) y; U  y4 x7 m! i; K
  1. root@F650A:/usr/var/lib/lxc/openwrt # lxc-stop -kn openwrt
    4 e. V5 W8 w# O
  2. root@F650A:/usr/var/lib/lxc/openwrt # ps
    0 |- v* J4 U3 I; J8 w( d3 ]! A5 T, b
  3. root@F650A:/usr/var/lib/lxc/openwrt # lxc-start -n openwrt
    4 |  O" V; Y# l: h+ ]
  4. <6>init: Console is alive: ]! K$ V- g# n1 u$ Q& }) u$ j
  5. <6>kmodloader: loading kernel modules from /etc/modules-boot.d/** |  h* Q# G) o2 `" q4 u6 n
  6. <6>kmodloader: done loading kernel modules from /etc/modules-boot.d/*8 }! [4 ], ], H/ v8 h9 V+ G
  7. <6>init: - preinit -) z  r* \: _" e6 L
  8. WARNING: Variable 'network' does not exist or is not an array/object( W  y% D$ B  e) ]
  9. WARNING: Variable 'lan' does not exist or is not an array/object; T5 T: ^, H2 W# Z; i3 O- }5 O: y( D2 q
  10. Press the [f] key and hit [enter] to enter failsafe mode4 B. ^3 K' V# |  `
  11. Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
    - ?; W- Q) j1 H' s6 E# O3 g
  12. <5>mount_root: mounting /dev/root
    4 g  I  U4 X1 c' ]
  13. urandom-seed: Seeding with /etc/urandom.seed9 I2 g% b5 u, }
  14. <6>procd: - early -
    7 E6 b! P$ y+ q
  15. <6>procd: - ubus -1 p( q  l4 X7 j8 g
  16. <6>procd: - init -$ T1 y( g3 v- A' P
  17. Please press Enter to activate this console.
    5 l5 g) M1 Y3 `' O& B- q' D
  18. <6>urngd: v1.0.2 started.
复制代码
此时回车便可看到openwrt的登入界面,添加密码。
9 m6 ?0 e5 g( v) [& @0 y6 \
  1.   N) p  c* {( d/ A3 R
  2. BusyBox v1.30.1 () built-in shell (ash)) k  {. J" F& x% |5 T' D; v$ u

  3. + l+ w5 C' d1 D, y. k
  4.   _______                     ________        __2 K! A% _; {0 m7 ^3 i
  5. |       |.-----.-----.-----.|  |  |  |.----.|  |_
    9 V8 ~3 z: q# g; Q6 O5 z# y
  6. |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|! O5 y4 {4 B8 K5 r" J
  7. |_______||   __|_____|__|__||________||__|  |____|
    - @1 `" s. S  x6 |! ~7 O
  8.           |__| W I R E L E S S   F R E E D O M
    % y9 y( y8 R: ?! O1 _5 B
  9. -----------------------------------------------------
    . c6 w5 L0 [& E& o7 o& w
  10. OpenWrt 19.07.1, r10911-c155900f66) X% C3 K! a. |' _; z
  11. -----------------------------------------------------: B3 g, @4 d# Z1 D
  12. root@openwrt:/# passwd root
    $ H, M& r4 C, C# |- a
  13. Changing password for root! I; ~: B, `8 _& ?
  14. New password:
    3 q2 P6 x2 j7 T* |( v$ h
  15. Bad password: too weak
    $ v4 C0 {' X; w5 e: h- k" B
  16. Retype password: ! E0 q1 X& n- ~+ z
  17. passwd: password for root changed by root
    $ `' j9 x! g9 ]: F# I
  18. root@openwrt:/# exit- n$ H+ n; Q6 l3 X' w) D+ X
  19. Please press Enter to activate this console.
复制代码
控制台方式进入openwrt之后,exit无效,没找到正常的退出方式,只能关闭窗口,此后就可以通过网页和ssh正常登录。
# _  K! G- D8 b6 |8 o9 [' A9 r1 X3 g; A/ F9 m
7、自启动及进程守护
% u  e* e7 C5 v) G0 a    telnet登录光猫主系统,确认saf程序已备份," J+ j5 b, g" a; B
# W4 b( g. D" x' V
  1. root@F650A:~ # ls /usr/sbin/
      k! y% g9 E+ W# r9 E$ j0 y/ a  \
  2. chroot       lsap         saf.bak      telnetd2 E$ L, n, ]+ f7 H# z( K4 J
  3. root@F650A:~ # vi /usr/sbin/saf
复制代码
填入 (2021年5月更新:去除USB端口挂载判定,避免无挂载时LXC不能启动): ~- y; V& v0 x# [$ P  F- v
#!/bin/sh
* j  j0 y; y! r, ~: [8 x# add user-defined startup scripts here, _9 N- d9 Y- m+ N( D8 B, q

$ l! U! h! J) ~1 }  Q7 r1 {/ g, B& }  df | grep mtdblock7! l% \$ W2 H* N! \& ?
  if [ $? -ne 0 ]" P/ C+ }3 D7 G( t5 ~
    then/ P* i! V1 h' D7 o2 U" M
      /bin/mount -n -t squashfs -o ro /dev/mtdblock7 /opt/upt/framework1
' q9 ^& \& R6 `: q7 X0 m  fi/ k) P6 N9 n! T/ x! s
##+ L: ?5 M  X4 X7 ]

- s2 u% `3 m2 `# V" a3 v. `* Y6 O7 Y#  ps | grep ntfsmount | grep -v grep! Q) M- B+ K: T0 a# Y9 V
#  if [ $? -eq 0 ]' U) m& y/ U7 a  \
#    then$ r. h* e( Y/ M: @+ P7 ~- U2 Q6 r
      /dbus/usr/bin/lxc-start -dn openwrt  k7 d6 E9 l+ x5 i2 F% z/ U# z# ^7 e, e
#  fi  j0 f; B3 B, u8 Y" i
##

1 \3 o( x- o+ c1 M& I* M* y或者在电脑编辑好内容,命名为saf,传入/usr/sbin/,'chmod +x' 添加执行权限,重启光猫。
& a* ?, \: Y% B  J* n
! q  C1 O( ^( Y) d0 e8、后续问题
- s3 H3 i. H# K" x- q    目前的openwrt安装或更新程序会报错,缺少 libustream-openssl 、ca-bundle 、ca-certificates 和 libopenssl1.1,还需要修改dns,添加中文等: R, c/ ~/ k. T' j# n
' [' S0 T6 b5 |; |" X0 f4 ?
  1. root@openwrt:~# opkg update- E7 I- ]4 e% k1 z) Y1 i
  2. Downloading https://mirrors.cloud.tencent.com/lede/releases/19.07.1/targets/bcm53xx/generic/packages/Packages.gz
    1 H. c: j$ T' _; M7 w6 D* f3 G+ K
  3. wget: SSL support not available, please install one of the libustream-.*[ssl|tls] packages as well as the ca-bundle and ca-certificates packages.# i$ \1 R8 G; y3 P7 l, f6 z
  4. *** Failed to download the package list from https://mirrors.cloud.tencent.com/lede/releases/19.07.1/targets/bcm53xx/generic/packages/Packages.gz
复制代码
这些安装包可以从腾讯的镜像站下载然后手动安装。
% @3 Y7 x! G  b
  1. root@openwrt:~# cd /mnt/USB_disc1/
    ; \8 W  L% W4 k" Z# q$ t6 P
  2. root@openwrt:/mnt/USB_disc1# opkg install *.ipk
复制代码
修改dns+ Q  N" d7 C1 \5 e9 `
  1. root@openwrt:/mnt/USB_disc1# rm /etc/resolv.conf
    ) j3 X8 _& `, o  G3 h
  2. root@openwrt:/mnt/USB_disc1# vi /etc/resolv.conf
复制代码
填入,保存
8 t' }( [) F1 Y  h3 ?
nameserver      223.5.5.5+ J( Q4 `/ V# D+ ?$ ~! Y$ ]7 J: Z
nameserver      8.8.8.8
8 ~8 z! J; w, g& K& [nameserver      2001:da8::666

5 q4 O, f0 v# N4 S, O嫌过程繁琐的可以直接下载我配置好的镜像,从第5部分最后开始操作,将下载的openwrt-19.07.1-bcm53xx-lxc.bin和saf-lxc-start-openwrt放入光猫上的u盘,子系统默认root密码123456。
% ^- D+ V' A. H# i0 ^
  1. root@F650A:~ # dd if=/dev/mtd7 of=/mnt/USB_disc1/mtd7.bin bs=1M
    4 ]& e/ r9 R* U
  2. root@F650A:~ # mtd write /mnt/USB_disc1/openwrt-19.07.1-bcm53xx-lxc.bin /dev/mtd74 Z+ S0 g/ }7 r8 Y  w
  3. root@F650A:~ # mount /dev/mtdblock7 /opt/upt/framework1
    9 {4 P3 ^- E+ W6 C: ]
  4. root@F650A:~ # mkdir -p /usr/var/lib/lxc/openwrt
    - u  a& B& U2 W' |$ P) a
  5. root@F650A:~ # cd /usr/var/lib/lxc/openwrt
    2 u- U1 r, ?* @. i0 R+ e( M
  6. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/pre-start.sh pre-start.sh
    0 {# k6 r% R  Q) A$ i
  7. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/config config- }+ z7 i, i8 C# G" ?" z# k
  8. root@F650A:/usr/var/lib/lxc/openwrt # mkdir rootfs
    ! c9 h3 i1 o$ R. k
  9. root@F650A:/usr/var/lib/lxc/openwrt # mkdir /opt/upt/apps/openwrt-rootfs
    ; c. W( T: l! V" [: C% e, S, L
  10. root@F650A:/usr/var/lib/lxc/openwrt # lxc-start -dn openwrt( P  G1 G( H6 }2 c/ p
  11. root@F650A:/usr/var/lib/lxc/openwrt # cd ~ 2 a3 e# {, O: h/ ?+ S# \2 Z
  12. root@F650A:~ # mv /usr/sbin/saf /usr/sbin/saf.bak
    & a8 I: r" M3 @, z4 G
  13. root@F650A:~ # cp /mnt/USB_disc1/saf-lxc-start-openwrt /usr/sbin/saf3 ^/ o* u! ]) n$ S  B
  14. root@F650A:~ # chmod 0755 /usr/sbin/saf
复制代码
   虽然子系统的openwrt可以顺利运行,但经过我的测试,kmod类app大多无法正常工作。比如F650A内核不支持ext4文件系统,在子系统安装kmod-fs-ext4,尽管可以安装成功,但重启后提示 modprobe 启用ext4模块失败。/ t* Z+ n3 ]. ^2 Z
        子系统的uhttpd默认占用80和443端口、dropbear占用22端口,如果主系统有应用使用这些端口,会产生冲突,需修改rootfs/etc/config/下uhttpd和dropbear的端口设置。F650A的电信web管理系统尽管使用了8080端口,但web登录界面二者公用,当输入超密自动跳转至 :8080/start.ghtml,而使用光猫背面密码则跳转至80端口的luci,所以新的openwrt刷入后电信web管理系统将不可用,这意味着不能方便配置光猫网络,恢复出厂后无法重新拨号。为使子系统与主系统的web页面共存,即访问 http://光猫ip/ 时进入子系统luci页面,而访问 http://光猫ip:8080/ 时进入电信web管理页面,需要更改光猫主系统,此操作的定制空间更大,有机会的话在后面回复中整理出自定义光猫固件的思路。+ @5 N: k( M% [0 v- h

2 |1 M- [! C) ~+ D

本帖子中包含更多资源

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

×
发表于 2020-2-17 23:36:12 | 显示全部楼层
期待大神的教程
发表于 2020-2-18 20:19:40 | 显示全部楼层
谢谢分享,期待大神的教程
发表于 2020-2-18 21:28:08 | 显示全部楼层
滿滿的乾貨,還具有很好的分享精神,贊一個!!
发表于 2020-2-20 12:58:43 | 显示全部楼层
坐等lxc的教程,另外19openwrt是你自己编译的还是直接下载armv7的官方bin刷进去的?. D7 E( ^; Q+ x+ Q3 U. g4 s7 K
中兴非15.0.1出问题是你没清理/opt/upt/apps//apps目录% ]! b0 U4 o/ S/ W5 Y
几乎所有光猫为了节省空间?都会有部分lib和var目录重用主系统的文件,openwrt下e8clib和e8cvar可以看看。
9 f; e1 s6 u6 {4 c# U7 O; z" V另外中兴编译的openwrt开始了uclibc的xlocale配置,这也是achaoge直接用omap源的APP无法运行的原因,我自己有手动开启xlocale后编译omap的openwrt放进去运行OK。: I) w" W6 N7 ~6 Q4 E5 z
有兴趣可以一起研究玩。
 楼主| 发表于 2020-2-20 21:40:34 | 显示全部楼层
anysoft 发表于 2020-2-20 12:58% Q; j7 _. l1 x- [$ e; E* |
坐等lxc的教程,另外19openwrt是你自己编译的还是直接下载armv7的官方bin刷进去的?
" u# X" h- }* Z. M中兴非15.0.1出问题是 ...
) y  }4 k5 ~( U! S: v9 H
; k2 d8 q9 Z" @& M3 ^2 Z
openwrt1907用的官方rootfs经https://github.com/mikma/lxd-openwrt修改而来;xlocale的问题我在编译主系统的busybox时也发现了,官方用的应该是buildroot2015.08.1,如果有dtb和驱动甚至可以自己写个固件了。
发表于 2020-2-21 14:42:33 | 显示全部楼层
songee 发表于 2020-2-20 21:40
' S; y# E+ i$ c7 wopenwrt1907用的官方rootfs经https://github.com/mikma/lxd-openwrt修改而来;xlocale的问题我在编译主 ...

4 ]4 v4 A+ V8 `* \  R5 Z是的, 中兴使用的是buildroot-2015.8.1,这个strings 一下sendcmd 就可以看到' c  a% i; f# k# `- a

2 t: P1 O! Z, H7 O$ p1 [看了下操作步骤,其实如果内存足够,没必要关闭saf启动的天翼网关。
) D0 t! C& |9 ^2 U可以让lxc容器启动两个op应该是可以的,F650A和华为hs8145V应该都是512MB内存,内存足够,openwrt可以放到apps分区文件夹下,不一定要写入mtd7再手动挂载。
9 h+ c$ R5 h( N6 k/ C4 }. C' n$ B/ j
; @/ t8 x3 k/ o: t, d我的HS8145V启动后内存只占用了30%,足够了。
* x4 x6 {- I. {) ?! ^7 r1 l4 y+ Q4 L& c: P" {  I5 x+ t" {2 r8 {
另外主系统下的usr/sbin目录下文件不是内存加载的rootfs对应的squash文件?这个更改应该不会回写到文件系统,重启应该就会消失?
' C! c1 S& c; x5 j1 n( Z. d+ u不晓得中兴和华为是不是一样的。可能中兴可以修改文件吧,华为的只能dd备份rootfs分区后自己解包修改打包后再dd写进去,会有砖的风险,砖了只能上编程器。; Y% n0 B: W. P) g; V( L) X; P

" I) W$ Z8 ]! j& `% x至于端口问题可以在打包openwrt的时候先修改每个服务对应监听端口就不会冲突了。
. k# c: l. t! N

本帖子中包含更多资源

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

×
*滑块验证:
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|小黑屋|宽带技术网 |网站地图 粤公网安备44152102000001号

GMT+8, 2025-5-19 06:48 , Processed in 0.047138 second(s), 7 queries , Redis On.

Powered by Discuz! X3.5 Licensed

Copyright © 2001-2020, Tencent Cloud.

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