找回密码
 注册

QQ登录

只需一步,快速开始

查看: 80612|回复: 97

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

  [复制链接]
发表于 2020-2-17 02:14:04 | 显示全部楼层 |阅读模式
本帖最后由 songee 于 2022-4-27 21:04 编辑 4 b9 z" F0 k  N+ G( K; B8 T2 |9 h
6 {5 M- \! z+ O$ Y" ?; j
家里装宽带,电信200M,送了个中兴F650A。自带的天翼3.0web界面看着不错可惜几乎没有可玩性,闲来无事研究一番。
7 p% h# P# H' ^+ g$ ^. M    借鉴论坛前辈achaoge的帖子:中兴 F450A/F650A 免 TTL 持久开 ssh顺利开启telnet,发现该光猫的运作机制是 主系统负责底层的硬件驱动、sendcmd管理系统(telnet、超密、ppp拨号、网络及WiFi、ftp等)、以httpd为基础的8080端口电信web管理界面,最后启动saf(lxc容器管理)程序。# {: g4 [* W5 q/ o
    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数据存放区,操作时需要特别注意!!: {7 v8 a& S" V
  1. root@F650A:/usr/sbin # saf
    ' r3 N$ Z. s& `
  2. Usage: saf service FWK_MTD_ID1 FWK_MTD_ID2 APPS_MTD_ID (eg. saf service 9 10 7)4 |& |' Q7 L7 q* B# V
  3. saf console
      M; C: f/ f7 p8 _( \* @& H
  4. saf info3 Q9 E. X0 ^, b; U# h( h0 _0 M
  5. saf version
    ! F" J, T9 _( V% k
  6. saf getfwkver/ P/ s2 S2 }, {' N7 x: _
  7. saf getbakfwkver
    6 ~7 O# P+ d- X- z
  8. saf getactive2 w9 @3 |3 [1 X1 u
  9. saf setactive FWK_MTD_ID [AFTER_REBOOT] (eg. ./saf setactive 17 1)
复制代码
  1. root@F650A:~ # cat /proc/mtd
    " }+ ]. y" V: F+ G4 L
  2. dev:    size   erasesize  name9 _; m. I/ U, m' N! r- f
  3. mtd0: 08000000 00020000 "whole flash"
    - s( `8 z# B$ Y# Y2 G9 C3 p5 a
  4. mtd1: 00100000 00020000 "u-boot"( e2 c, l) q# f7 H$ p* r
  5. mtd2: 00080000 00020000 "others"; g3 i7 D0 j, q
  6. mtd3: 00100000 00020000 "parameter tags"
    / B- i0 {# V2 M1 ?9 R4 t
  7. mtd4: 00100000 00020000 "wlan"  E) F3 _8 D8 N. n% ~) N6 x' v* I
  8. mtd5: 00200000 00020000 "usercfg"3 Q8 X8 A, A1 T2 a
  9. mtd6: 00800000 00020000 "framework"
    5 D8 n2 D2 ~: U# Y; H. F4 o& c0 t0 r( k( Q
  10. mtd7: 00800000 00020000 "framework1"! u7 p6 I+ L- K
  11. mtd8: 00780000 00020000 "dbus"
    - y) ~7 U1 f- K& v
  12. mtd9: 01280000 00020000 "kernel1"
    & {: P. L  Q; [9 k# z; C! r! y
  13. mtd10: 01280000 00020000 "kernel2": H% y! j, _* z2 K5 R1 j
  14. mtd11: 03e00000 00020000 "plugin_data"  n$ t6 Q  p# G& f2 X) ^5 T
  15. mtd12: 01240000 00020000 "rootfs"
复制代码
0 V# r1 q$ ~3 J9 }% i
    saf程序管理子系统,是通过系统的lxc容器实现的,在/dbus/usr/bin/目录下有lxc相关程序,但并非标准的官方版,而是定制的,lxc.lxcpath即lxc容器存放位置设定为/usr/var/lib/lxc,暂时没有发现更改的方法(也没什么必要)。
root@F650A:~ # ls -l /dbus/usr/bin
% N) q8 Y3 `7 X! `total 377
- V8 l- e/ y  K2 x  @% f9 g9 z-rwxr-xr-x    1 root     root         10143 Nov 15  2018 dbus-cleanup-sockets
: r1 ]; k+ G6 [( n* s% h-rwxr-xr-x    1 root     root         18867 Nov 15  2018 dbus-launch
" W4 v0 U( w/ R$ `9 |! h# d-rwxr-xr-x    1 root     root         22537 Nov 15  2018 dbus-monitor
7 w% f8 k% ?0 G9 F/ ^( w* v-rwxr-xr-x    1 root     root         11049 Nov 15  2018 dbus-run-session% k$ C& d; y9 a4 j; L5 E% v
-rwxr-xr-x    1 root     root         23431 Nov 15  2018 dbus-send& ]" w$ c4 b0 V8 b" I
-rwxr-xr-x    1 root     root         19495 Nov 15  2018 dbus-test-tool, Z$ K$ x- _% h+ T+ ^$ r" C5 ?
-rwxr-xr-x    1 root     root         12257 Nov 15  2018 dbus-update-activation-environment+ r& @/ q$ }& C, y- u* c
-rwxr-xr-x    1 root     root          8365 Nov 15  2018 dbus-uuidgen: D! F; r5 c7 Q) Q2 P# i! X
-rwxr-xr-x    1 root     root         33112 Nov 15  2018 gdbus
& S( Z, V6 _; x" X* a# C-rwxrwxrwx    1 root     root         12332 Nov 15  2018 lxc-attach+ z! Q. S* s; `, D9 ?
-rwxrwxrwx    1 root     root         14241 Nov 15  2018 lxc-autostart5 n8 k: T* O$ D% I4 J/ e
-rwxrwxrwx    1 root     root          9122 Nov 15  2018 lxc-cgroup. e) {+ R  V9 g5 ?$ t, f
-rwxrwxrwx    1 root     root          4414 Nov 15  2018 lxc-checkconfig
2 P; ^( k1 ]+ o4 j0 y& q9 P-rwxrwxrwx    1 root     root         10175 Nov 15  2018 lxc-clone
6 S5 o$ u4 ]7 L3 z-rwxrwxrwx    1 root     root          6181 Nov 15  2018 lxc-config" ]+ v0 |) f- v) n: r
-rwxrwxrwx    1 root     root          8590 Nov 15  2018 lxc-console
8 L3 S$ ^9 j, Q# q-rwxrwxrwx    1 root     root         14556 Nov 15  2018 lxc-create. F" }  u3 n0 y. ^
-rwxrwxrwx    1 root     root          8540 Nov 15  2018 lxc-destroy
, E! M8 ?  A; C-rwxrwxrwx    1 root     root         10027 Nov 15  2018 lxc-execute
2 f! U& `, m$ X7 W-rwxrwxrwx    1 root     root          8630 Nov 15  2018 lxc-freeze6 p# u- \1 J" b* [8 o
-rwxrwxrwx    1 root     root         18956 Nov 15  2018 lxc-info4 j+ w/ a& U4 ~% Y& G% x
-rwxrwxrwx    1 root     root          2834 Nov 15  2018 lxc-ls
- m6 B- `6 r% r- Q6 T-rwxrwxrwx    1 root     root         11122 Nov 15  2018 lxc-monitor: ^7 d. c. s5 N& M" M+ R
-rwxrwxrwx    1 root     root         12270 Nov 15  2018 lxc-snapshot
5 V* C! h6 R  [3 H-rwxrwxrwx    1 root     root         15356 Nov 15  2018 lxc-start1 x# e  ]4 _) `- r0 G* F
-rwxrwxrwx    1 root     root         10055 Nov 15  2018 lxc-stop  i& j; q( i# u. h
-rwxrwxrwx    1 root     root          8634 Nov 15  2018 lxc-unfreeze
! z3 o1 @5 F: A! A4 C( J; [" r-rwxrwxrwx    1 root     root         12380 Nov 15  2018 lxc-unshare, \* U: i2 u: j& q0 w  {
-rwxrwxrwx    1 root     root         13324 Nov 15  2018 lxc-usernsexec
; l) v- P5 I8 F-rwxrwxrwx    1 root     root          8561 Nov 15  2018 lxc-wait
  1. root@F650A:~ # lxc-config -l: J/ Z$ I! `% Z, E0 a% {  a7 Y+ R
  2. lxc.default_config
    & j% [8 e% ], H( e
  3. lxc.lxcpath, o" F9 X! h4 Z! c* W
  4. lxc.bdev.lvm.vg
    # V% U. O$ n/ J
  5. lxc.bdev.lvm.thin_pool0 n* o0 V% H6 [4 k3 r- o  {2 k
  6. lxc.bdev.zfs.root
    ; M* u, V2 @& w8 B# R: C
复制代码
  1. root@F650A:~ # lxc-config lxc.default_config  B% r6 J, k$ z; @; t
  2. /usr/etc/lxc/default.conf# m* Z0 t1 S' |4 j& z6 V6 O  t3 x/ G
复制代码
  1. root@F650A:~ # lxc-config lxc.lxcpath
    " q" D1 D- V' G; J: ~2 g# H1 D0 X
  2. /usr/var/lib/lxc
复制代码
* A, Z$ B" z; I- a' X
    了解系统运作机制之后,我最初打算借用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方式开启新世界,操作步骤在本文回复中细谈。
) u$ E% X+ k! ?+ l- b- Y" N    经过几番折腾,已将系统原有的openwrt中兴定制版saf子系统完全替换为官方openwrt19.07.1(lxc方式启动),不影响光猫拨号且可在线安装及更新非kmod类app,如ariang离线下载,samba文件共享,甚至各类科学上网工具(性能及安全原因不推荐)。
4 @  n+ U+ {# P: a7 _9 M) @4 R
; r0 v) q! w! T$ \, B- h# Y- W' z3 q+ r! j1 ?( e4 _
* o7 g1 ^, k8 E  r: E/ s6 Z

" Q6 Z4 z6 U: ^
: D0 A- N7 s# O% a; a' J
( v6 A6 J- n3 l& d: ^7 ~) f. I& I" T/ c) F& i' h& }

本帖子中包含更多资源

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

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

简化并更新OpenWRT22.03.0 RC1版本

本帖最后由 songee 于 2022-4-26 23:39 编辑
: L. \8 J; k' O# e" }( C/ q% P- U" S# M9 w6 I7 \4 J  w4 i# X
因二楼原帖过程过于繁琐,近期尝试了一种较为简单的办法。
- m; S' x8 n$ n' d7 ~' `9 k+ V; [. O8 L
. k+ p; D( M' \3 v  i  J
1、下载openwrt.org固件,我选的是openwrt-22.03.0-rc1-bcm53xx-generic-tenda_ac9-squashfs.trx,binwalk分析squashfs偏移量并用dd取出,unsquashfs提取rootfs,打包为rootfs2203rc1.tar.gz,传入光猫临时目录,如 /run/shm 。
; W7 u( N8 `* ?( d- @* e/ M7 ]
2 `- g' I+ A' y" ^. O0 I: ^. `2、将rootfs2203rc1.tar.gz提取至 (lxc-config lxc.lxcpath)/openwrt/rootfs 。
8 Y( R( i; D2 o$ S
  1. root@F650A:/usr/var/lib/lxc/openwrt/rootfs # tar -xzvf /run/shm/rootfs2203rc1.tar.gz -C ./
复制代码

$ |/ r7 L$ s' I  Y+ U( p' n. Y! E* c4 u
3、修改rootfs。openwrt的网络配置与主系统有冲突,需要清除。& I, C" e: ]. e9 A) \$ H+ j% @+ l$ I
    3.1 移除 ./etc/board.d/ 目录下 01_leds 、02_network 、99-default_network 三个文件。+ H5 `% S, J% X# B; `  Y
    3.2 移除 ./etc/rc.d/ 目录下 K21wpad 、K85odhcpd 、K90network 、S19dnsmasq 、S19firewall 、S19wpad 、S20network 、S35odhcpd 、S96led。
! ^; V8 v3 o0 O) ]( Z    3.3 移除 ./etc/modules.d/ 和 ./etc/modules-boot.d/ 及 ./lib/modules/5.10.111/目录下所有文件,openwrt的kernel modules与光猫内核不兼容。
! J! Z3 }# W( c) w" `& ]- o# {8 G& t7 Y0 I
    3.4 修改opkg源 ./etc/opkg/distfeeds.conf(可选)9 V  G0 ^( I9 `0 Q0 Z
  1. src/gz openwrt_core https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/targets/bcm53xx/generic/packages! r. U; A7 M: A
  2. src/gz openwrt_base https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/base
    ' q. J$ R  ~/ U
  3. src/gz openwrt_luci https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/luci+ x) M" H7 K3 W. S0 q
  4. src/gz openwrt_packages https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/packages3 ]1 V3 _3 T8 |6 E( F4 }; q
  5. src/gz openwrt_routing https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/routing
    ' R( L5 T- N. Y# W5 [9 E
  6. src/gz openwrt_telephony https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/telephony, t1 U0 J6 `0 w  `  ]! x6 G
复制代码
  3.5 修改 ./etc/inittab 实现启动项自启(参考https://github.com/mikma/lxd-ope ... r/files/etc/inittab! O( Z3 K; R! @8 L+ t8 [: p+ U
  1. ::sysinit:/etc/init.d/rcS S boot
    3 O* C6 x' u" ?9 a! C- X5 u, S
  2. ::shutdown:/etc/init.d/rcS K shutdown- _! q& R; ^9 c  k
  3. console::askfirst:/usr/libexec/login.sh
复制代码
  3.6 修改密码 ( root 密码 chinadsl+ S: l3 X4 [; z
  1. root@F650A:/usr/var/lib/lxc/openwrt/rootfs # chroot ./8 f, I0 O8 \- b5 x" b1 R

  2. ' T" A/ h! c  u  c) {9 G8 t  b
  3. ) J* }4 ]# Q  g( W
  4. BusyBox v1.35.0 (2022-04-20 10:37:37 UTC) built-in shell (ash)
    " p5 T1 z; v4 |

  5. 5 V5 R7 v/ a* J/ r0 O
  6. root@F650A:/ # passwd# J  I- K2 m3 Q0 @
  7. Changing password for root
    ' y+ Q/ h+ t/ l0 }
  8. New password:3 H7 n1 s8 ~9 q  [$ o7 T2 I  W( O
  9. Bad password: too weak
    1 z) h  d1 t. w: S
  10. Retype password:
    % T- x% [$ ]4 E0 o( V
  11. passwd: password for root changed by root
复制代码
  3.7 删除 ./etc/resolv.conf 软连接并新建./etc/resolv.conf,否则openwrt无法解析域名
9 O. M3 k& O, s4 U0 @
  1. nameserver 223.5.5.5
    ( Y( Y# d) y/ T1 @2 n; h9 y
  2. nameserver 2001:da8::6662 ^6 ~1 S4 [- P* [$ @4 J8 L7 J
复制代码
" O: E- f6 d) p& p! a) g8 ~7 w0 ?
; s+ k- }* _+ ?$ ]0 _! J9 W+ G' {
4、修改lxc配置文件 /usr/var/lib/lxc/openwrt/config ,根据各自光猫环境修改测试,这个配置我的F650A可正常使用。
. f+ _* t' ?1 [' b5 f# i- I
  1. lxc.arch = arm& P  u& |( E9 h* R1 ~
  2. lxc.utsname = openwrt1 l; D; T% {9 e( ?1 @: r' K
  3. #lxc.rootfs.mount = /usr/var/lib/lxc/openwrt/rootfs
      T$ l, A* N! i' e
  4. #lxc.rootfs.path = overlayfs:/opt/upt/framework1/rootfs:/opt/upt/apps/openwrt-rootfs$ s3 j+ H) i% H  o
  5. lxc.rootfs = /usr/var/lib/lxc/openwrt/rootfs
    9 K5 R% x% C( C2 X% H
  6. lxc.haltsignal = SIGUSR1
    / b1 ?+ q7 D4 L6 H
  7. lxc.tty = 1
    3 [. ~; Z3 p/ t' k6 N  ?
  8. lxc.pts = 1# y" v3 B# r0 J
  9. #lxc.hook.pre-start = /usr/var/lib/lxc/openwrt/pre-start.sh
    # f+ {, E& t) b  s6 ?0 U6 v- x
  10. lxc.aa_profile = lxc-container-default-with-nesting
    8 b7 F9 P. Z' K' n  m# j+ ?
  11. lxc.network.type = none
    # u+ L- [6 ~8 `( ~
  12. lxc.mount.auto = cgroup-full:rw
    # g7 K7 ?( `& F: Z
  13. #lxc.mount.auto = proc sys cgroup3 E* `) ]0 ]5 D2 W- b- C
  14. lxc.mount.entry = sysfs sys sysfs defaults 0 0
    0 ~* i/ J5 ?3 R0 w% Y7 @
  15. lxc.mount.entry = proc proc proc defaults 0 0
复制代码

5 y1 v1 P# C( ]; z, {# f2 Q1 H: T1 I
5、启动,根据提示按enter进入控制台。3 _7 ~' ^* y9 x2 j
  1. root@F650A:~ # lxc-start -n openwrt
    / S: r4 P& {# K% H) G4 S
  2. <6>init: Console is alive4 x" {, Z. W5 c4 i4 V/ L
  3. <3>init: Failed to redirect stdin to /dev/null: No such file or directory) }9 ^7 ^7 H5 K% f$ W5 O
  4. <3>init: Failed to redirect stdout to /dev/null: No such file or directory
    ! [' o  x$ R  T9 L
  5. <3>init: Failed to redirect stderr to /dev/null: No such file or directory
    ( o+ ^7 t. d# A
  6. <6>kmodloader: loading kernel modules from /etc/modules-boot.d/*. I+ O4 P% D6 R$ Y, a& z- U
  7. <6>kmodloader: done loading kernel modules from /etc/modules-boot.d/*
    ) s! d5 k) ?0 q; U8 j
  8. <6>init: - preinit -
    , c. [+ |7 ]# |" S! K# u* F
  9. ls: /etc/board.d/*: No such file or directory
    . u# R. s+ M( ^6 U, w  C1 Y
  10. Press the [f] key and hit [enter] to enter failsafe mode
    - ^3 A5 Q: _( e5 _
  11. Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
    0 j0 K/ k0 D9 W$ c4 r3 J8 h
  12. <3>mount_root: Could not open mtd device: /dev/mtd12! K- }7 c) z* ]. x' h/ O
  13. <3>mount_root: reading rootfs failed
    + g# V' L# R% y+ O& F
  14. <5>mount_root: mounting /dev/root
    6 b5 l1 D. w6 W$ q& L
  15. urandom-seed: Something is wrong with /dev/urandom
    . J) E3 d  ]- P- A: k
  16. <6>procd: - early -' Z: F# a& p$ N" l0 _
  17. <6>procd: - ubus -8 u  n% v! G4 d
  18. <6>procd: - init -
    * u' b- x, E% h7 N; M$ u# b. K# U
  19. Please press Enter to activate this console.: [) B: E1 a, {5 x/ m. g# t
  20. <6>kmodloader: loading kernel modules from /etc/modules.d/*
    $ @  }. V8 b7 ^; [! S' g: \9 X" r
  21. <6>kmodloader: done loading kernel modules from /etc/modules.d/*# d  q" u5 ]: p- k
  22. <6>urngd: v1.0.2 started.
    0 `2 o! e& n+ D9 T. N

  23. + i: p+ T/ U# c6 s: c. d

  24. " ?* a2 ?! [  W1 A5 s' b( Y

  25. - ?9 c  |8 }3 N+ d! A1 E
  26. BusyBox v1.35.0 (2022-04-20 10:37:37 UTC) built-in shell (ash)# r9 _8 z$ {+ B/ S7 X
  27. & D( n+ f' c1 d5 n- z( Q
  28.   _______                     ________        __; `: a+ I4 j! v2 @" G8 M  [7 W
  29. |       |.-----.-----.-----.|  |  |  |.----.|  |_" g  A# h3 V; l) d3 J
  30. |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
    4 h  g# l+ C5 ^* B1 R# _
  31. |_______||   __|_____|__|__||________||__|  |____|
    ( }7 T+ J; r$ B0 n. i4 j  Y
  32.           |__| W I R E L E S S   F R E E D O M' E8 c  D8 G% `& }' W* {& I
  33. -----------------------------------------------------
    8 p7 D( B. f1 \" a: n  s+ \1 H- a- o
  34. OpenWrt 22.03.0-rc1, r19302-df622768da
    . W: }5 w; i% s" C3 h3 J
  35. -----------------------------------------------------% w6 A% c% E. N1 T9 d- u; Y
  36. root@openwrt:/#
复制代码
, q; c7 E, C# D) I6 v) _

. [6 K; O6 B+ C1 z9 X3 s
  1. root@openwrt:/# ps9 a2 k0 S7 U" F2 T, `( a
  2.   PID USER       VSZ STAT COMMAND
    5 f9 {, j: z. k
  3.     1 root      1452 S    /sbin/procd
    " v& a8 e6 J. z" p0 z
  4.    58 ubus      1112 S    /sbin/ubusd
    ; y; R- L7 j5 `4 r( M# D
  5.    59 root      1196 S    /bin/ash --login
    4 ~8 ]( B( r+ L+ \1 A2 }7 Y9 |! {
  6.    93 root       908 S    /sbin/urngd
    - n7 W* p6 H, Q. H
  7.   204 root      3736 S    /usr/sbin/uhttpd -f -h /www -r OpenWrt -x /cgi-bin -u /ubus -t 60 -T 30
    8 f. C6 p9 u* q  b9 n: S
  8.   487 root      1952 S    /sbin/rpcd -s /var/run/ubus/ubus.sock -t 30" f0 [. ^- f7 v6 L- y6 F
  9.   556 root       956 S    /usr/sbin/dropbear -F -P /var/run/dropbear.1.pid -p 22 -K 300 -T 3
    ; }" ]* G4 o. Y' r' Y2 c% f
  10. 1065 root      1200 R    ps
    ( ~# N  E5 F# }1 F+ ^
  11. root@openwrt:/#
复制代码
7 c/ ~4 Z6 J! R  X

7 U! |. Q0 i% o# L) \! U& y
  1. root@openwrt:/# opkg update
    ' E) U: E! f0 |( k# N8 m5 m
  2. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/targets/bcm53xx/generic/packages/Packages.gz
    " K  G' s. Y: W, W& B
  3. Updated list of available packages in /var/opkg-lists/openwrt_core
    ) I5 e7 F$ ]7 p: v2 [3 Z* y
  4. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/targets/bcm53xx/generic/packages/Packages.sig
    & I) j, n% Q2 {  s
  5. Signature check passed.7 _) V3 C9 ]2 W( [
  6. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/base/Packages.gz: Z: X* t+ e. Y7 T" u" q
  7. Updated list of available packages in /var/opkg-lists/openwrt_base
    1 i6 {8 h. M) Z
  8. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/base/Packages.sig% I* X# N6 k* H4 R& z- q7 J
  9. Signature check passed.# O" k, D! [" j' N
  10. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/luci/Packages.gz
    3 }" a  _, ^, e$ V, ]. F5 f
  11. Updated list of available packages in /var/opkg-lists/openwrt_luci
    " s. {, b0 C3 y. ^
  12. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/luci/Packages.sig. p: `! W+ Z5 L  O8 M6 x% c8 K
  13. Signature check passed.
    ) [# ^! |% x' Y# e$ }
  14. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/packages/Packages.gz
    ! p$ i# T5 M6 o6 B" L7 W' @
  15. Updated list of available packages in /var/opkg-lists/openwrt_packages8 Q- z, D. g1 a: |* O! r" x
  16. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/packages/Packages.sig! }7 [+ ?3 Q0 P# C) `/ C  }
  17. Signature check passed.
    0 N& [( b3 k) t7 W0 T6 q/ |) \' \
  18. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/routing/Packages.gz
    6 X% N% O# @4 a6 _3 w2 J% {
  19. Updated list of available packages in /var/opkg-lists/openwrt_routing( \* D" u! }( n9 B# U9 [
  20. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/routing/Packages.sig/ y# C- V) k& }$ U, c
  21. Signature check passed.* u2 a, F9 P# x4 f. K0 K
  22. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/telephony/Packages.gz6 O$ k2 e5 S* Y0 ]. I8 m, X
  23. Updated list of available packages in /var/opkg-lists/openwrt_telephony( D# l8 W7 I. O( e
  24. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/telephony/Packages.sig
    5 c7 y2 t9 g! M, v( Q% E0 ?$ N
  25. Signature check passed.) G2 L/ P6 x/ D& `/ V9 q
  26. root@openwrt:/#
复制代码
, }/ _- b" x- `) f7 s

( T5 {4 x& S3 T, y  |此时临时的openwrt系统已建好,运行的服务有两个:http占用主系统的80和443端口,ssh占用22端口。& _' `0 o; O8 u8 f
8 y3 @3 i( w( g3 N
如果光猫有公网IP,请务必关闭ssh密码登录并使用密钥。
/ I% g+ f* V# o' b1 X7 ~8 l9 ?
: A: V$ K8 e/ I$ G. ~% c后期使用建议使用 lxc-start -dn openwrt 后台启动,使用 lxc-stop -kn openwrt 命令关闭。openwrt管理使用ssh密钥登录。
- B' h6 A2 Q9 F需要固化openwrt到固件的,可以打包rootfs和config(需修改配置),mksquashfs制作成squashfs,用mtd写入saf分区,就不用担心恢复出厂设置了。
6 i' O) o4 u; U; v3 y9 J随光猫启动可以参考二楼。* C. e# H) N/ f& U
" ~9 B/ u  Z  l7 v4 `' F# ?

本帖子中包含更多资源

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

×
 楼主| 发表于 2022-4-27 23:10:13 | 显示全部楼层
因光猫原系统的busybox功能不完整,也没有nano和dropbear,调试lxc可能会不方便,现分享出来。
" ?: N4 Y8 k+ c4 R7 W& ?/ v0 V
8 V$ Z2 u5 ]2 t" I  e4 X9 ]
  1. root@F650A:~ # /usr/bin/busybox
    5 E& |$ t8 z6 v: n& H/ T
  2. BusyBox v1.23.2 (2020-06-16 16:53:26 CST) multi-call binary.
    5 g* p4 I0 Z  c% M- S
  3. BusyBox is copyrighted by many authors between 1998-2012.- x) Z9 l" A+ n, d
  4. Licensed under GPLv2. See source distribution for detailed
    6 S" P* l1 W  h$ [: J  v9 A( @
  5. copyright notices.
    . B; g# s" K4 s9 f+ u: o
  6.   n% T; O: l4 s3 t9 G0 Z$ x$ |
  7. Usage: busybox [function [arguments]...]+ T; d2 w. r5 i2 a7 c
  8.    or: busybox --list[-full]
    6 K6 P/ C- c0 z7 m
  9.    or: busybox --install [-s] [DIR]8 R% |4 S$ ]1 D2 N
  10.    or: function [arguments]...
    ) M- I6 w) P, N+ S& w4 b

  11. 5 F& c6 h$ |+ J* X1 w) K3 c# e4 t
  12.         BusyBox is a multi-call binary that combines many common Unix
    2 p7 ?" z" B& i6 k$ V
  13.         utilities into a single executable.  Most people will create a' r% E6 g! a, I5 V9 i! z, T& g  u7 \
  14.         link to busybox for each function they wish to use and BusyBox
    $ {& Y" p! l: ~2 ]. M5 L
  15.         will act like whatever it was invoked as.
    , c1 q8 L$ B" C+ M. T; T

  16. $ Y- {/ o0 c2 ]. \+ S6 T
  17. Currently defined functions:/ c9 I9 i# }! u5 r- Z
  18.         [, [[, addgroup, adduser, ar, arp, arping, ash, awk, basename, blkid, brctl, bunzip2,1 r$ T9 m0 n8 X+ m7 U) ]/ I6 Y4 D6 g
  19.         bzcat, cat, catv, chattr, chgrp, chmod, chown, chroot, chrt, chvt, cksum, clear, cmp, cp,! ]% A3 t( c1 Q* y$ ^. A
  20.         cpio, crond, crontab, cut, date, dc, dd, deallocvt, delgroup, deluser, depmod, devmem, df,8 P" g# @" b. {6 Q7 \  K7 p
  21.         diff, dirname, dmesg, dnsd, dnsdomainname, dos2unix, du, dumpkmap, echo, egrep, eject, env,
    . T: U2 g$ [) e& U' ^
  22.         ether-wake, expr, false, fbset, fdflush, fdformat, fdisk, fgrep, find, flock, fold, free,' y8 Z! t5 Q; d2 u9 }
  23.         freeramdisk, fsck, fstrim, fuser, getopt, getty, grep, gunzip, gzip, halt, hdparm, head,
    9 I( M. X$ w) ^; J* M8 p5 t
  24.         hexdump, hostid, hostname, hwclock, id, ifconfig, ifdown, ifup, inetd, init, insmod,. ~; m. x7 K- X
  25.         install, ip, ipaddr, ipcrm, ipcs, iplink, iproute, iprule, iptunnel, kill, killall,
    & r5 A3 c' o. S
  26.         killall5, klogd, last, less, linux32, linux64, linuxrc, ln, loadfont, loadkmap, logger,
    / ^/ `5 d; Z/ s- Y! p
  27.         login, logname, losetup, ls, lsattr, lsmod, lsof, lspci, lsusb, lzcat, lzma, makedevs,
    + Y+ ~0 j4 j  P% C' B3 X5 O
  28.         md5sum, mdev, mesg, microcom, mkdir, mke2fs, mkfifo, mkfs.ext2, mknod, mkswap, mktemp,
    ' \4 f" Q# I4 z) p* O0 U, [
  29.         modinfo, modprobe, more, mount, mountpoint, mt, mv, nameif, nanddump, nandwrite, netstat,
      a1 U* X1 S  B9 Q! W
  30.         nice, nohup, nslookup, od, openvt, passwd, patch, pidof, ping, pipe_progress, pivot_root,6 {0 f. l8 c& ^" p$ y7 k( r8 t9 \$ a
  31.         poweroff, printenv, printf, ps, pwd, rdate, readlink, readprofile, realpath, reboot,1 |) x& h% F: v& ~
  32.         renice, reset, resize, rm, rmdir, rmmod, route, run-parts, runlevel, sed, seq, setarch,) z& M, H) X; f7 ^$ G! J1 B
  33.         setconsole, setkeycodes, setlogcons, setserial, setsid, sh, sha1sum, sha256sum, sha3sum,7 P( J0 l. v. m! U, G
  34.         sha512sum, sleep, sort, start-stop-daemon, strings, stty, su, sulogin, swapoff, swapon,
    ! Y8 p6 \! v# c4 e
  35.         switch_root, sync, sysctl, syslogd, tail, tar, tee, telnet, telnetd, test, tftp, time, top,4 t% G! h6 b' q
  36.         touch, tr, traceroute, traceroute6, true, tty, ubiattach, ubidetach, ubimkvol, ubirmvol,, G3 G; q# H' F9 g9 |4 n- G; ~
  37.         ubirsvol, ubiupdatevol, udhcpc, umount, uname, uniq, unix2dos, unlink, unlzma, unxz, unzip,
    ! s" [0 `' a4 R" x7 g
  38.         uptime, usleep, uudecode, uuencode, vconfig, vi, vlock, watch, watchdog, wc, wget, which,
    8 _: d2 i0 V; y* R$ `; l. m
  39.         who, whoami, xargs, xz, xzcat, yes, zcat
    7 F: z) n8 [  c

  40. 8 ^& X9 ^1 o6 f+ f. b" [& \
复制代码
  1. root@F650A:~ # nano -h
    + a7 U. X, m2 p7 B; m2 ?) N  |
  2. Usage: nano [OPTIONS] [[+LINE,COLUMN] FILE]...
    ) u# a3 k+ v+ J6 _6 N+ s0 k

  3. & |4 I" F' m' U
  4. Option          GNU long option         Meaning5 l, g7 |' l( G7 _& s, T( \
  5. +LINE,COLUMN                           Start at line LINE, column COLUMN" m3 O8 f' l) c1 a0 J" p; _, D
  6. -D             --boldtext              Use bold instead of reverse video text: h" _$ e; s! z9 n
  7. -K             --rebindkeypad          Fix numeric keypad key confusion problem
    4 k8 K  [; @) b# T( m4 h
  8. -L             --nonewlines            Don't add newlines to the ends of files! f7 m( X. h2 _- _( [6 F& M8 x
  9. -O             --morespace             Use one more line for editing
    ) w9 y1 t- F! g4 F9 u& _& k$ `
  10. -R             --restricted            Restricted mode
    ) A5 ?9 ?- z4 E' M
  11. -T <#cols>     --tabsize=<#cols>       Set width of a tab to #cols columns
    9 X! u+ t2 B9 p6 q
  12. -V             --version               Print version information and exit
    * I& C: ]0 o6 e
  13. -c             --const                 Constantly show cursor position
    & u/ v- m( E% H0 g" q5 j
  14. -d             --rebinddelete          Fix Backspace/Delete confusion problem
    7 Z& e6 a7 C4 F* g
  15. -h             --help                  Show this help text
    / j" M- y- D+ k1 \
  16. -l             --nofollow              Don't follow symbolic links, overwrite( p6 ?+ x8 v% S. k9 |) ?/ {0 p
  17. -n             --noread                Do not read the file (only write it)6 O! s* U$ ?# z) i
  18. -p             --preserve              Preserve XON (^Q) and XOFF (^S) keys- C# D$ q9 J* o5 {
  19. -t             --tempfile              Auto save on exit, don't prompt
    4 t4 {) |# A" t5 e$ o
  20. -v             --view                  View mode (read-only)
    ( ^6 n0 c, R; b
  21. -x             --nohelp                Don't show the two help lines
    9 g0 _: \" M) n; ], p# p2 R  y
  22. -z             --suspend               Enable suspension9 }6 O( ]$ O! p0 D
  23. root@F650A:~ # nano -V4 u. `, U" p, `; N: j
  24. GNU nano, version 2.4.25 V" _3 T$ `$ j9 s* T6 c$ j; [
  25. (C) 1999..2015 Free Software Foundation, Inc.
    : U9 }: }6 v. D* v: N) E
  26. Email: nano@nano-editor.org    Web: http://www.nano-editor.org/! s6 V3 ^$ |" p) Z
  27. Compiled options: --enable-tiny --disable-utf88 W8 m* {& m6 w* a, T* p
复制代码
  1. root@F650A:~ # dropbear -h' V  [. r2 K+ }$ c" ~) x
  2. Dropbear server v2015.67 https://matt.ucc.asn.au/dropbear/dropbear.html
      h7 q) V, S6 u+ E) z5 V9 a
  3. Usage: dropbear [options]
    ( ~5 s- B% K5 I. i+ x; c
  4. -b bannerfile   Display the contents of bannerfile before user login
    6 A# g% K& j. {0 q
  5.                 (default: none)
    , i0 O) ?9 A: O4 O/ M0 t
  6. -r keyfile  Specify hostkeys (repeatable)
    " T. s- l4 n, c6 q; g, Z& @$ B
  7.                 defaults:
    * K- \. q. V9 _* M4 H
  8.                 dss /etc/dropbear/dropbear_dss_host_key; _- `/ g. X  Y
  9.                 rsa /etc/dropbear/dropbear_rsa_host_key: n$ d: g* l3 ?1 G8 c
  10.                 ecdsa /etc/dropbear/dropbear_ecdsa_host_key
    : a! }; X8 e5 V5 A. D% L6 R
  11. -R              Create hostkeys as required
    ! o9 O9 e! k/ J; U1 N5 a: R
  12. -F              Don't fork into background% }7 E8 R7 I# O3 L! G6 s
  13. -E              Log to stderr rather than syslog
    ) g: P; Z2 o# m7 |: o; l! v5 I! }- u9 t& s
  14. -m              Don't display the motd on login% I" |+ s4 x6 M
  15. -w              Disallow root logins
    # x& p. V7 K9 k
  16. -s              Disable password logins, d$ j, A! c. C+ b6 @9 @
  17. -g              Disable password logins for root
    , _) D# W! B8 M; c
  18. -B              Allow blank password logins* d" I; x! j6 C. w$ A' f
  19. -j              Disable local port forwarding
    : j: @' [7 D) N% c  z
  20. -k              Disable remote port forwarding
    7 G" [1 D- y' \# b6 i" O
  21. -a              Allow connections to forwarded ports from any host
    4 g  v1 z7 |. r5 |: V8 F
  22. -p [address:]port$ L9 s+ h$ @5 H& Z% N( J* d
  23.                 Listen on specified tcp port (and optionally address),
    ; z* E9 o7 \5 N& w. i2 l, i
  24.                 up to 10 can be specified
    % e, y& j, \. n# C9 }! `) W8 e; C2 B
  25.                 (default port is 22 if none specified)! F6 O! W5 r& D; n! A8 [+ W
  26. -P PidFile      Create pid file PidFile1 [: ~. s1 W' b7 {$ n
  27.                 (default /var/run/dropbear.pid)
    3 `5 w0 y! t3 \5 Z
  28. -i              Start for inetd& f" s, r5 r0 O7 e+ T
  29. -W <receive_window_buffer> (default 24576, larger may be faster, max 1MB)
    , x4 m8 O# r0 d- ?+ C
  30. -K <keepalive>  (0 is never, default 0, in seconds)$ Q1 l. A% c$ M" s% x
  31. -I <idle_timeout>  (0 is never, default 0, in seconds)9 i" L" G" }. h8 `
  32. -V    Version
    - P. Z1 [1 F2 P2 v! I' D
复制代码

0 p/ y4 }2 R; k4 Y9 I6 t2 f; }! }

本帖子中包含更多资源

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

×
发表于 2021-11-27 21:38:54 | 显示全部楼层
本帖最后由 btworm 于 2021-11-27 21:41 编辑 # C6 A2 p4 _0 g' @+ i& J
songee 发表于 2021-11-27 04:15
$ m, N9 I9 w' D5 t; `/ ~: m0 U1.只要lxc相关命令可以正常运行,写好配置文件,选择符合CPU架构的rootfs,就可以把容器跑起来。
5 l4 I4 @! [/ r  c2 k0 m2.我的 ...

; F! Y) B7 v" n: {( x& X感谢指点!
! S& X! u8 c3 ]4 x: m
: t) j; X3 d4 K( k0 O关于第2点
6 h/ C% n& s0 |7 p华为光猫 / 只读,/etc,/usr,/lib这些目录也都依附于/, 所以都不可写, /opt目录不存在,当然也无法创建。6 F5 n2 k# ?0 f( M" w. J) F

* w6 U" c6 p; `5 F; n* u之前担心/dev/pts, /proc, /sys只读,是因为以前玩路由器时,有个chroot脚本使用过这些目录,刚又看了遍那个脚本,使用的是 "-o bind"参数,所以主机目录是否可写就无所谓了。在华为猫上跑lxc应该没问题了4 g4 f! y" Q: j( Z$ q7 m

: f8 h& o, Q9 J% g! y6 c' J2 Q; T另外想问问,光猫容器内的应用对端口的监听是:1 h/ E& @. P4 o9 B
1.直接监听光猫的端口?- Q  \. P9 `# c+ P, U
2.还是只能监听容器内的端口,并需要光猫iptables做端口转发给容器?
 楼主| 发表于 2020-2-22 18:37:10 | 显示全部楼层
anysoft 发表于 2020-2-22 17:502 G* w$ }! m5 b, Y  m% e/ D8 _
HS8145V HS8145V5  F650A 都是512MB+256MB 2.4G+5G方案
9 a! p1 V- k, m) p: C7 L3 @( T价格都还好,特别F650A 因为会玩的人少价格特别便 ...
, D5 @% q9 X, ]# e) C
hs8145v技术成熟,更适合玩,而且其实f650a是512/128,nand flash少了一半,CPU一个尿性,价格差别不大的话,能hs8145v还是别选650。; X  c6 `4 x0 O" N# y2 T$ [
还有个大胆想法,lxc可以通过配置文件config修改子系统网络,从eth0桥接是不是就能在子系统多拨了,子系统专门离线和网络存储,不影响猫后面接的手机电脑上网,还是蛮有趣的
7 A; ]8 A5 f" r$ R, k
- d' U1 Y  [4 E3 x4 P$ J+ S/ S$ b  n, j  q

! n; p5 t& V4 r: z
 楼主| 发表于 2020-2-17 02:19:26 | 显示全部楼层

二楼原帖,仅保留做参考

本帖最后由 songee 于 2022-4-27 21:17 编辑 $ A, k( T/ m- _) S4 n7 b; C, m; I

! [# }1 I# D6 F" }2 r. g; y7 l2 V& l. {8 m! ~2 O' q* i& v- O4 _
(2020年原帖初步摸索,过程过于繁杂,不建议再按这部分思路操作)
: ^, a+ ~& q$ ]: [中兴、华为等带有saf模块的光猫,以官方版openwrt替换厂商定制版的思路总结一下,供大家参考。4 s0 i( [9 u( |: r
1、准备工具
- v6 f/ I; U9 s6 {# r    F650A主系统没有 mtd 、 dd 和 vi 等工具,而自带的saf子系统正好都有,子系统位于framework分区即mtd6,挂载于/opt/upt/framework,cp过来可以直接使用。
root@F650A:~ # cp /opt/upt/framework/saf/rootfs/sbin/mtd /usr/bin/
/ j$ Q$ Y! e. Oroot@F650A:~ # cp /opt/upt/framework/saf/rootfs/lib/libubox.so /lib/
% O$ R/ [, O- n" u" C6 C2 ]root@F650A:~ # cp /opt/upt/framework/saf/rootfs/bin/busybox /usr/bin/
% T7 h# @% c1 |" S5 e) croot@F650A:~ # cd /usr/bin/
" X3 |( @  q% g% Uroot@F650A:/usr/bin # ln -s busybox dd
$ X5 z4 y2 L# z2 H) h: \3 hroot@F650A:/usr/bin # ln -s busybox vi

4 J2 p5 M; W3 E2、改进lxd-openwrt生成代码。
( l% O0 h' J& X/ W1 N8 V/ }    本节参考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如下
9 N1 E) z) {1 Q( q
*** build.sh                2020-02-19 01:50:10.972675562 -0100# h+ ~$ y7 G& [5 J0 O& t# p( K
--- build.sh.origin        2020-02-14 19:10:45.000000000 -0100
5 f; V) A0 P) ^+ f8 t***************0 m0 m. V1 Q  K9 o6 Y% k% t
*** 72,81 ****
* R% G( X1 E( f" W3 j8 ~! W5 H                  subarch=64
2 s6 W6 Z0 x- P8 c8 n                  arch_ipk=x86_64
% M7 ]4 J' s( g3 \3 @; ?( c- D4 t                  ;;
  C0 I7 b" q) z!         arm)
0 u; _( ^) l( y& b3 y!                 arch=bcm53xx) A: B2 S6 [4 [  h& p* v" S2 K* R
!                 subarch=generic
4 d9 o# c  t" F5 ]- Q7 K" S. q!                 arch_ipk=arm_cortex-a9' r8 l0 ~! \3 x5 c' |1 W# o/ l: ~) I2 Y
                  ;;
' q" y9 u" d: G- M( \3 U' H          *)3 N9 E, q9 T) |9 W% Z
                  usage6 m4 I; @3 o, N+ |. R! ^' S: t3 v1 T
--- 72,81 ----
, Y  B: M2 i4 V3 V* C% E                  subarch=64
, G( m  C' T. ^, V3 b3 Q# r; C                  arch_ipk=x86_64$ c/ L" s1 H+ i% Z2 m
                  ;;3 p7 L- O+ T8 e& W" G
!         aarch64)
# n% v' x6 K5 g' Z) n% V" D2 V4 U!                 arch=armvirt" _! a7 l. {& O  F: ~
!                 subarch=64
3 ]9 }' f4 K, `/ r1 \# h!                 arch_ipk=aarch64_generic7 C" I" b$ p5 Z* V) I% o/ `
                  ;;+ q5 T5 ^& W6 o5 m
          *)1 E, K: @$ q; {$ \
                  usage. W* J: [' R5 N0 u
***************2 b: v' v5 }5 L0 w. f
*** 87,97 ****1 |* c$ \6 k% u2 x- J! f/ `9 x
  if test $ver = snapshot; then
) u0 o0 [1 Y) a6 U4 l: H" Z          openwrt_branch=snapshot
2 x% X' R8 O& O- r3 d          procd_url=https://github.com/openwrt/openwrt/trunk/package/system/procd
# j2 s8 X- [' X!         openwrt_url=https://mirrors.cloud.tencent.com/lede/snapshots/targets/${arch}/${subarch}
* C2 }8 L7 Z  d/ o% N, X) Z  else9 G! C* o& x' q- Z, G; Y: K) {
          openwrt_branch=${dist}-${branch_ver}# K3 i3 N' N/ q: F2 i. x
          procd_url=https://github.com/openwrt/openwrt/branches/${openwrt_branch}/package/system/procd
' o" M. [+ _/ ]: d3 N0 T6 C% ^!         openwrt_url=https://mirrors.cloud.tencent.com/lede/releases/${ver}/targets/${arch}/${subarch}
; c& ]4 A) u9 T  fi  p! D8 J9 |" u9 Z5 ?! v
  
4 O: l' P5 S' q+ R- u  procd_extra_ver=lxd-3
7 Q' Z1 D* E! ]; I--- 87,97 ----
8 v$ _* z8 U  M+ t0 q  if test $ver = snapshot; then  t6 w% c2 j$ p
          openwrt_branch=snapshot, D# |! x, W1 N+ n' t
          procd_url=https://github.com/openwrt/openwrt/trunk/package/system/procd
+ I) n/ T8 v/ L1 w& H!         openwrt_url=https://downloads.openwrt.org/snapshots/targets/${arch}/${subarch}
2 y4 W0 Y+ E/ U" h8 ^8 q: i. |  else: X" p& c; e; E" V$ X7 z( }. W+ Q( Z
          openwrt_branch=${dist}-${branch_ver}
3 A7 k6 s% q, k  x1 p7 c3 z* E          procd_url=https://github.com/openwrt/openwrt/branches/${openwrt_branch}/package/system/procd
1 G8 W- J; f5 i" G* q!         openwrt_url=https://downloads.openwrt.org/releases/${ver}/targets/${arch}/${subarch}
0 Y2 K& \$ o- ?# k  fi; v. X8 A9 K9 T
  + \/ M! ?+ ]' N
  procd_extra_ver=lxd-37 ~2 C2 z6 f5 C2 d  G, E
***************
4 Z& V+ ~& D9 z6 v*** 112,125 ****
# J8 s# s9 G; e. W# L  }# |- D8 {% @0 c6 N. ~
  7 ?; z* a# R; g; `" a
  download_rootfs() {8 i/ |  _* o& x' I9 z( C) E0 R
! #        detect_url "rootfs\.tar"9 V9 I* v3 m( E" q5 o+ X7 L
! #        local rootfs_url=$openwrt_url/$return) b% B0 ]  o+ }7 r
  * x4 d& G. j8 l2 J5 `. n$ ^
          # global $rootfs
% |, b& c5 y* l- _8 m2 [: c!         rootfs=dl/openwrt-19.07.1-bcm53xx-generic-rootfs.tar.gz1 C/ C# x, b" H" v' `% w. @
  $ e0 z5 {  s' Z4 o% ^0 N2 X8 i
! #        download $rootfs_url $rootfs $rootfs* N2 q$ v. @) V( r- i
! #        check $rootfs $rootfs_url
# [* G+ D" _3 g: B* I3 r5 R  I  }% y8 d0 c& F# v& |
  # i1 W4 W" Z7 J) h9 `5 |% t) R
  download_sdk() {, ?6 G! k4 m/ ?5 l5 f0 U' c3 j1 h$ g' W
--- 112,125 ----
* ]. F2 d/ z& Y/ c/ l4 F  }
% b! U8 o1 K$ U  7 Z* x" W; l9 b3 {
  download_rootfs() {
  G- X7 J( n) i& A5 `4 J!         detect_url "rootfs\.tar"
7 w# i. e! m5 n7 F8 ]" ]!         local rootfs_url=$openwrt_url/$return
) }( y# L4 K8 c# e& [  " P, l, H) C9 M1 }, Y/ I3 t9 Z
          # global $rootfs. Y: X' N& ]/ F. W$ ^
!         rootfs=dl/$(basename $rootfs_url)* s, `5 J8 h1 W7 R2 M0 z- E
  2 Z0 Z& b& d6 I  g* u2 m0 {
!         download $rootfs_url $rootfs
, k& E+ w- Z  _1 I8 f!         check $rootfs $rootfs_url
& A  v) T' Q  ^& N( A9 k; N  }0 y! l, K% C5 E# E* H; }
  
* w6 F) i/ k4 f$ {! D! ~  download_sdk() {

7 z& A; N5 r* ?) ~4 h3、从腾讯镜像下载openwrt-19.07.1-bcm53xx-tplink-archer-c9-v1-squashfs.bin,从固件中提取rootfs并预处理。6 N( [! E  Y) D8 |+ Z- w
  1. x@x-Surface-Pro-3:~/下载$ binwalk openwrt-19.07.1-bcm53xx-tplink-archer-c9-v1-squashfs.bin
    8 d" L4 k$ _' H  `( ]

  2. 9 q& M( \- u. p; D9 h8 n
  3. DECIMAL       HEXADECIMAL     DESCRIPTION
    2 y3 F, q0 a! A  A& n: ~$ H
  4. --------------------------------------------------------------------------------  T! O- `0 D# K8 M: {
  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: 0x00 B% |/ A, X, k; g% f
  6. 8345          0x2099          LZMA compressed data, properties: 0x5D, dictionary size: 65536 bytes, uncompressed size: 1801662 bytes% S8 F6 C  \; b* B4 E* X7 z
  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
      T0 E3 i1 t9 a% {
  8. ; X$ ~2 {. W0 {1 r
  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
    5 {+ ~% b+ i( N" u3 U& B1 j
  10. 记录了1900548+0 的读入
    ' P( ~4 j! \* p# f" [
  11. 记录了1900548+0 的写出
    . b1 S; I! U) s" l3 L
  12. 1900548 bytes (1.9 MB, 1.8 MiB) copied, 5.16823 s, 368 kB/s2 H) q& H8 e; o
  13. x@x-Surface-Pro-3:~/下载$ binwalk rootfs-squashfs.bin 6 Q2 n% D! F% m0 z

  14. . i/ u% v$ |% f* r0 U
  15. DECIMAL       HEXADECIMAL     DESCRIPTION
    : y! u. x: l* y( v% u# b9 a  }; y) o3 A
  16. --------------------------------------------------------------------------------
    - p9 D$ `8 q3 z: k: s! h
  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
    " s) H! u! o) h- x7 y. n+ c
  18. 7 w/ i. c3 A# e0 T
  19. x@x-Surface-Pro-3:~/下载$ unsquashfs rootfs-squashfs.bin ) L* B9 E! ?" P
  20. Parallel unsquashfs: Using 4 processors
    " [4 u3 y$ {/ }( ?7 C) `, m
  21. 1071 inodes (1066 blocks) to write" T2 L& T' `. e5 |8 i( @1 V
  22. ( P# N3 H% G# Z8 D/ [/ ^! o! Y% ?! [
  23. ( x, B" W7 h% }' s& k
  24. create_inode: could not create character device squashfs-root/dev/console, because you're not superuser!
    7 F7 W5 J/ @7 B) W5 g/ J
  25. [====================================================================================================| ] 1065/1066  99%
    0 @4 s4 S# `; P
  26. & H5 q( A  U! G# D4 k/ l  `
  27. created 875 files
    * w7 l! i9 t4 ]+ a  k8 \4 H8 r
  28. created 103 directories& G8 \. A8 O0 H& N( i, X$ Z* E
  29. created 195 symlinks8 J/ g$ d/ p# [
  30. created 0 devices
    8 l. Z! d  Y. i6 ?; p1 i
  31. created 0 fifos3 ?7 V7 g, }! k
  32. x@x-Surface-Pro-3:~/下载$ cd ./squashfs-root/$ O  V, R% D1 [" \+ p. Q5 O
  33. x@x-Surface-Pro-3:~/下载/squashfs-root$ gedit etc/opkg/distfeeds.conf
复制代码
将opkg软件源改为腾讯镜像
  u8 k- S) ^' f  O. I- ?' B# k
src/gz openwrt_core https://mirrors.cloud.tencent.co ... xx/generic/packages
& S! a4 _" x' I9 L/ Msrc/gz openwrt_kmods https://mirrors.cloud.tencent.co ... 92b7d7eca715b1ee0b8
7 q+ T( j9 G) Ssrc/gz openwrt_base https://mirrors.cloud.tencent.co ... /arm_cortex-a9/base) v! f+ U+ }5 V, k
src/gz openwrt_luci https://mirrors.cloud.tencent.co ... /arm_cortex-a9/luci! L/ ]# ]( m+ g
src/gz openwrt_packages https://mirrors.cloud.tencent.co ... _cortex-a9/packages
; j0 C/ G, r# G# L6 q$ Esrc/gz openwrt_routing https://mirrors.cloud.tencent.co ... m_cortex-a9/routing( p! e6 B0 t) X5 s9 {- D
src/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 ./
    * Z, N  Y5 c3 ]; J' j6 ]
  2. x@x-Surface-Pro-3:~/下载/squashfs-root$ cd ../) m6 N2 _9 ?( k3 r
  3. x@x-Surface-Pro-3:~/下载$ mkdir lxd-openwrt-master/dl
    : c% A; D5 q2 S( X
  4. x@x-Surface-Pro-3:~/下载$ mv openwrt-19.07.1-bcm53xx-generic-rootfs.tar.gz lxd-openwrt-master/dl/
复制代码
执行修改过的build.sh7 ^: C9 r0 O( l' q; p% f7 L
  1. x@x-Surface-Pro-3:~/下载$ cd lxd-openwrt-master/- ]0 }" {4 f& U; {1 ?# j5 O0 w0 D  z6 X
  2. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ ./build.sh -a arm -v 19.07.1. i+ G/ T0 N" k$ d4 R0 o; X0 M7 B
  3. ......
    ) _% V. _9 T9 v, b+ e2 o  u5 r
  4. Pack rootfs
    9 P0 q1 b7 s4 ^- ~
  5. Tarball built: bin/openwrt-19.07.1-bcm53xx-generic-lxd.tar.gz: P% M$ q3 _3 ^/ Y4 x9 X7 n# E/ S
  6. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ mkdir ../openwrt-19.07.1-bcm53xx-generic-lxc5 g  p; m8 [7 N& J! T5 v
  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
    : k2 j" x. q" L* W2 x0 w+ {) q
  8. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ cd ../openwrt-19.07.1-bcm53xx-generic-lxc/9 i6 C: G1 \" `& I+ [
  9. x@x-Surface-Pro-3:~/下载/openwrt-19.07.1-bcm53xx-generic-lxc$ ls
    ; y- |% \0 w, u7 R
  10. metadata.yaml  rootfs  templates
    0 V' z2 G. h6 Q- }0 h
  11. x@x-Surface-Pro-3:~/下载/openwrt-19.07.1-bcm53xx-generic-lxc$
复制代码
' |5 b  `7 z* |- Z
4、这时我们已经创建好lxc下可运行的openwrt19.07.1的rootfs,接下来处理lxc及rootfs的配置文件。
% U  D' }# C0 L9 g进光猫复制自带子系统的两个文件,再通过U盘或ftp传到Ubuntu的openwrt-19.07.1-bcm53xx-generic-lxc目录下,
* Z; E/ u. @5 K% y+ _- J9 B& y
  1. root@F650A:~ # cp /opt/upt/framework/saf/config /mnt/USB_disc1/! d6 c" @/ O8 _) D8 p9 r2 p! t  v
  2. root@F650A:~ # cp /opt/upt/framework/pre-start.sh /mnt/USB_disc1/
复制代码
config为saf系统的配置文件,新系统下稍作修改,- q5 g' a& l( Q7 Q
lxc.arch = arm
- t, U/ m: s) M6 A# M" O- Vlxc.utsname = openwrt
1 z: r8 X0 I8 mlxc.rootfs.mount = /usr/var/lib/lxc/openwrt/rootfs% o% Z; a  m6 T' E2 S
lxc.rootfs.path = overlayfs:/opt/upt/framework1/rootfs:/opt/upt/apps/openwrt-rootfs ( Q& M5 k% p- ?" E
# lxc.rootfs = /usr/var/lib/lxc/openwrt/rootfs
& t  J: z8 m( Klxc.haltsignal = SIGUSR10 [% W* B: K3 F8 \7 H" M/ V; v
lxc.tty = 1. f  l& P' U( _& Z( T
lxc.pts = 1
$ M0 E9 c# P/ z1 D9 rlxc.hook.pre-start = /usr/var/lib/lxc/openwrt/pre-start.sh/ ?  f; r! j, U( |8 S7 x& [6 a# m
lxc.aa_profile = lxc-container-default-with-nesting* y3 V/ t+ @6 M5 r! r
lxc.network.type = none' e: s. D. \; }1 A* D: n% n
lxc.mount.entry = sysfs sys sysfs defaults 0 0
3 K7 M; ^) u" |* q6 n+ ~lxc.mount.auto = cgroup-full:rw
: N- J, U3 u  j) g# Tlxc.mount.entry = proc proc proc defaults 0 0
6 Z4 a  k. X' @7 Elxc.mount.entry = /mnt mnt none rw,rbind 0 0
/ x; R8 a( [3 M, r* V) Mlxc.start.auto = 1
; \# X8 L' b1 z: Y3 C" s3 j/ v
pre-start.sh处理模拟终端,为避免重复挂载devpts,添加一行卸载代码,
$ _* o7 o% @4 q- B
#!/bin/sh3 o; [! b: ~; v
umount /dev/pts /dev/ptmx
  r. c) ?" P5 {, H: V# emount -t devpts -o newinstance -o ptmxmode=0666,nosuid devpts /dev/pts
/ `' Y! l2 K# M7 Y% `+ S2 o. i7 q/ dmount -o bind /dev/pts/ptmx /dev/ptmx

3 M# ~* ?: X6 T再删除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镜像,  U! P6 h, n. a4 r
  1. x@x-Surface-Pro-3:~/下载$ mksquashfs openwrt-19.07.1-bcm53xx-generic-lxc openwrt-19.07.1-bcm53xx-lxc.bin8 r0 m- f% f$ v. Z: `, {
  2. Parallel mksquashfs: Using 4 processors
    , D8 n! J4 g; i+ d2 B
  3. Creating 4.0 filesystem on openwrt-19.07.1-bcm53xx-lxc.bin, block size 131072." ~9 d, q' c8 S. {+ N
  4. [=======================================================================================================/] 881/881 100%
    & r- q4 G2 L" s5 G  {

  5.   j( @1 ?# Q- H- Y
  6. Exportable Squashfs 4.0 filesystem, gzip compressed, data block size 131072
    9 v9 e: i7 R2 p( E) Q/ X
  7.         compressed data, compressed metadata, compressed fragments,
    $ y  o1 Q" a: h  s- `. Z' Z; _
  8.         compressed xattrs, compressed ids. d- Z" I3 T1 H) ?; x3 f
  9.         duplicates are removed  J, k" G9 G; W* O
  10. Filesystem size 3163.90 Kbytes (3.09 Mbytes)4 @3 D, m1 C# x6 Q! }* W
  11.         48.94% of uncompressed filesystem size (6464.54 Kbytes)
    + K' A' G  D; h' H2 }) L$ Y
  12. Inode table size 9693 bytes (9.47 Kbytes)/ \, c3 I) D4 u7 }1 D* l. g
  13.         25.72% of uncompressed inode table size (37693 bytes)
    3 n/ f) D3 q+ O5 [* N9 h
  14. Directory table size 11372 bytes (11.11 Kbytes)& v9 F" K, a* J
  15.         47.17% of uncompressed directory table size (24108 bytes)
    & s# {8 w, h3 z$ P& z6 {
  16. Number of duplicate files found 136
    / s& m! h6 N& X
  17. Number of inodes 1145$ _$ d- a1 K) j  h) V# G' U
  18. Number of files 8738 q) k  Z: k0 m4 _
  19. Number of fragments 39
    / b- @3 N) q( h/ S/ l- r, D
  20. Number of symbolic links  171
    ; z* k) Y' N* \  Z; m
  21. Number of device nodes 07 E2 Y9 \8 z( i& C  D
  22. Number of fifo nodes 0
    ! k4 S% m& v2 @& {' Z  u
  23. Number of socket nodes 01 g, C( K/ G* e) U! k) k
  24. Number of directories 101# N7 ?' ~& q( b' x
  25. Number of ids (unique uids + gids) 1
    , s* q3 @& R- Y
  26. Number of uids 1
    7 r2 j' Q, u; E4 P
  27.         x (1000)
    ) ?4 O1 i/ D9 E- C
  28. Number of gids 1
    1 d+ w2 y/ o' t) A0 e1 c: R! Z$ ]
  29.         x (1000)5 ^) S0 s8 a2 W0 C
  30. x@x-Surface-Pro-3:~/下载$
复制代码

- S; O& g4 q! J7 v! m0 l3 x! a8 h! l% {5 N- s% n0 M. m2 q
5、生成的openwrt-19.07.1-bcm53xx-lxc.bin传入光猫,'mtd' 写入mtd7分区。9 S3 l* z) U' A5 \, Q
刷之前先关掉saf,因saf有lxc-monitord进程守护,kill掉之后会自动运行,只好修改saf程序名,重启光猫。
0 M. x8 u  p4 y4 z- f! A9 ?
  1. root@F650A:~ # mv /usr/sbin/saf /usr/sbin/saf.bak4 o) ]; g  }1 k2 O
  2. root@F650A:~ # reboot
复制代码
重启后telnet登录,'ps' 确认进程列表没有saf,备份然后写入并挂载。
root@F650A:~ # ps
; m9 z6 l* ^# E' j1 h6 J% Y  PID USER     VSZ   RSS  STAT  CPU COMMAND& |# n1 p! x$ q+ `
    1 root     23160   600  S     <1>  init3 Z* O" ~4 M8 g1 ]3 ]
    ......
8 x* s, G8 s; B$ x/ p+ q& T8 mroot@F650A:~ # dd if=/dev/mtd7 of=/mnt/USB_disc1/mtd7.bin bs=1M0 c3 N3 u& r, `. L
8+0 records in
& Z% }( J' z- f, \% Q, q0 f% x8+0 records out
) `/ u- @# I$ `) p- oroot@F650A:~ # mtd write /mnt/USB_disc1/openwrt-19.07.1-bcm53xx-lxc.bin /dev/mtd77 U0 F3 z- y% J
Unlocking /dev/mtd7 ...' @1 Z2 I- ?2 y: C4 q* J4 G
( y8 h" u* b, o# c; v0 l4 q9 B+ F
Writing from /mnt/USB_disc1/openwrt-19.07.1-bcm53xx-lxc.bin to /dev/mtd7 ...
5 {4 q$ o( a2 v& u! ?, F, Proot@F650A:~ # mount /dev/mtdblock7 /opt/upt/framework1

7 C( _1 `, H  l2 s6、开启OpenWRT新世界
6 |9 E) d; e' t    写入mtd7分区并挂载之后,开始首次启动的准备工作。F650A的lxc默认路径在/usr/var/lib/lxc(一楼有说明),按config文件创建相应文件及文件夹,: T  X$ S- `0 U. w* G) a( M7 Q

  m  {1 x6 W' d: k
  1. root@F650A:~ # mkdir -p /usr/var/lib/lxc/openwrt
    ' S9 {. Z4 P" n
  2. root@F650A:~ # cd /usr/var/lib/lxc/openwrt
    : L1 s' ~, v+ }) t4 U
  3. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/pre-start.sh pre-start.sh( W) G& O* O9 V: [$ a( l( X9 i$ k
  4. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/config config
      P) N, r& M/ ~1 q' r, I# F1 \
  5. root@F650A:/usr/var/lib/lxc/openwrt # mkdir rootfs
    8 B% s6 z7 t# [# |
  6. root@F650A:/usr/var/lib/lxc/openwrt # mkdir /opt/upt/apps/openwrt-rootfs
    0 T  Y' o0 R+ _
  7. root@F650A:/usr/var/lib/lxc/openwrt # lxc-start -dn openwrt! l3 Z/ {% x) c7 Z+ h, ~+ e, Y
  8. root@F650A:/usr/var/lib/lxc/openwrt # ps
复制代码
此时的进程列表应该可以看到/usr/sbin/uhttpd、dropbear等,或者可以尝试打开浏览器 http://光猫ip/或ssh登录,如果看到Authorization Required提示登录或ssh提示登录用户名密码,表明lxc已成功运行,但此时无密码状态无法网页和ssh登录,只能通过控制台方式添加密码后才能实现。关闭openwrt容器,'ps' 确认,前台启动。* m( k/ f( B8 M2 h
  1. root@F650A:/usr/var/lib/lxc/openwrt # lxc-stop -kn openwrt) k, A. |  B' n0 b
  2. root@F650A:/usr/var/lib/lxc/openwrt # ps
      ]- L6 Z; ^& h. M  ~0 P' k
  3. root@F650A:/usr/var/lib/lxc/openwrt # lxc-start -n openwrt
      k: Z' H  O# z& b% P
  4. <6>init: Console is alive
    # D' p/ F* t+ n0 }" H" \7 M' v
  5. <6>kmodloader: loading kernel modules from /etc/modules-boot.d/*
    : z, Y# S3 L. i" H, ]! }
  6. <6>kmodloader: done loading kernel modules from /etc/modules-boot.d/*0 l( ]+ q6 @) a
  7. <6>init: - preinit -3 {8 I' B: {( g# s/ E+ x. E8 @
  8. WARNING: Variable 'network' does not exist or is not an array/object
    7 t% Y: ^2 |  B# F& h, @
  9. WARNING: Variable 'lan' does not exist or is not an array/object
    9 B. c/ D. z- `6 i
  10. Press the [f] key and hit [enter] to enter failsafe mode( h( f% P" x( B
  11. Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
      o5 _3 W: C3 l% ?
  12. <5>mount_root: mounting /dev/root5 {) C/ G) |  q
  13. urandom-seed: Seeding with /etc/urandom.seed
    / U- D6 ~' i6 s" H6 p3 m
  14. <6>procd: - early -
    # b, F+ m+ @/ D
  15. <6>procd: - ubus -
    & u$ ^+ h" g- r2 K0 I
  16. <6>procd: - init -
    $ M: T# ~9 N. M3 t8 t( `( J" ^
  17. Please press Enter to activate this console.
    ; _" Y0 V2 c3 B7 \
  18. <6>urngd: v1.0.2 started.
复制代码
此时回车便可看到openwrt的登入界面,添加密码。, v2 p" c& I  ?) G% W4 d+ m6 _
  1. 3 F6 O; N2 k+ `3 \) `- w9 ?
  2. BusyBox v1.30.1 () built-in shell (ash)$ R5 ~0 N7 W3 k3 R

  3. # m2 ^/ S# H7 E  D8 @9 s
  4.   _______                     ________        __. U/ n7 E8 s2 W) i2 y6 p( C
  5. |       |.-----.-----.-----.|  |  |  |.----.|  |_
    $ U- u# j: Q  h  Y& G
  6. |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
    ! H7 ~' m3 O/ j) o
  7. |_______||   __|_____|__|__||________||__|  |____|
    . V' M: x& U0 Q
  8.           |__| W I R E L E S S   F R E E D O M
    0 s+ W6 b+ _4 J+ B. ^# P; D
  9. -----------------------------------------------------$ X! U7 Q* t4 c  w% g' P
  10. OpenWrt 19.07.1, r10911-c155900f66: a2 H( C9 o5 ^& U7 ~) }; w5 `
  11. -----------------------------------------------------; F; o& a. Z. H  O* d$ E5 n
  12. root@openwrt:/# passwd root1 ^. d. \9 P: G* G/ E
  13. Changing password for root
    2 h7 x3 U; z$ Z- z: e' s
  14. New password:
    ! m2 L- s% {. {9 \
  15. Bad password: too weak& t4 m1 ~" C7 U1 X
  16. Retype password: ) u0 q& E0 ?: T6 X
  17. passwd: password for root changed by root: Q! S9 t* c: J) h  m4 z! \
  18. root@openwrt:/# exit" e; i$ Q6 y- p- G. Y! B5 p: G
  19. Please press Enter to activate this console.
复制代码
控制台方式进入openwrt之后,exit无效,没找到正常的退出方式,只能关闭窗口,此后就可以通过网页和ssh正常登录。
7 v& H6 d2 U, ]) d$ s; r
2 N- j4 Q" ~9 v* W' ~7、自启动及进程守护6 m4 w0 G1 f  o7 J' u8 i4 F: g# A
    telnet登录光猫主系统,确认saf程序已备份,
- g& d) w3 l6 T* x- l
% ?4 c, R/ U8 ?
  1. root@F650A:~ # ls /usr/sbin/3 m6 E9 ]; b4 r- e  b
  2. chroot       lsap         saf.bak      telnetd* q" q3 }: y$ \
  3. root@F650A:~ # vi /usr/sbin/saf
复制代码
填入 (2021年5月更新:去除USB端口挂载判定,避免无挂载时LXC不能启动)$ d0 H/ i# R- u! M, [+ |  ~, d7 _+ H
#!/bin/sh7 g! P, k5 u* n/ |
# add user-defined startup scripts here
, }" a$ f% V9 ?
# w# x2 a3 o+ q9 i. P/ a' s0 Y6 }  df | grep mtdblock7
$ }& s" ]4 S8 t" h$ \( s  if [ $? -ne 0 ]
2 [) {0 x) Q. t4 T    then! m0 i' }+ m' c3 V3 g
      /bin/mount -n -t squashfs -o ro /dev/mtdblock7 /opt/upt/framework1
2 j6 V/ j8 z7 f; ~- |8 t1 k( N  fi: g6 l$ ~+ H4 T; Q7 ]. D! m# X
##( ]  c! u6 e" I6 w/ {

) c7 B: ], W( S0 j; Z8 Z#  ps | grep ntfsmount | grep -v grep
9 k5 q( W3 H1 Q% f; d& m#  if [ $? -eq 0 ]+ V$ u/ ]% E# p) f/ I
#    then
! y7 G* v9 U5 [      /dbus/usr/bin/lxc-start -dn openwrt
8 l5 S3 C+ a; p  j6 v! h& G- y#  fi/ G% n2 p. G0 K; [4 S
##

# |4 Q3 }/ w5 o1 I# l& Q' U/ U" }或者在电脑编辑好内容,命名为saf,传入/usr/sbin/,'chmod +x' 添加执行权限,重启光猫。3 s" b: d/ b" g! R$ b* ?" N. `0 S0 l

! Y+ U8 N* K3 [5 i& b5 ?" e8、后续问题
4 O4 R4 v8 `9 I+ M5 J  C- C7 e8 U- W    目前的openwrt安装或更新程序会报错,缺少 libustream-openssl 、ca-bundle 、ca-certificates 和 libopenssl1.1,还需要修改dns,添加中文等
$ {$ m/ |, @  H( V9 S# H4 t. ^# ]' r0 l+ ^( E/ f5 f4 M! G
  1. root@openwrt:~# opkg update4 x& F) p/ ~! R: T4 |
  2. Downloading https://mirrors.cloud.tencent.com/lede/releases/19.07.1/targets/bcm53xx/generic/packages/Packages.gz5 P9 s8 Z' }. s$ N
  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.
    + N. S" a3 U( k: v
  4. *** Failed to download the package list from https://mirrors.cloud.tencent.com/lede/releases/19.07.1/targets/bcm53xx/generic/packages/Packages.gz
复制代码
这些安装包可以从腾讯的镜像站下载然后手动安装。  Y$ E, K) ^( I8 O0 V
  1. root@openwrt:~# cd /mnt/USB_disc1/) {* R6 m& ?, n3 g2 j2 z
  2. root@openwrt:/mnt/USB_disc1# opkg install *.ipk
复制代码
修改dns! \1 @3 `- b  o* b1 f
  1. root@openwrt:/mnt/USB_disc1# rm /etc/resolv.conf* p& P# A0 e9 f0 {
  2. root@openwrt:/mnt/USB_disc1# vi /etc/resolv.conf
复制代码
填入,保存
8 j' N1 I9 \4 k9 \- Y
nameserver      223.5.5.5/ X% ~# o- k% @/ C; ]) P  V
nameserver      8.8.8.86 b% w9 S1 e$ k( U
nameserver      2001:da8::666

2 }9 H7 t: D6 [5 Z嫌过程繁琐的可以直接下载我配置好的镜像,从第5部分最后开始操作,将下载的openwrt-19.07.1-bcm53xx-lxc.bin和saf-lxc-start-openwrt放入光猫上的u盘,子系统默认root密码123456。% |. E# v/ i, ?0 w& n6 N; `- i
  1. root@F650A:~ # dd if=/dev/mtd7 of=/mnt/USB_disc1/mtd7.bin bs=1M
    # e: h; I( W7 g1 x8 ]& Z
  2. root@F650A:~ # mtd write /mnt/USB_disc1/openwrt-19.07.1-bcm53xx-lxc.bin /dev/mtd7
    3 p3 R, J6 e/ X& {
  3. root@F650A:~ # mount /dev/mtdblock7 /opt/upt/framework1
    $ X! }' ^% ^6 o  p; ^8 C8 _
  4. root@F650A:~ # mkdir -p /usr/var/lib/lxc/openwrt
    2 |$ `+ m* Q- b, o0 g
  5. root@F650A:~ # cd /usr/var/lib/lxc/openwrt  B0 J  s8 x/ M! R* T. @
  6. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/pre-start.sh pre-start.sh) W3 ]7 I5 r0 A6 I' U+ V* A- f! q) l
  7. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/config config  P' B4 Z7 i4 ~8 ]" X" G* O) ^" y# f
  8. root@F650A:/usr/var/lib/lxc/openwrt # mkdir rootfs
    % c- n7 F' r/ `' X1 I8 j
  9. root@F650A:/usr/var/lib/lxc/openwrt # mkdir /opt/upt/apps/openwrt-rootfs
    , i/ @" ?( w) e) V+ R& S7 E/ M, c
  10. root@F650A:/usr/var/lib/lxc/openwrt # lxc-start -dn openwrt
    ! t. ^& w: M0 z9 G" a  c* {
  11. root@F650A:/usr/var/lib/lxc/openwrt # cd ~ 6 r* C; |  k9 u& A
  12. root@F650A:~ # mv /usr/sbin/saf /usr/sbin/saf.bak  G+ {0 L, A) a5 K& F5 s' O# r
  13. root@F650A:~ # cp /mnt/USB_disc1/saf-lxc-start-openwrt /usr/sbin/saf
    3 I$ ]5 Q- }; s; X
  14. root@F650A:~ # chmod 0755 /usr/sbin/saf
复制代码
   虽然子系统的openwrt可以顺利运行,但经过我的测试,kmod类app大多无法正常工作。比如F650A内核不支持ext4文件系统,在子系统安装kmod-fs-ext4,尽管可以安装成功,但重启后提示 modprobe 启用ext4模块失败。
0 P9 M, J3 S# M0 u        子系统的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管理页面,需要更改光猫主系统,此操作的定制空间更大,有机会的话在后面回复中整理出自定义光猫固件的思路。7 j2 e3 p' a. m, \5 E4 ^  Q  Z
# a  f8 t+ I6 Y* p; A

本帖子中包含更多资源

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

×
发表于 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刷进去的?
1 _: e3 j% E* p" Q: s- U7 {$ E中兴非15.0.1出问题是你没清理/opt/upt/apps//apps目录
- ~! `0 |, t8 V2 _+ `1 N* w* K几乎所有光猫为了节省空间?都会有部分lib和var目录重用主系统的文件,openwrt下e8clib和e8cvar可以看看。
0 w! H; o9 H! [0 r另外中兴编译的openwrt开始了uclibc的xlocale配置,这也是achaoge直接用omap源的APP无法运行的原因,我自己有手动开启xlocale后编译omap的openwrt放进去运行OK。
+ ~3 B( V; p4 C! X/ l有兴趣可以一起研究玩。
 楼主| 发表于 2020-2-20 21:40:34 | 显示全部楼层
anysoft 发表于 2020-2-20 12:58% H1 M0 }+ d1 x
坐等lxc的教程,另外19openwrt是你自己编译的还是直接下载armv7的官方bin刷进去的?
7 k* r3 T- K0 o. z& g+ R4 |  M: C中兴非15.0.1出问题是 ...

: v/ G6 }9 ]3 Z- B7 b: D# r
" v6 h: D$ c, s% ropenwrt1907用的官方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
, h/ V; ~  F, ?& }' {) Q  zopenwrt1907用的官方rootfs经https://github.com/mikma/lxd-openwrt修改而来;xlocale的问题我在编译主 ...
# b5 p& p& u  W! R1 z/ A8 ]) o
是的, 中兴使用的是buildroot-2015.8.1,这个strings 一下sendcmd 就可以看到
/ S. `; w5 Q7 o. V# l+ o% [+ _
# L6 j# C# e; J: P, K看了下操作步骤,其实如果内存足够,没必要关闭saf启动的天翼网关。, Z- |/ M' a; g% |. j1 E2 \5 z
可以让lxc容器启动两个op应该是可以的,F650A和华为hs8145V应该都是512MB内存,内存足够,openwrt可以放到apps分区文件夹下,不一定要写入mtd7再手动挂载。
* Z$ ]" m' C% E: _) W6 W
7 R: N  k  U# W3 i+ H' C我的HS8145V启动后内存只占用了30%,足够了。; i$ m0 L7 m2 T' @

$ f& m. N! S& f- U9 z+ {6 p另外主系统下的usr/sbin目录下文件不是内存加载的rootfs对应的squash文件?这个更改应该不会回写到文件系统,重启应该就会消失?; c3 `, Q! e+ r# n% V- n5 i" F7 [
不晓得中兴和华为是不是一样的。可能中兴可以修改文件吧,华为的只能dd备份rootfs分区后自己解包修改打包后再dd写进去,会有砖的风险,砖了只能上编程器。- R. d/ |( c; h# D- G  g6 }
, ?; W; k/ ^7 Q4 \* h
至于端口问题可以在打包openwrt的时候先修改每个服务对应监听端口就不会冲突了。
6 T* M0 S, p" l% N0 M

本帖子中包含更多资源

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

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

本版积分规则

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

GMT+8, 2025-5-1 07:48 , Processed in 0.044874 second(s), 8 queries , Redis On.

Powered by Discuz! X3.5 Licensed

Copyright © 2001-2020, Tencent Cloud.

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