找回密码
 注册

QQ登录

只需一步,快速开始

查看: 76177|回复: 93

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

  [复制链接]
发表于 2020-2-17 02:14:04 | 显示全部楼层 |阅读模式
本帖最后由 songee 于 2022-4-27 21:04 编辑
) N$ s% T/ D0 \/ S# U8 R8 G9 ^9 g  ^- L( q3 r0 C+ [, C; S1 T
家里装宽带,电信200M,送了个中兴F650A。自带的天翼3.0web界面看着不错可惜几乎没有可玩性,闲来无事研究一番。
8 M: S! s' v; U, `7 r+ K3 ?    借鉴论坛前辈achaoge的帖子:中兴 F450A/F650A 免 TTL 持久开 ssh顺利开启telnet,发现该光猫的运作机制是 主系统负责底层的硬件驱动、sendcmd管理系统(telnet、超密、ppp拨号、网络及WiFi、ftp等)、以httpd为基础的8080端口电信web管理界面,最后启动saf(lxc容器管理)程序。' t% @9 l/ `! d0 l; j. G) G3 I
    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数据存放区,操作时需要特别注意!!
- Y7 o3 ^, |! c" {5 `$ y; ~2 j
  1. root@F650A:/usr/sbin # saf; f! O- |4 o% C' ], i
  2. Usage: saf service FWK_MTD_ID1 FWK_MTD_ID2 APPS_MTD_ID (eg. saf service 9 10 7)
    9 n7 z% D  S8 a( u
  3. saf console) i' P( K/ E3 {! P! s- z
  4. saf info
    " U9 G4 k+ F' a$ l* ^8 F
  5. saf version
    4 f( w1 c1 v/ E
  6. saf getfwkver
    4 c0 h0 p' S* e- k8 x* W2 ]
  7. saf getbakfwkver
    ' v# p8 ~! {0 U9 n1 a# Z& u6 a
  8. saf getactive
    ) `& q( Y/ [! [
  9. saf setactive FWK_MTD_ID [AFTER_REBOOT] (eg. ./saf setactive 17 1)
复制代码
  1. root@F650A:~ # cat /proc/mtd
    2 g) I. o/ A8 g/ M; T  d* C
  2. dev:    size   erasesize  name
    ( s3 p/ x% G1 O/ x
  3. mtd0: 08000000 00020000 "whole flash"
    % ~( E2 X; P- B% @' _( Q' [
  4. mtd1: 00100000 00020000 "u-boot"% j! [' c* H) Z4 H7 G' T
  5. mtd2: 00080000 00020000 "others"$ n4 d0 A- E1 f( S8 I3 q
  6. mtd3: 00100000 00020000 "parameter tags"% c- ~7 l1 K/ A: Q0 f% a6 V
  7. mtd4: 00100000 00020000 "wlan"
    7 t' X/ z- W+ f+ Y4 P0 ^' c( K: U
  8. mtd5: 00200000 00020000 "usercfg"( z6 B  q# }4 Q4 t
  9. mtd6: 00800000 00020000 "framework") j3 |8 x9 g) R8 ?1 }* q0 f) u
  10. mtd7: 00800000 00020000 "framework1"/ E; Y! a: o2 \$ |4 [, {
  11. mtd8: 00780000 00020000 "dbus"7 L( q$ V* h" c) i, P/ d
  12. mtd9: 01280000 00020000 "kernel1": D( c( R: t; l/ x
  13. mtd10: 01280000 00020000 "kernel2"9 t4 `6 c, d; P8 l% J3 O
  14. mtd11: 03e00000 00020000 "plugin_data"
    7 j8 `: g- p* ?7 j% a2 ^: J5 K  Y3 S/ J
  15. mtd12: 01240000 00020000 "rootfs"
复制代码

6 R" p) L4 E7 l* B# e& V% Z: e2 @    saf程序管理子系统,是通过系统的lxc容器实现的,在/dbus/usr/bin/目录下有lxc相关程序,但并非标准的官方版,而是定制的,lxc.lxcpath即lxc容器存放位置设定为/usr/var/lib/lxc,暂时没有发现更改的方法(也没什么必要)。
root@F650A:~ # ls -l /dbus/usr/bin
1 I8 M' _2 ^6 I; F9 @; Vtotal 377
& P6 x& A7 q) J-rwxr-xr-x    1 root     root         10143 Nov 15  2018 dbus-cleanup-sockets
5 \8 w% e( F3 a1 y0 i-rwxr-xr-x    1 root     root         18867 Nov 15  2018 dbus-launch3 K9 Y6 A. q" F: |4 q8 _  m, u( _6 T& R
-rwxr-xr-x    1 root     root         22537 Nov 15  2018 dbus-monitor
% \# p8 d6 p3 T& T; _, j( b+ v-rwxr-xr-x    1 root     root         11049 Nov 15  2018 dbus-run-session" ~* z1 S% y6 y. {: O# b4 `4 n
-rwxr-xr-x    1 root     root         23431 Nov 15  2018 dbus-send
' L! j; z! s' {- O; P1 k3 d-rwxr-xr-x    1 root     root         19495 Nov 15  2018 dbus-test-tool% E3 U  h7 {- D4 \
-rwxr-xr-x    1 root     root         12257 Nov 15  2018 dbus-update-activation-environment. L4 |) N1 E( p& _" {6 _  c+ W/ S
-rwxr-xr-x    1 root     root          8365 Nov 15  2018 dbus-uuidgen
, w' g( B: o( T3 N( |% _6 u* B-rwxr-xr-x    1 root     root         33112 Nov 15  2018 gdbus
% a1 m- Y+ g- ~# G9 H' O; e3 i4 l-rwxrwxrwx    1 root     root         12332 Nov 15  2018 lxc-attach
1 Z$ @1 p! |# X/ y5 W3 m-rwxrwxrwx    1 root     root         14241 Nov 15  2018 lxc-autostart  {# J$ @6 x1 |2 e% m& V' k+ W; t- u
-rwxrwxrwx    1 root     root          9122 Nov 15  2018 lxc-cgroup/ s: K. h1 ?, t. t7 j$ ?
-rwxrwxrwx    1 root     root          4414 Nov 15  2018 lxc-checkconfig
) c  D. T1 ^: _% S6 d; w-rwxrwxrwx    1 root     root         10175 Nov 15  2018 lxc-clone
! f7 r: @2 }( F0 b-rwxrwxrwx    1 root     root          6181 Nov 15  2018 lxc-config
' o) m8 _4 j5 D! N-rwxrwxrwx    1 root     root          8590 Nov 15  2018 lxc-console
- r) ?( D5 Z% k-rwxrwxrwx    1 root     root         14556 Nov 15  2018 lxc-create
% l4 u% }7 f9 p+ g% m3 a# m-rwxrwxrwx    1 root     root          8540 Nov 15  2018 lxc-destroy
  Z( C0 p+ W+ l8 F; [  e+ F-rwxrwxrwx    1 root     root         10027 Nov 15  2018 lxc-execute8 R* y2 R9 q% C. ?" Z( `
-rwxrwxrwx    1 root     root          8630 Nov 15  2018 lxc-freeze
  }3 e0 L: M2 q0 H) g. v-rwxrwxrwx    1 root     root         18956 Nov 15  2018 lxc-info2 e, ]1 |9 |) y' l0 Y( J+ w% M% T
-rwxrwxrwx    1 root     root          2834 Nov 15  2018 lxc-ls
5 @" V( F* c1 O) x9 m4 @, M  y* X-rwxrwxrwx    1 root     root         11122 Nov 15  2018 lxc-monitor$ Y! [8 z0 Q0 }+ F% r0 {
-rwxrwxrwx    1 root     root         12270 Nov 15  2018 lxc-snapshot( D$ p% q# e3 F; {# `0 E
-rwxrwxrwx    1 root     root         15356 Nov 15  2018 lxc-start
  ^1 G0 ~, c  r; z/ z-rwxrwxrwx    1 root     root         10055 Nov 15  2018 lxc-stop  t$ [; y1 Y/ T7 _
-rwxrwxrwx    1 root     root          8634 Nov 15  2018 lxc-unfreeze
8 y, v! |3 e0 I8 Y! k  u-rwxrwxrwx    1 root     root         12380 Nov 15  2018 lxc-unshare: L- F3 h( O! v( J, [
-rwxrwxrwx    1 root     root         13324 Nov 15  2018 lxc-usernsexec
. X( t* M- O1 ]' I! z0 |: m! w-rwxrwxrwx    1 root     root          8561 Nov 15  2018 lxc-wait
  1. root@F650A:~ # lxc-config -l9 Q" H' @- v8 D* x$ n5 d
  2. lxc.default_config
    2 U( b' X. G9 Q0 E- d7 \
  3. lxc.lxcpath  I. A# `6 n* P- B
  4. lxc.bdev.lvm.vg
    3 f9 J% G7 V; n6 [$ J
  5. lxc.bdev.lvm.thin_pool/ u, T6 j, _* y: ~8 @4 e
  6. lxc.bdev.zfs.root
    , W+ s$ s+ v3 m9 f3 O- g
复制代码
  1. root@F650A:~ # lxc-config lxc.default_config
    5 x* @, }, S9 X/ i
  2. /usr/etc/lxc/default.conf
    9 P. H2 u2 s. I. |9 H/ o# e
复制代码
  1. root@F650A:~ # lxc-config lxc.lxcpath
    " p& v" S) k$ N5 Y. z! a) `" T
  2. /usr/var/lib/lxc
复制代码
7 t4 d6 l3 ^4 M' u$ s' E
    了解系统运作机制之后,我最初打算借用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方式开启新世界,操作步骤在本文回复中细谈。$ W4 j5 L7 m, Z/ {) L
    经过几番折腾,已将系统原有的openwrt中兴定制版saf子系统完全替换为官方openwrt19.07.1(lxc方式启动),不影响光猫拨号且可在线安装及更新非kmod类app,如ariang离线下载,samba文件共享,甚至各类科学上网工具(性能及安全原因不推荐)。' e# ~: [; _& ^# y  X" B' E, Z6 g
$ p4 }6 S9 e; E. r! ^9 C8 ~
& a. m  K) V- l. N- k* b
6 l9 g8 ^! n7 R- G" t  v/ H

- Y8 N( W, B* R* _; s) F3 ^- \+ z3 C5 n+ q& f
/ n8 y# W7 Q# \% O; v
) R! K2 c" [0 e) Y- Q, k$ b- b# u4 V( r1 d

本帖子中包含更多资源

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

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

简化并更新OpenWRT22.03.0 RC1版本

本帖最后由 songee 于 2022-4-26 23:39 编辑 : z5 w! ~! @2 l/ g; n4 b

9 i5 R- c' S( l6 P因二楼原帖过程过于繁琐,近期尝试了一种较为简单的办法。% |2 z6 Y! V8 b- g' M
( s+ D0 o8 G$ q

9 n& ?/ c* ^6 V5 ~, @% \1、下载openwrt.org固件,我选的是openwrt-22.03.0-rc1-bcm53xx-generic-tenda_ac9-squashfs.trx,binwalk分析squashfs偏移量并用dd取出,unsquashfs提取rootfs,打包为rootfs2203rc1.tar.gz,传入光猫临时目录,如 /run/shm 。/ p- F+ C" k8 V: V: g
( C& ~7 T0 b/ y* e4 ?0 a4 v
2、将rootfs2203rc1.tar.gz提取至 (lxc-config lxc.lxcpath)/openwrt/rootfs 。
* a) h3 t% V1 J/ v
  1. root@F650A:/usr/var/lib/lxc/openwrt/rootfs # tar -xzvf /run/shm/rootfs2203rc1.tar.gz -C ./
复制代码
. K8 ^: A) G" V8 t) ]% d( R3 H

% ?& h2 |; `' x3、修改rootfs。openwrt的网络配置与主系统有冲突,需要清除。
/ _5 n; x9 ]5 N5 ^- S- q1 s    3.1 移除 ./etc/board.d/ 目录下 01_leds 、02_network 、99-default_network 三个文件。
* G6 {8 @2 y: l( W    3.2 移除 ./etc/rc.d/ 目录下 K21wpad 、K85odhcpd 、K90network 、S19dnsmasq 、S19firewall 、S19wpad 、S20network 、S35odhcpd 、S96led。# L' b* ?2 G) w: W
    3.3 移除 ./etc/modules.d/ 和 ./etc/modules-boot.d/ 及 ./lib/modules/5.10.111/目录下所有文件,openwrt的kernel modules与光猫内核不兼容。# U/ y  U) I% |- m1 g. g% K" H

7 Z7 ~! a( j0 c0 D6 i' n0 @$ v! H    3.4 修改opkg源 ./etc/opkg/distfeeds.conf(可选)
. h$ ~- ]: P6 A- }1 [8 [( p! @. Y  y
  1. src/gz openwrt_core https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/targets/bcm53xx/generic/packages- u2 h" P' w3 c! ^
  2. src/gz openwrt_base https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/base, Q; b! H! K* N" j) O
  3. src/gz openwrt_luci https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/luci0 m: Z0 c' g& A' G4 X
  4. src/gz openwrt_packages https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/packages8 I! K/ M& N5 K' n, `* V
  5. src/gz openwrt_routing https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/routing6 d0 d; G, F- P5 R0 Y1 K* k
  6. src/gz openwrt_telephony https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/telephony
    2 G, c) ?5 A/ x: ^& V
复制代码
  3.5 修改 ./etc/inittab 实现启动项自启(参考https://github.com/mikma/lxd-ope ... r/files/etc/inittab, P2 a. V* e! C  L" D' i0 J' A9 Y0 D
  1. ::sysinit:/etc/init.d/rcS S boot+ o" b: |9 N! _  y9 m6 \7 P' y0 {
  2. ::shutdown:/etc/init.d/rcS K shutdown3 `2 [8 m+ [/ C( M" Y2 {  D
  3. console::askfirst:/usr/libexec/login.sh
复制代码
  3.6 修改密码 ( root 密码 chinadsl
# }* g' x7 e3 Y* j
  1. root@F650A:/usr/var/lib/lxc/openwrt/rootfs # chroot ./% c; r3 r4 l) X1 F) x

  2. 7 R0 k' o8 @$ ^9 F
  3.   \8 x- n, P& i3 q. \3 L
  4. BusyBox v1.35.0 (2022-04-20 10:37:37 UTC) built-in shell (ash)+ [2 |  K$ p* r2 R  I

  5. 7 ?2 Z# W5 u  W- V/ p" R: g9 i+ j9 }
  6. root@F650A:/ # passwd
    - ~1 m+ U. {# L% j7 _- y
  7. Changing password for root9 R, ^, r  R: l) z' n2 z: t
  8. New password:! L5 c! Z+ C1 O' {0 f
  9. Bad password: too weak
    3 f3 C; z( y& _; G
  10. Retype password:9 ^$ [' x. `% [0 c
  11. passwd: password for root changed by root
复制代码
  3.7 删除 ./etc/resolv.conf 软连接并新建./etc/resolv.conf,否则openwrt无法解析域名+ x, y1 Y: k5 E. i" p# q- G% K; k4 z
  1. nameserver 223.5.5.5; j  |% ?3 T3 n3 Q
  2. nameserver 2001:da8::666
    9 v4 l" e5 R; Z, r0 B
复制代码
1 B  S9 r2 p1 z0 g
+ w: Y% l- }" g2 C2 k7 P; ]0 V7 ^
4、修改lxc配置文件 /usr/var/lib/lxc/openwrt/config ,根据各自光猫环境修改测试,这个配置我的F650A可正常使用。* c9 z6 p7 Z6 G
  1. lxc.arch = arm
    + ]- ^9 p/ W& q: c$ o/ Q% Q
  2. lxc.utsname = openwrt
    ! a; X6 v# D: p7 X' \4 l0 p# P0 ^3 J
  3. #lxc.rootfs.mount = /usr/var/lib/lxc/openwrt/rootfs
    7 H" ]# M1 a1 M. |1 {$ S
  4. #lxc.rootfs.path = overlayfs:/opt/upt/framework1/rootfs:/opt/upt/apps/openwrt-rootfs
    ' r# H$ x7 I& G8 ]) N& F
  5. lxc.rootfs = /usr/var/lib/lxc/openwrt/rootfs
    ( e7 D+ f2 o% m/ u( b% s
  6. lxc.haltsignal = SIGUSR1
    8 l' s: S: d: a, y* g4 c& g. P
  7. lxc.tty = 1( K' l: }6 x% _  k4 h
  8. lxc.pts = 1: Y, c& y7 z2 b. w6 c
  9. #lxc.hook.pre-start = /usr/var/lib/lxc/openwrt/pre-start.sh1 j5 s; \& `; w4 J7 I0 s
  10. lxc.aa_profile = lxc-container-default-with-nesting$ C  c! K& @! R& ]8 R7 ^5 s
  11. lxc.network.type = none( f3 K3 S- E  R8 ^, W8 p' j! i
  12. lxc.mount.auto = cgroup-full:rw3 O+ \/ Y5 u$ @, e1 B  j
  13. #lxc.mount.auto = proc sys cgroup
    . m# Y$ k& W" A6 ^; O
  14. lxc.mount.entry = sysfs sys sysfs defaults 0 02 J. O) i/ I' B' ~
  15. lxc.mount.entry = proc proc proc defaults 0 0
复制代码
% v' J/ k) [# g0 T# N
' Z6 c# M& ]4 A
5、启动,根据提示按enter进入控制台。. e8 ?, U$ f3 H" t  @; z
  1. root@F650A:~ # lxc-start -n openwrt
    - ]: M/ t4 k4 T4 u* r
  2. <6>init: Console is alive7 ?# T: v1 {! P( r+ T& G
  3. <3>init: Failed to redirect stdin to /dev/null: No such file or directory( s( m& f8 J7 h9 q9 ^% z
  4. <3>init: Failed to redirect stdout to /dev/null: No such file or directory& I9 m% `4 B. t! P* W
  5. <3>init: Failed to redirect stderr to /dev/null: No such file or directory  z; F2 ~8 r+ n" F9 ?/ @6 T. d
  6. <6>kmodloader: loading kernel modules from /etc/modules-boot.d/*
    / b% |  b& a/ K9 J2 ^  R
  7. <6>kmodloader: done loading kernel modules from /etc/modules-boot.d/*( d$ S6 t4 u+ R9 Z# E
  8. <6>init: - preinit -; q! d2 H( z8 p  P$ q8 [) c
  9. ls: /etc/board.d/*: No such file or directory
    7 V$ g$ f% g! I! ?( k2 F
  10. Press the [f] key and hit [enter] to enter failsafe mode2 ^0 h* }  F! w2 V! l; `% u4 O
  11. Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level5 m" j% j: o0 h" q- p# {# m
  12. <3>mount_root: Could not open mtd device: /dev/mtd12
    6 X9 e& ~3 N* E  [- c* Q
  13. <3>mount_root: reading rootfs failed# P2 G- [3 B; [: Y0 ~8 \
  14. <5>mount_root: mounting /dev/root, V- D, v& f3 ^* ?7 e8 ]. `
  15. urandom-seed: Something is wrong with /dev/urandom' N( l' _# t0 n5 \+ O& b; G
  16. <6>procd: - early -7 H  A6 t" E& i' K) t9 f7 d
  17. <6>procd: - ubus -
    . g/ Q6 D# M/ G
  18. <6>procd: - init -' p- I' a/ f8 W' g: e+ k6 \6 G
  19. Please press Enter to activate this console.% s* r2 y# j0 T4 f7 ^8 S
  20. <6>kmodloader: loading kernel modules from /etc/modules.d/*
    4 b9 f) R+ K& I, F9 f/ J' ^, q
  21. <6>kmodloader: done loading kernel modules from /etc/modules.d/*8 s; L0 p9 }1 {2 Z* y  ~( i& Y- R
  22. <6>urngd: v1.0.2 started.% P7 @+ t# s4 p
  23. % j! k% ^8 m: d% _

  24. 8 B9 v( x1 F8 m" V& {% |7 e9 Z1 C* A9 h

  25. 0 N& R9 A' j; M  n
  26. BusyBox v1.35.0 (2022-04-20 10:37:37 UTC) built-in shell (ash)
    ; R: m5 h" ?9 ]: ]9 K5 p8 z9 R- L

  27. ( q7 F, ~% _& q& i  \$ `! J+ d
  28.   _______                     ________        __& S& R6 X8 T7 Z6 _0 j
  29. |       |.-----.-----.-----.|  |  |  |.----.|  |_# ~+ S( m7 [  n0 B( ^1 w0 w
  30. |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|7 o7 H# K  Q  t* ]+ o  t) w* d
  31. |_______||   __|_____|__|__||________||__|  |____|
    , c3 F  o  a" P, _8 ^
  32.           |__| W I R E L E S S   F R E E D O M3 Y" v$ L) U; c% `4 Y$ d
  33. -----------------------------------------------------
    6 S0 y' [! v) W3 P. K  R# K7 }
  34. OpenWrt 22.03.0-rc1, r19302-df622768da! s; v- j9 n' _8 B1 O9 Q, U
  35. -----------------------------------------------------: `: c9 K+ v( |& d
  36. root@openwrt:/#
复制代码
8 T( w( E" n( w; d3 E( ~
# H: n+ ]+ V, g  |
  1. root@openwrt:/# ps$ e7 m0 c% O: K. G; Y* J9 l
  2.   PID USER       VSZ STAT COMMAND& O9 K0 t. ?0 |' B2 m8 Y6 D3 `2 J
  3.     1 root      1452 S    /sbin/procd! d& ^+ l% T& H. k$ X
  4.    58 ubus      1112 S    /sbin/ubusd: @7 V* h% c- `% H- \3 o6 ?. S
  5.    59 root      1196 S    /bin/ash --login% b3 ~( l" g2 y1 j2 R' Z  y0 V
  6.    93 root       908 S    /sbin/urngd
    8 P  ^2 I; o; |: }  M6 F! T
  7.   204 root      3736 S    /usr/sbin/uhttpd -f -h /www -r OpenWrt -x /cgi-bin -u /ubus -t 60 -T 30. {/ h2 l( b) m  J
  8.   487 root      1952 S    /sbin/rpcd -s /var/run/ubus/ubus.sock -t 30! J6 N6 G2 U+ B/ K, ^/ T' ]
  9.   556 root       956 S    /usr/sbin/dropbear -F -P /var/run/dropbear.1.pid -p 22 -K 300 -T 3, @4 r1 O3 I9 S# O: S
  10. 1065 root      1200 R    ps
    ( i" G1 U! V8 P( ^% o
  11. root@openwrt:/#
复制代码
2 K, c/ d+ X; ]2 M7 X
/ ]$ ~2 W; ~9 f( A/ P8 A8 T: k
  1. root@openwrt:/# opkg update
    ; {' r9 n) @1 X8 v
  2. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/targets/bcm53xx/generic/packages/Packages.gz3 C( D( G. }, ]# i# O
  3. Updated list of available packages in /var/opkg-lists/openwrt_core
    9 @3 P5 E! t$ B- u5 ?& J# b
  4. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/targets/bcm53xx/generic/packages/Packages.sig
    ( {4 |2 A/ m6 ]: V$ @
  5. Signature check passed." D1 G! ~- m4 @( @
  6. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/base/Packages.gz
    / K0 y$ k; o+ ^# k  u" Z$ b
  7. Updated list of available packages in /var/opkg-lists/openwrt_base! s5 s5 u4 z& Z: t+ n+ x1 S
  8. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/base/Packages.sig0 J: @6 _+ _! t% L/ P/ V( m' b* ?
  9. Signature check passed.
    $ h# X* m: L1 J4 h8 t2 J
  10. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/luci/Packages.gz" v* d! E5 L# }" `3 y; o
  11. Updated list of available packages in /var/opkg-lists/openwrt_luci( v5 N6 J  s7 E
  12. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/luci/Packages.sig8 f; ?% o$ ~9 m# B6 d. j3 y+ g
  13. Signature check passed.* p. F7 @# M2 F: o1 N2 q3 P
  14. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/packages/Packages.gz
    . `8 q$ o% T3 K7 p
  15. Updated list of available packages in /var/opkg-lists/openwrt_packages. `7 k" ^" A, H8 b0 X, ?
  16. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/packages/Packages.sig: f) a7 o+ M, w: x% m3 v
  17. Signature check passed.
    1 N% o; v. w+ J. I& F. }
  18. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/routing/Packages.gz- W. l- w; D8 L/ P; i% i' d# i/ w0 ?* b
  19. Updated list of available packages in /var/opkg-lists/openwrt_routing" K3 v: N4 k5 K+ T6 S
  20. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/routing/Packages.sig, |5 T) e/ ?: _1 w: I" {
  21. Signature check passed.2 b% o2 e: j5 k$ k4 n  P; z
  22. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/telephony/Packages.gz
    9 k8 e- z( j1 R; T+ F4 C5 j0 B
  23. Updated list of available packages in /var/opkg-lists/openwrt_telephony- e6 D2 z8 Z( }: ~
  24. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/telephony/Packages.sig7 b9 T& l, R5 \
  25. Signature check passed.
    8 @- I- O. @8 {
  26. root@openwrt:/#
复制代码

* {4 P; r  J0 \  z& V2 X# F
1 k* G6 X- Q2 U此时临时的openwrt系统已建好,运行的服务有两个:http占用主系统的80和443端口,ssh占用22端口。0 A+ d# l# T3 R; \, a% t& ]
6 k" Y" k- c- N4 S7 l$ c0 S
如果光猫有公网IP,请务必关闭ssh密码登录并使用密钥。
- S* A' x- n- `, D+ B0 m5 Y2 n/ P/ L  h# K% K
后期使用建议使用 lxc-start -dn openwrt 后台启动,使用 lxc-stop -kn openwrt 命令关闭。openwrt管理使用ssh密钥登录。
& L$ c4 A) z( F- H5 a需要固化openwrt到固件的,可以打包rootfs和config(需修改配置),mksquashfs制作成squashfs,用mtd写入saf分区,就不用担心恢复出厂设置了。
, _5 @2 Z/ W8 ]! i4 q, v1 C5 {' N# v! H随光猫启动可以参考二楼。
* ]/ q  ^+ G. Y* O5 B4 S" N6 C+ N. Z8 ^- ~4 F$ ?5 ?

本帖子中包含更多资源

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

×
 楼主| 发表于 2022-4-27 23:10:13 | 显示全部楼层
因光猫原系统的busybox功能不完整,也没有nano和dropbear,调试lxc可能会不方便,现分享出来。
& m' g: D( z8 i* G% [7 C+ N, ~3 g" e7 W
  1. root@F650A:~ # /usr/bin/busybox
    3 ^2 C0 {# u' q) f& I; N& o
  2. BusyBox v1.23.2 (2020-06-16 16:53:26 CST) multi-call binary.
    6 y( p. y3 F- B9 |1 J
  3. BusyBox is copyrighted by many authors between 1998-2012.  E& U* g/ m- H; W% Y& U: O7 Q) T
  4. Licensed under GPLv2. See source distribution for detailed
    * z7 w4 W" ?5 ~
  5. copyright notices.7 v  b! J( Z- y
  6. ) b8 y. _+ Y* W" v* c; F; U
  7. Usage: busybox [function [arguments]...]- H& y- [3 ]) x8 Q) Z
  8.    or: busybox --list[-full]
    3 R  ?" G' n& o6 J# g% T
  9.    or: busybox --install [-s] [DIR]
    ' f( b& G2 y0 |* N
  10.    or: function [arguments]...
    * f" E/ w6 @. d8 U

  11. 4 F* M0 {, m" I* v2 c2 p" Z
  12.         BusyBox is a multi-call binary that combines many common Unix+ G$ L/ K1 w( c1 m* D# M
  13.         utilities into a single executable.  Most people will create a
    9 w. a6 j. t: |
  14.         link to busybox for each function they wish to use and BusyBox. d3 K3 a4 S! ~/ ~
  15.         will act like whatever it was invoked as.# [4 z# _; ~( L$ V7 `& k, _
  16. / q- M; h5 Z+ H7 I0 O' s% x
  17. Currently defined functions:; q; q  k2 m' E' a8 c* P
  18.         [, [[, addgroup, adduser, ar, arp, arping, ash, awk, basename, blkid, brctl, bunzip2,+ W, ]8 i- D+ k& s, [
  19.         bzcat, cat, catv, chattr, chgrp, chmod, chown, chroot, chrt, chvt, cksum, clear, cmp, cp,
      r2 t& [' P2 k
  20.         cpio, crond, crontab, cut, date, dc, dd, deallocvt, delgroup, deluser, depmod, devmem, df,
    6 n  U9 w; m, `2 J2 t6 x; w
  21.         diff, dirname, dmesg, dnsd, dnsdomainname, dos2unix, du, dumpkmap, echo, egrep, eject, env,
    9 g) s3 v7 m$ X7 h8 b  ^
  22.         ether-wake, expr, false, fbset, fdflush, fdformat, fdisk, fgrep, find, flock, fold, free,
    , b3 `, Z4 R7 O* u& @
  23.         freeramdisk, fsck, fstrim, fuser, getopt, getty, grep, gunzip, gzip, halt, hdparm, head,
    8 ]& H; U1 v3 \# I( `1 G
  24.         hexdump, hostid, hostname, hwclock, id, ifconfig, ifdown, ifup, inetd, init, insmod,
      X9 W7 J. a9 c$ g, l# W
  25.         install, ip, ipaddr, ipcrm, ipcs, iplink, iproute, iprule, iptunnel, kill, killall,
    & ^, J  Q( X& k! B' V
  26.         killall5, klogd, last, less, linux32, linux64, linuxrc, ln, loadfont, loadkmap, logger,5 h, j% t0 |) Y4 s; Q
  27.         login, logname, losetup, ls, lsattr, lsmod, lsof, lspci, lsusb, lzcat, lzma, makedevs,9 d+ d4 `/ [' {+ P+ ]' h
  28.         md5sum, mdev, mesg, microcom, mkdir, mke2fs, mkfifo, mkfs.ext2, mknod, mkswap, mktemp,0 I* H4 F7 b2 ]' ~' U& u! M  {! K6 y
  29.         modinfo, modprobe, more, mount, mountpoint, mt, mv, nameif, nanddump, nandwrite, netstat,: _# U7 W1 @) A2 P
  30.         nice, nohup, nslookup, od, openvt, passwd, patch, pidof, ping, pipe_progress, pivot_root,4 ?3 r$ a& c$ Y9 v$ i
  31.         poweroff, printenv, printf, ps, pwd, rdate, readlink, readprofile, realpath, reboot,
      S  t* h" n7 `! h& D+ Q
  32.         renice, reset, resize, rm, rmdir, rmmod, route, run-parts, runlevel, sed, seq, setarch,8 E3 c0 I: S! k
  33.         setconsole, setkeycodes, setlogcons, setserial, setsid, sh, sha1sum, sha256sum, sha3sum,
      p( G& d7 y+ r  E
  34.         sha512sum, sleep, sort, start-stop-daemon, strings, stty, su, sulogin, swapoff, swapon,* j# w# L  V% t' V  w
  35.         switch_root, sync, sysctl, syslogd, tail, tar, tee, telnet, telnetd, test, tftp, time, top,& |" j( x: S' x
  36.         touch, tr, traceroute, traceroute6, true, tty, ubiattach, ubidetach, ubimkvol, ubirmvol,
    # j; }/ ]/ {  q( F- N+ @* I. z
  37.         ubirsvol, ubiupdatevol, udhcpc, umount, uname, uniq, unix2dos, unlink, unlzma, unxz, unzip,
    * ^2 L7 R, F9 x( K- V% C0 [
  38.         uptime, usleep, uudecode, uuencode, vconfig, vi, vlock, watch, watchdog, wc, wget, which,
    6 d& c+ Z# {  P% i5 N2 |
  39.         who, whoami, xargs, xz, xzcat, yes, zcat
    + H, [; L. |6 }; A# F/ v; [1 B5 c! U

  40. ' C. a0 K/ {+ M' R
复制代码
  1. root@F650A:~ # nano -h) l! j( ~: M7 S
  2. Usage: nano [OPTIONS] [[+LINE,COLUMN] FILE]...5 w/ I6 g# b% x2 C- o. g4 b2 f
  3. 8 M* q% g# V: c& z9 w
  4. Option          GNU long option         Meaning+ J3 f' _0 f  h0 \0 S# x/ h
  5. +LINE,COLUMN                           Start at line LINE, column COLUMN6 v: L/ }2 O* I5 s+ T6 Q' u# k
  6. -D             --boldtext              Use bold instead of reverse video text
    ; ~6 A' A) W5 O! q
  7. -K             --rebindkeypad          Fix numeric keypad key confusion problem* u4 Q- K6 c" f" ~" m3 |" q' Y# I
  8. -L             --nonewlines            Don't add newlines to the ends of files8 P0 o. J% P% Z7 x- E
  9. -O             --morespace             Use one more line for editing; m2 ]) V7 i% z5 X
  10. -R             --restricted            Restricted mode
    - q2 \0 P/ r; X/ F5 e) H
  11. -T <#cols>     --tabsize=<#cols>       Set width of a tab to #cols columns1 @/ G) d2 f" `0 ~
  12. -V             --version               Print version information and exit
    . E0 D% ^4 l& g+ H+ a& F
  13. -c             --const                 Constantly show cursor position+ m; q3 ^& \! f$ J3 Y+ L2 O5 \
  14. -d             --rebinddelete          Fix Backspace/Delete confusion problem
      x3 t( ^* }7 h5 D+ Y4 L
  15. -h             --help                  Show this help text7 G, ?& c4 F, N. r
  16. -l             --nofollow              Don't follow symbolic links, overwrite  P; \/ X1 z5 @& V" T/ O
  17. -n             --noread                Do not read the file (only write it)
    " }# c# I% j# z  q/ p8 c
  18. -p             --preserve              Preserve XON (^Q) and XOFF (^S) keys0 ^) Q9 f, }, s: A
  19. -t             --tempfile              Auto save on exit, don't prompt
    4 f! X& r1 i+ B! V$ A" W
  20. -v             --view                  View mode (read-only)
    8 E+ ^/ _  v$ x5 U
  21. -x             --nohelp                Don't show the two help lines
    " H9 G8 o! G2 q
  22. -z             --suspend               Enable suspension5 g; [; t+ N3 h, @/ F
  23. root@F650A:~ # nano -V! v# x) `: \& O  S5 d, m
  24. GNU nano, version 2.4.2; ?8 c0 N/ b3 z/ ~$ `: k: A; _
  25. (C) 1999..2015 Free Software Foundation, Inc.
    $ [6 y/ _4 u( @) H% G6 V1 o+ s
  26. Email: nano@nano-editor.org    Web: http://www.nano-editor.org/
    $ E5 @$ F8 h1 M: @" C) m
  27. Compiled options: --enable-tiny --disable-utf8
    1 u! [! L( b5 U) Y
复制代码
  1. root@F650A:~ # dropbear -h
    6 T6 z$ u" [+ o0 r: w0 ?
  2. Dropbear server v2015.67 https://matt.ucc.asn.au/dropbear/dropbear.html
    2 A! S% c) u- o
  3. Usage: dropbear [options]; P" \+ I  M2 y2 T
  4. -b bannerfile   Display the contents of bannerfile before user login* H3 H" W, c& @# l" t4 b3 `
  5.                 (default: none)' @( g( I3 s+ ~" U0 N
  6. -r keyfile  Specify hostkeys (repeatable)
    3 m/ c0 f& @4 F5 l! u, F: p
  7.                 defaults:8 @+ j; c' V+ u' C# ~9 Q  w& k
  8.                 dss /etc/dropbear/dropbear_dss_host_key
    6 S0 q; t$ @5 }" p
  9.                 rsa /etc/dropbear/dropbear_rsa_host_key6 P' z( ]$ Z# x$ h1 u9 P5 s. L: w
  10.                 ecdsa /etc/dropbear/dropbear_ecdsa_host_key
    0 C9 W( l: x# w" w
  11. -R              Create hostkeys as required
    2 ]5 K! w# _( F8 @8 [, y. q- k, w
  12. -F              Don't fork into background
    5 x" [6 S5 l, P* j' |& K3 ]
  13. -E              Log to stderr rather than syslog
    7 ~; @* H8 K0 L$ c) I; W8 B9 A
  14. -m              Don't display the motd on login) x; t) f, l6 w7 R
  15. -w              Disallow root logins5 O6 T* g9 J" p2 N$ x4 d
  16. -s              Disable password logins
    - d: Y  n. c4 G0 E5 E
  17. -g              Disable password logins for root
    % y+ b$ R! ?3 g$ t% g: b8 a& _+ a
  18. -B              Allow blank password logins& l5 I3 \2 k: V5 `9 d
  19. -j              Disable local port forwarding: S( V8 l# U$ L0 r- C$ r
  20. -k              Disable remote port forwarding+ w8 ^& U) z% u. h1 D- T
  21. -a              Allow connections to forwarded ports from any host; w2 l+ W/ a  ]9 G% V
  22. -p [address:]port
    . w! D! h4 Z, q9 w. ?
  23.                 Listen on specified tcp port (and optionally address),
    ( W# V4 G* I' i7 s8 F  ^. Y
  24.                 up to 10 can be specified0 [% v4 u2 r8 v5 y% t
  25.                 (default port is 22 if none specified)
    . E8 t1 Z& i! h. x2 k! X, N
  26. -P PidFile      Create pid file PidFile
    / {; v$ i! S( o1 A
  27.                 (default /var/run/dropbear.pid)- @! J0 \5 }# k6 j5 s
  28. -i              Start for inetd9 g$ ]* n$ V5 n9 p/ J. f) b
  29. -W <receive_window_buffer> (default 24576, larger may be faster, max 1MB)8 _: Y) {5 S, F+ h2 [) J4 n( w
  30. -K <keepalive>  (0 is never, default 0, in seconds)7 A' c5 H+ ~5 t+ [- G: G- L
  31. -I <idle_timeout>  (0 is never, default 0, in seconds)
    1 }( A  d$ j$ j! s4 {8 D+ k2 {! ~+ k
  32. -V    Version
    3 c, e3 |0 R2 q2 q& z, y
复制代码
  W- r/ ]4 h6 f  b

* I. R0 n( R/ F* S# J

本帖子中包含更多资源

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

×
发表于 2021-11-27 21:38:54 | 显示全部楼层
本帖最后由 btworm 于 2021-11-27 21:41 编辑 3 _2 c7 }4 K9 b1 V% g
songee 发表于 2021-11-27 04:15
  l5 e% S6 E2 i; z5 n1.只要lxc相关命令可以正常运行,写好配置文件,选择符合CPU架构的rootfs,就可以把容器跑起来。
7 m  K' ^; a$ p* T7 o  y, ]2.我的 ...
: I$ ?# ?7 G, S2 T
感谢指点!+ o5 b- p0 y% y$ v$ R7 h' n
9 L4 R8 ?/ x* x/ e- m) Y7 S
关于第2点
4 V* r5 f/ l! Q. c华为光猫 / 只读,/etc,/usr,/lib这些目录也都依附于/, 所以都不可写, /opt目录不存在,当然也无法创建。) @3 n$ u0 z, _" w1 G! o0 |" B
' E# E: p; U$ e6 I# O
之前担心/dev/pts, /proc, /sys只读,是因为以前玩路由器时,有个chroot脚本使用过这些目录,刚又看了遍那个脚本,使用的是 "-o bind"参数,所以主机目录是否可写就无所谓了。在华为猫上跑lxc应该没问题了
. V! l( x/ B$ z) p  ^. f) D# d, K1 t0 g6 I8 c+ |
另外想问问,光猫容器内的应用对端口的监听是:" a1 ~  h1 N. w* C$ t1 v# N
1.直接监听光猫的端口?
- g7 l" R& Y! \9 ~+ H7 m& C2.还是只能监听容器内的端口,并需要光猫iptables做端口转发给容器?
 楼主| 发表于 2020-2-22 18:37:10 | 显示全部楼层
anysoft 发表于 2020-2-22 17:50
  n5 P- [1 w" F% g4 MHS8145V HS8145V5  F650A 都是512MB+256MB 2.4G+5G方案/ ?+ g4 s' w: ?
价格都还好,特别F650A 因为会玩的人少价格特别便 ...

& E. m( H0 n7 A  p1 o' J! r6 Z4 uhs8145v技术成熟,更适合玩,而且其实f650a是512/128,nand flash少了一半,CPU一个尿性,价格差别不大的话,能hs8145v还是别选650。
2 u0 K- a& M' l2 i还有个大胆想法,lxc可以通过配置文件config修改子系统网络,从eth0桥接是不是就能在子系统多拨了,子系统专门离线和网络存储,不影响猫后面接的手机电脑上网,还是蛮有趣的, R# a% q0 q# N- }# G
; Z1 s! ~. k2 y9 ~4 T) R3 l4 i

9 ]6 Z& Z) A2 \9 r/ v. A1 q& ~8 [7 y. G1 i8 L1 |5 g" A
 楼主| 发表于 2020-2-17 02:19:26 | 显示全部楼层

二楼原帖,仅保留做参考

本帖最后由 songee 于 2022-4-27 21:17 编辑 & \3 C, \) [. o* Z

, y* B) y4 V" R0 U4 k9 S. k1 x# Q( H/ X/ P! H9 D# T, Q; I
(2020年原帖初步摸索,过程过于繁杂,不建议再按这部分思路操作)! `2 |4 p. W6 k* e. |  q
中兴、华为等带有saf模块的光猫,以官方版openwrt替换厂商定制版的思路总结一下,供大家参考。5 @( w. P/ [& ]# t# a; }
1、准备工具
: w. V2 h9 ?% `" w* G$ a  ]0 }0 m# }    F650A主系统没有 mtd 、 dd 和 vi 等工具,而自带的saf子系统正好都有,子系统位于framework分区即mtd6,挂载于/opt/upt/framework,cp过来可以直接使用。
root@F650A:~ # cp /opt/upt/framework/saf/rootfs/sbin/mtd /usr/bin/
$ v8 T& I! Q8 droot@F650A:~ # cp /opt/upt/framework/saf/rootfs/lib/libubox.so /lib/( m' J+ W1 N# p" ^3 a2 _6 m
root@F650A:~ # cp /opt/upt/framework/saf/rootfs/bin/busybox /usr/bin// d" P( C# {$ T+ o% n) ~
root@F650A:~ # cd /usr/bin/
6 k' n+ v1 a" h/ c" s7 |7 T' {: Wroot@F650A:/usr/bin # ln -s busybox dd
6 m# j  c% \7 v2 Droot@F650A:/usr/bin # ln -s busybox vi
( R' q8 w- A$ r+ U( r1 r6 h6 {
2、改进lxd-openwrt生成代码。0 K4 h! Q/ k! F' X6 s
    本节参考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如下
' k6 n/ \8 y* U. t7 }; ~  J- U
*** build.sh                2020-02-19 01:50:10.972675562 -0100
) }6 U! }5 A. ^+ R) t--- build.sh.origin        2020-02-14 19:10:45.000000000 -01007 B' C& B( [1 }5 x
***************2 j$ o- ]8 H- Z
*** 72,81 ****
5 _1 W, n7 P/ V7 r8 P; V                  subarch=64& Q1 m  q3 X7 `, z5 J1 s2 `
                  arch_ipk=x86_641 N0 h( r  @  g6 V  k" \3 b
                  ;;; o- J" H& h# Q/ u
!         arm)
0 P* Q" [+ S) F4 b5 m1 X& w!                 arch=bcm53xx0 x) O% J7 |/ L9 V/ h
!                 subarch=generic
- U5 e7 v9 Q+ Z* j!                 arch_ipk=arm_cortex-a9
2 B5 v( ~& j/ `8 T3 [0 c5 M8 x                  ;;1 [/ o; ~1 v  x% R' o
          *)6 C6 E. @. e0 M+ u- O
                  usage
6 F  q1 e, [+ e% D  Z--- 72,81 ----
8 P1 y4 Q; Q  [# o                  subarch=640 d( k% V* \4 ?, U
                  arch_ipk=x86_64
/ w' e! t2 t9 [) T  f3 x7 \                  ;;5 _3 q; [3 l4 n1 {/ n$ }- ~
!         aarch64), o+ `5 d# \% T2 P0 k$ q/ h
!                 arch=armvirt
! K$ w& a' w$ J!                 subarch=64
) l0 G7 f3 W7 @/ D# V5 {: _* u1 P1 `!                 arch_ipk=aarch64_generic
$ Y; t& \' L6 I" x' ~2 c* A- F0 Z                  ;;
# j5 g7 {" x+ D- \          *)) f0 b. R! u" b6 F5 a) n0 H
                  usage
1 ?. M) t" k# p! S0 W% g***************
4 h1 O# P. j8 z+ d5 t. R8 v3 g6 w*** 87,97 ****2 G. Y2 R% w0 m7 a
  if test $ver = snapshot; then+ l+ u0 @  h( Y: T9 e
          openwrt_branch=snapshot
% o8 x9 _4 A: y1 |* B          procd_url=https://github.com/openwrt/openwrt/trunk/package/system/procd
: B! w8 R- I4 M% s; o: P!         openwrt_url=https://mirrors.cloud.tencent.com/lede/snapshots/targets/${arch}/${subarch}
. G+ Z6 m  j: e& W5 D; |3 A/ n  else% [; X& f0 {6 t& _* V. F
          openwrt_branch=${dist}-${branch_ver}
; n  s" X" S0 z' _/ {          procd_url=https://github.com/openwrt/openwrt/branches/${openwrt_branch}/package/system/procd
+ @4 ?( w. l& }1 k!         openwrt_url=https://mirrors.cloud.tencent.com/lede/releases/${ver}/targets/${arch}/${subarch}
- D9 ^" {; ?5 M* ^6 d  fi
+ A, O+ A7 H+ U& Q1 j+ H  
( }6 e) h5 a7 O1 b  procd_extra_ver=lxd-3  Y  O" K# e" T) {* ^
--- 87,97 ----$ k* k6 s: q  t9 T
  if test $ver = snapshot; then
! Z! a5 o# b' |) Z' Z          openwrt_branch=snapshot% z( a7 i" ~) d4 s6 |
          procd_url=https://github.com/openwrt/openwrt/trunk/package/system/procd
+ Y5 o% Z, H! A5 q( C- {!         openwrt_url=https://downloads.openwrt.org/snapshots/targets/${arch}/${subarch}
" K+ r! [0 D% h$ ~4 ?- G  else5 a" P* C6 T8 D( I  T. q
          openwrt_branch=${dist}-${branch_ver}2 o2 H+ S/ ~5 _8 ?
          procd_url=https://github.com/openwrt/openwrt/branches/${openwrt_branch}/package/system/procd
  L! D/ F( b1 G) [( D!         openwrt_url=https://downloads.openwrt.org/releases/${ver}/targets/${arch}/${subarch}8 Y  S2 r: h' k) f' F
  fi
1 M" p6 V: H. n  X- @  
8 D8 E% O. U( t) A  procd_extra_ver=lxd-3
, f8 {* b/ p; j9 |* Q5 T- d5 q***************- s, D: V0 z1 ?2 |! @) r
*** 112,125 ****
) x/ ~% E2 _0 z/ f% x8 [% O  }
$ n# t  x8 A4 c% e, w  5 T3 F" p) i  J- d
  download_rootfs() {5 J  @  r) j- h7 w9 a
! #        detect_url "rootfs\.tar"
' |4 A3 X( D7 M! #        local rootfs_url=$openwrt_url/$return
7 k. u. K* m  o* F5 ^  
; q  ]' ^, |7 S% `; R! P& H          # global $rootfs
( }* G) c: ~! q6 m!         rootfs=dl/openwrt-19.07.1-bcm53xx-generic-rootfs.tar.gz
1 O. Q4 X% x$ i8 |7 [  . r2 ?/ M9 O1 @. ~
! #        download $rootfs_url $rootfs $rootfs1 Y* g: [) {( T: I
! #        check $rootfs $rootfs_url
; |2 L! ?, f  z) r  }# C3 ]8 O! A  x4 j/ I; S6 s
  
3 ~- Z; D3 u! T8 N  j( l  download_sdk() {
& N5 ]) H  M& G, Y; l--- 112,125 ----
+ P( @; n) g3 O6 h3 O# `6 {) r  }
: @' k' s) Z( ?: r: [  5 B& a# K; G8 @. |$ U: J" @
  download_rootfs() {
2 v# B2 Y  i4 g+ n, t7 ?6 \1 E( O!         detect_url "rootfs\.tar"2 s+ x* ]) Q; |7 c$ I
!         local rootfs_url=$openwrt_url/$return* t; U& x! m2 e; e( w
  9 h5 m5 J, q8 `$ e) @
          # global $rootfs
+ m5 [$ m" P1 W, {' T!         rootfs=dl/$(basename $rootfs_url)
2 M. `* s( D" }5 s8 h  % v$ p5 H- y. C% F/ D
!         download $rootfs_url $rootfs
7 v5 H, ~8 Z$ P: e7 I. \!         check $rootfs $rootfs_url
# z, ^8 S2 R, Z  }2 i( `! m* I! U3 i
  & I/ d4 n) q0 R7 `( S, ^& Q
  download_sdk() {
0 o2 v" I- P7 x5 \
3、从腾讯镜像下载openwrt-19.07.1-bcm53xx-tplink-archer-c9-v1-squashfs.bin,从固件中提取rootfs并预处理。
% k) `. @  d- L- Q
  1. x@x-Surface-Pro-3:~/下载$ binwalk openwrt-19.07.1-bcm53xx-tplink-archer-c9-v1-squashfs.bin
    ) }8 O; m' r! y* h
  2. ; G9 B" q" b' c- I" N/ O
  3. DECIMAL       HEXADECIMAL     DESCRIPTION
    ' H# y, n  N" y, N4 E
  4. --------------------------------------------------------------------------------
    / f& ^2 h6 n; n6 w2 q$ c/ @
  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: 0x07 k' N1 s* {! D' o6 I
  6. 8345          0x2099          LZMA compressed data, properties: 0x5D, dictionary size: 65536 bytes, uncompressed size: 1801662 bytes1 R! F8 E3 O* c! U2 o  A
  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
    6 ]9 {( r+ E  ^; L9 Q0 |

  8. $ e0 f. Y0 P7 t  H3 o
  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
    ! z' ?, {% l. ^, a3 {3 \: H6 g# u
  10. 记录了1900548+0 的读入- ]+ E) f- _/ U  w( o9 T$ i
  11. 记录了1900548+0 的写出
    , s8 Q3 n# @' ^" W( ^$ B4 |6 p
  12. 1900548 bytes (1.9 MB, 1.8 MiB) copied, 5.16823 s, 368 kB/s
    9 J( m/ _1 h' O; v- k& k( f
  13. x@x-Surface-Pro-3:~/下载$ binwalk rootfs-squashfs.bin
    ) }# w" z9 M1 p- w$ }

  14. ' c+ H% }2 A: ~- c) p3 v! z3 s
  15. DECIMAL       HEXADECIMAL     DESCRIPTION4 n8 R$ K: {5 J3 V" y* R
  16. --------------------------------------------------------------------------------
    " h* N! e" e7 J
  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
    - |# w8 y! R2 }1 R5 X' ]8 ?) d

  18. 4 V2 T0 Y5 l. v/ q3 z- K
  19. x@x-Surface-Pro-3:~/下载$ unsquashfs rootfs-squashfs.bin 8 m, s* p- S/ g) s6 t4 H) _( [0 f
  20. Parallel unsquashfs: Using 4 processors
    . |! }6 _% i& t. M& f0 [
  21. 1071 inodes (1066 blocks) to write
    " w$ Q. X# F# v. D# r8 r
  22. ( U4 ^! `- F0 o: S' M
  23. 9 I1 k3 [) |7 @9 e0 R
  24. create_inode: could not create character device squashfs-root/dev/console, because you're not superuser!* T/ i  ?, B: Y9 n) y0 Y& i# y
  25. [====================================================================================================| ] 1065/1066  99%
    7 o# e  w$ k$ O% ~( u

  26. + E8 }) X  f$ N
  27. created 875 files
    ' b9 D% V: u5 f9 f8 J7 @6 J- e
  28. created 103 directories  H* v$ \0 J3 ]$ W9 Z5 ?
  29. created 195 symlinks3 P6 h( O1 r" G$ l9 Z3 |6 k
  30. created 0 devices
    ; t' m7 L( O/ W! Q0 b
  31. created 0 fifos' g6 a$ e* f% j% z* S$ O& M; O
  32. x@x-Surface-Pro-3:~/下载$ cd ./squashfs-root/
    4 Y2 A; e9 F) m8 v/ ~5 Z
  33. x@x-Surface-Pro-3:~/下载/squashfs-root$ gedit etc/opkg/distfeeds.conf
复制代码
将opkg软件源改为腾讯镜像
+ r& j. a8 N1 Y) Y$ G$ n
src/gz openwrt_core https://mirrors.cloud.tencent.co ... xx/generic/packages
0 y+ K# L, _/ [; C' Psrc/gz openwrt_kmods https://mirrors.cloud.tencent.co ... 92b7d7eca715b1ee0b8& B: V0 D' k2 H2 X
src/gz openwrt_base https://mirrors.cloud.tencent.co ... /arm_cortex-a9/base1 G- a$ M5 ?+ U/ a0 l( b
src/gz openwrt_luci https://mirrors.cloud.tencent.co ... /arm_cortex-a9/luci: ]2 y: Q* y; I- b0 k! p" e
src/gz openwrt_packages https://mirrors.cloud.tencent.co ... _cortex-a9/packages
2 J$ L+ n1 ]. G) F% p9 d6 V% Jsrc/gz openwrt_routing https://mirrors.cloud.tencent.co ... m_cortex-a9/routing  M  i% |& V4 l5 @! g" ~. O
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 ./
    ) f  }% T  J8 E
  2. x@x-Surface-Pro-3:~/下载/squashfs-root$ cd ../. N8 [0 R) @! c5 z" E7 A; k& A; I# U
  3. x@x-Surface-Pro-3:~/下载$ mkdir lxd-openwrt-master/dl
    : i0 z0 Q/ ~" @% ^* A9 \4 Y8 E
  4. x@x-Surface-Pro-3:~/下载$ mv openwrt-19.07.1-bcm53xx-generic-rootfs.tar.gz lxd-openwrt-master/dl/
复制代码
执行修改过的build.sh
% G4 I6 F# l! a4 j
  1. x@x-Surface-Pro-3:~/下载$ cd lxd-openwrt-master// Z1 i( `- V: N) S7 Y, O& ]
  2. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ ./build.sh -a arm -v 19.07.18 {1 ^9 ?) t  r$ g  K9 ?- r$ N+ m
  3. ......
    6 g2 ?! E9 n, S- m; ^3 ~
  4. Pack rootfs$ Y% K4 n+ q6 ]* v& B, J
  5. Tarball built: bin/openwrt-19.07.1-bcm53xx-generic-lxd.tar.gz6 X  K9 k# j- M( }7 z$ M4 p; t
  6. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ mkdir ../openwrt-19.07.1-bcm53xx-generic-lxc
    2 H# L/ {8 p  \; a, G7 S
  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$ m, @' k) I/ a' F# D1 F* z
  8. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ cd ../openwrt-19.07.1-bcm53xx-generic-lxc/9 \# L5 x# W/ Z0 i3 w3 j1 N8 _
  9. x@x-Surface-Pro-3:~/下载/openwrt-19.07.1-bcm53xx-generic-lxc$ ls! k! h  N) f, t* k; O! }8 B3 g
  10. metadata.yaml  rootfs  templates% e1 O! \* ^% }1 |2 y
  11. x@x-Surface-Pro-3:~/下载/openwrt-19.07.1-bcm53xx-generic-lxc$
复制代码

2 ]# C2 U: ~: e2 j* Q4、这时我们已经创建好lxc下可运行的openwrt19.07.1的rootfs,接下来处理lxc及rootfs的配置文件。
$ O1 K7 J" ~( U. U进光猫复制自带子系统的两个文件,再通过U盘或ftp传到Ubuntu的openwrt-19.07.1-bcm53xx-generic-lxc目录下,  |# y% c% a7 W$ E9 `5 S% w
  1. root@F650A:~ # cp /opt/upt/framework/saf/config /mnt/USB_disc1/
    2 Z9 @2 k! a4 H8 P& r9 P
  2. root@F650A:~ # cp /opt/upt/framework/pre-start.sh /mnt/USB_disc1/
复制代码
config为saf系统的配置文件,新系统下稍作修改,: u0 ?0 ]! i  [0 i: M$ v# b
lxc.arch = arm
  r) ?6 A. p5 slxc.utsname = openwrt
+ [8 i& Q; u1 N, M0 q& _lxc.rootfs.mount = /usr/var/lib/lxc/openwrt/rootfs/ C! e0 n0 D4 h0 [' Z5 W
lxc.rootfs.path = overlayfs:/opt/upt/framework1/rootfs:/opt/upt/apps/openwrt-rootfs : e4 P6 E: e2 p8 d
# lxc.rootfs = /usr/var/lib/lxc/openwrt/rootfs + P: O9 @5 h, q% M9 z* Y* ~; o5 t9 s% M
lxc.haltsignal = SIGUSR1
' [  l7 I; F+ ^' S" ylxc.tty = 1+ @) z! Q7 h' q+ J$ s
lxc.pts = 1
# t  j: d9 e! d1 h/ O1 ulxc.hook.pre-start = /usr/var/lib/lxc/openwrt/pre-start.sh8 Q4 v( ^: ^8 l
lxc.aa_profile = lxc-container-default-with-nesting/ ]/ m- {1 ]( @7 E: r
lxc.network.type = none
& M' {4 h. ]4 h! k3 t: b+ ]lxc.mount.entry = sysfs sys sysfs defaults 0 0
, }% P3 U& f% Glxc.mount.auto = cgroup-full:rw
% d" a3 x: ^" Q2 B  ?lxc.mount.entry = proc proc proc defaults 0 0. p1 v# T& a. H6 C- b" R/ m
lxc.mount.entry = /mnt mnt none rw,rbind 0 0
8 P$ x2 [8 ^- ?  J0 P" e  L5 G0 Jlxc.start.auto = 1

2 z6 j* b' c3 d' Q. V6 Cpre-start.sh处理模拟终端,为避免重复挂载devpts,添加一行卸载代码,
& J: h, N' a# y$ k: o# r
#!/bin/sh/ _% Y9 v( j' D# Z3 W
umount /dev/pts /dev/ptmx- \$ v/ g/ E" Q. f/ I: F
mount -t devpts -o newinstance -o ptmxmode=0666,nosuid devpts /dev/pts% T% n9 N$ O; U0 j3 I9 o& c
mount -o bind /dev/pts/ptmx /dev/ptmx

, K0 M/ V8 W' H再删除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镜像,  ]0 `. B2 M$ [3 s
  1. x@x-Surface-Pro-3:~/下载$ mksquashfs openwrt-19.07.1-bcm53xx-generic-lxc openwrt-19.07.1-bcm53xx-lxc.bin
    " _" j3 Z% I* Z2 K6 e
  2. Parallel mksquashfs: Using 4 processors* f: S! A/ U2 F. j) e0 O
  3. Creating 4.0 filesystem on openwrt-19.07.1-bcm53xx-lxc.bin, block size 131072.: [+ o/ q+ e. |3 d
  4. [=======================================================================================================/] 881/881 100%* i: A. v( v0 F' u

  5. : }- S, S. d* _6 A4 }, p2 K
  6. Exportable Squashfs 4.0 filesystem, gzip compressed, data block size 131072
    ' ^' _3 c3 l8 g5 n$ m6 c
  7.         compressed data, compressed metadata, compressed fragments,8 U/ j" _) D) y2 M" y
  8.         compressed xattrs, compressed ids
    ' S( O( [! K4 d
  9.         duplicates are removed3 O" y! I$ B: D4 ?) o# T% P- s; j
  10. Filesystem size 3163.90 Kbytes (3.09 Mbytes)
    ' l: d/ p# h8 g( ^6 s
  11.         48.94% of uncompressed filesystem size (6464.54 Kbytes)
    # S9 E% ?. R$ ?9 {% p
  12. Inode table size 9693 bytes (9.47 Kbytes)
    ! S. i& ~& U9 Y: J; S1 Q
  13.         25.72% of uncompressed inode table size (37693 bytes), w! g) Q6 P4 y. i
  14. Directory table size 11372 bytes (11.11 Kbytes)3 F; f7 c# l6 M. o6 x
  15.         47.17% of uncompressed directory table size (24108 bytes)
    % N8 V+ \+ G! @6 Z/ }1 R) p, L$ E
  16. Number of duplicate files found 136
    7 q$ F& m2 ~3 ^  V! A3 E5 h
  17. Number of inodes 1145* ^4 G$ R! _2 U7 i( Q
  18. Number of files 8731 s! x( v) B- v: g3 `" i
  19. Number of fragments 39+ M3 S; w- C  c6 J; h! c
  20. Number of symbolic links  1712 Q( J" a$ N( b2 e6 E
  21. Number of device nodes 0
    " {9 m+ K' v: X' Z
  22. Number of fifo nodes 0
    ' v& F( q" @: T5 n- X0 F; r: a
  23. Number of socket nodes 0* z0 w# r# _" I( f" x
  24. Number of directories 101
    / U7 C9 `0 k7 {7 @0 f* z. a* X
  25. Number of ids (unique uids + gids) 1# r4 W" [) ^. C2 j8 Y( i# [+ p
  26. Number of uids 1
    ; T- D; b1 d1 }& R9 G
  27.         x (1000)
    ( C* Y+ t: @" u$ Y6 b5 Y
  28. Number of gids 19 u4 I3 v9 X* a& z
  29.         x (1000)
    ; r/ K9 `$ J7 Z5 N: H
  30. x@x-Surface-Pro-3:~/下载$
复制代码
. }: Z. A* M6 Z+ t$ Z
+ {. _# g) H4 b: _
5、生成的openwrt-19.07.1-bcm53xx-lxc.bin传入光猫,'mtd' 写入mtd7分区。, p* J" Y) s& n. w4 u, \
刷之前先关掉saf,因saf有lxc-monitord进程守护,kill掉之后会自动运行,只好修改saf程序名,重启光猫。
. y  i- W- f. S, Y5 y7 t
  1. root@F650A:~ # mv /usr/sbin/saf /usr/sbin/saf.bak
    ' X( C* D) u  v* U3 [
  2. root@F650A:~ # reboot
复制代码
重启后telnet登录,'ps' 确认进程列表没有saf,备份然后写入并挂载。
root@F650A:~ # ps4 {5 f/ I4 ^/ B' X
  PID USER     VSZ   RSS  STAT  CPU COMMAND( T5 y# D6 v) `/ w% K
    1 root     23160   600  S     <1>  init
) ]: W& W; ^. u$ A: ~    ......* E  R0 Y' y! M$ E3 K
root@F650A:~ # dd if=/dev/mtd7 of=/mnt/USB_disc1/mtd7.bin bs=1M
  |9 p% k/ z# l. @; @8+0 records in
% N6 S5 W. `8 x4 q# H+ W& M8+0 records out/ j. b& \# \2 d$ ^
root@F650A:~ # mtd write /mnt/USB_disc1/openwrt-19.07.1-bcm53xx-lxc.bin /dev/mtd78 T; L( H7 g& @. r4 Y
Unlocking /dev/mtd7 ...
# r, s- Y/ }  b+ X# |" F! T, }
; F1 m1 [4 Y; I' fWriting from /mnt/USB_disc1/openwrt-19.07.1-bcm53xx-lxc.bin to /dev/mtd7 ...; b+ c) q! U6 i% d, A
root@F650A:~ # mount /dev/mtdblock7 /opt/upt/framework1
) N0 j3 G6 Q$ `/ z# f
6、开启OpenWRT新世界
9 A* t5 O3 b0 e+ q; G) z* X8 u4 w    写入mtd7分区并挂载之后,开始首次启动的准备工作。F650A的lxc默认路径在/usr/var/lib/lxc(一楼有说明),按config文件创建相应文件及文件夹,  O* {3 |1 y8 D! v: A0 U
" c5 t6 O8 ?% T5 W. B3 _
  1. root@F650A:~ # mkdir -p /usr/var/lib/lxc/openwrt
    . p/ k$ P  g& P) c+ p: h
  2. root@F650A:~ # cd /usr/var/lib/lxc/openwrt
    & q3 R9 v, Y" C4 @- D, N
  3. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/pre-start.sh pre-start.sh3 U0 ]( \/ w; C$ A5 H5 [4 H
  4. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/config config0 v6 ?  `: a& K, [
  5. root@F650A:/usr/var/lib/lxc/openwrt # mkdir rootfs
    ( t3 `% ?/ l+ D1 N, ^
  6. root@F650A:/usr/var/lib/lxc/openwrt # mkdir /opt/upt/apps/openwrt-rootfs
    1 B$ ^' Y3 m8 p' Y( F
  7. root@F650A:/usr/var/lib/lxc/openwrt # lxc-start -dn openwrt
    9 ^# g8 _% u3 E# P2 C
  8. root@F650A:/usr/var/lib/lxc/openwrt # ps
复制代码
此时的进程列表应该可以看到/usr/sbin/uhttpd、dropbear等,或者可以尝试打开浏览器 http://光猫ip/或ssh登录,如果看到Authorization Required提示登录或ssh提示登录用户名密码,表明lxc已成功运行,但此时无密码状态无法网页和ssh登录,只能通过控制台方式添加密码后才能实现。关闭openwrt容器,'ps' 确认,前台启动。9 Y9 g( S' v% R6 l  G/ E* E' a
  1. root@F650A:/usr/var/lib/lxc/openwrt # lxc-stop -kn openwrt: ?% I' q+ [: y4 `, i$ ?* `
  2. root@F650A:/usr/var/lib/lxc/openwrt # ps
    + x, a7 X7 R; d' R  ]
  3. root@F650A:/usr/var/lib/lxc/openwrt # lxc-start -n openwrt3 }; U" M/ U! @0 t; @3 ^- f+ t
  4. <6>init: Console is alive1 z% x# c1 J/ T3 l0 _6 ~% `
  5. <6>kmodloader: loading kernel modules from /etc/modules-boot.d/*0 `2 N4 ?6 G6 G* a6 \
  6. <6>kmodloader: done loading kernel modules from /etc/modules-boot.d/*
      G' c/ ~& c) B7 D2 m. L8 ]4 L
  7. <6>init: - preinit -
    1 N+ o8 V; G, O' l( |
  8. WARNING: Variable 'network' does not exist or is not an array/object. W. o& e0 _" F
  9. WARNING: Variable 'lan' does not exist or is not an array/object
    1 T! `7 I' ?- z: l
  10. Press the [f] key and hit [enter] to enter failsafe mode
    , ^- J3 F- R8 r, l5 ]
  11. Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level. g/ M3 G/ h% J: [4 J; T  D9 F
  12. <5>mount_root: mounting /dev/root, X1 r) D% Q$ i
  13. urandom-seed: Seeding with /etc/urandom.seed! O  K. V! n6 r& |( \/ d
  14. <6>procd: - early -+ o2 U9 _, u' w) v
  15. <6>procd: - ubus -
    & D% k' M2 H7 }
  16. <6>procd: - init -
    1 s2 Y( d+ a/ N0 m
  17. Please press Enter to activate this console.; A, ?7 s! U1 f1 |
  18. <6>urngd: v1.0.2 started.
复制代码
此时回车便可看到openwrt的登入界面,添加密码。2 ^* x# U9 B4 h: y/ \0 ?* Z) V

  1. 1 ]  V1 b7 O5 J- u, x2 \4 Q& \
  2. BusyBox v1.30.1 () built-in shell (ash)1 x& x7 a6 N8 l& w

  3. 5 N" J+ Z. I2 L# y$ m
  4.   _______                     ________        __
    5 [! i& S7 e3 z* Y: p
  5. |       |.-----.-----.-----.|  |  |  |.----.|  |_
    1 t, Q4 ^: J. Z4 }; c+ a: v
  6. |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
    5 B& H$ {$ o/ i& o0 r0 s
  7. |_______||   __|_____|__|__||________||__|  |____|7 I9 d: h6 g) D( l) L. W3 A# q1 v
  8.           |__| W I R E L E S S   F R E E D O M
    5 I0 ~* @. }8 c. y0 E
  9. -----------------------------------------------------
      e+ Z% ~2 Y+ J2 |
  10. OpenWrt 19.07.1, r10911-c155900f66
    ; [, p. ~4 b# d4 d6 u6 e; ]
  11. -----------------------------------------------------3 m! [0 Z3 n  f7 |9 i' u
  12. root@openwrt:/# passwd root
    : t' C5 a0 E0 z( E6 y7 K7 Y4 p1 ^
  13. Changing password for root
    $ P& c0 r( I3 i" G7 I2 K7 g
  14. New password:
    1 D+ H1 ^& G: D& m; y
  15. Bad password: too weak- m1 S6 R) c/ R& A5 h7 Y1 S3 Q' P5 W
  16. Retype password: / @4 e: Z) X. U$ P# Z. o
  17. passwd: password for root changed by root
    $ H" Y- ]$ f6 O- P  I
  18. root@openwrt:/# exit9 U& D; x4 K& g2 `
  19. Please press Enter to activate this console.
复制代码
控制台方式进入openwrt之后,exit无效,没找到正常的退出方式,只能关闭窗口,此后就可以通过网页和ssh正常登录。
* H; H  u8 x! p5 X4 @9 e6 i: N8 B9 P
7、自启动及进程守护
' y, C- x# B, e, V/ |    telnet登录光猫主系统,确认saf程序已备份,! I5 z' r- d4 U: u& ^

2 B" Z8 Z3 R( [/ O
  1. root@F650A:~ # ls /usr/sbin/
    0 g7 E( u/ X3 `  x8 L& i
  2. chroot       lsap         saf.bak      telnetd1 `6 [$ H7 B' o; r; G
  3. root@F650A:~ # vi /usr/sbin/saf
复制代码
填入 (2021年5月更新:去除USB端口挂载判定,避免无挂载时LXC不能启动)
; r7 S0 s3 ^8 I5 m& {" |6 i7 R
#!/bin/sh
0 j0 I9 d1 Y$ e9 S# add user-defined startup scripts here; {1 d4 L5 K$ I  {

8 e. N2 o1 f1 d+ L# S3 u& \4 n2 [  df | grep mtdblock7
9 @% J5 i- W1 J0 y  if [ $? -ne 0 ]
: @+ k- f2 q- n$ h/ q    then1 G, T; n% _( n5 u8 G! W
      /bin/mount -n -t squashfs -o ro /dev/mtdblock7 /opt/upt/framework1
& c* T# X  [& t' z: L+ e& \8 L  fi
( `1 i. s5 n9 v- v##
! F+ N- t5 z* n! m1 z
( W9 V/ q; ~" J! [#  ps | grep ntfsmount | grep -v grep
6 D3 L5 ]' g  E5 W0 z1 f' \' N: R#  if [ $? -eq 0 ]0 L3 Y. y  N" {  J9 B
#    then
; D9 m/ B! z5 I4 \2 L* P9 `' Z) G      /dbus/usr/bin/lxc-start -dn openwrt% b4 ^/ h) m+ Y# B) T
#  fi: y# K! }% ~% T- \. J8 B
##
4 \. [+ _- Y! o; B. i/ s
或者在电脑编辑好内容,命名为saf,传入/usr/sbin/,'chmod +x' 添加执行权限,重启光猫。9 U4 m$ N! J# O
+ E6 x6 ^' `, ^8 H9 @
8、后续问题2 I. M6 N9 g' {6 \8 i( l& P" `
    目前的openwrt安装或更新程序会报错,缺少 libustream-openssl 、ca-bundle 、ca-certificates 和 libopenssl1.1,还需要修改dns,添加中文等; m6 c' z1 F' Q2 n) q
( U2 u9 c; _7 W! T
  1. root@openwrt:~# opkg update8 T# d: y: |: B  w# @
  2. Downloading https://mirrors.cloud.tencent.com/lede/releases/19.07.1/targets/bcm53xx/generic/packages/Packages.gz" {+ E; y: _( E  {3 G
  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.
    * X4 L/ i- L& P7 h1 f; Y, F
  4. *** Failed to download the package list from https://mirrors.cloud.tencent.com/lede/releases/19.07.1/targets/bcm53xx/generic/packages/Packages.gz
复制代码
这些安装包可以从腾讯的镜像站下载然后手动安装。
6 K2 H6 u1 M0 w  i4 F" V7 {0 Q4 t" B
  1. root@openwrt:~# cd /mnt/USB_disc1/- w, ^7 K" k8 G& P
  2. root@openwrt:/mnt/USB_disc1# opkg install *.ipk
复制代码
修改dns7 e9 k* u+ d( s" G, H% h; t6 [# `
  1. root@openwrt:/mnt/USB_disc1# rm /etc/resolv.conf
    $ m+ G  S7 s6 V8 C7 Z, B4 y" T% o
  2. root@openwrt:/mnt/USB_disc1# vi /etc/resolv.conf
复制代码
填入,保存1 _4 C  l. Q# R0 \5 y
nameserver      223.5.5.5; {/ j0 [' _& U) j
nameserver      8.8.8.8$ j* F5 R$ D5 L) Q% g
nameserver      2001:da8::666
. J# E8 j" d3 H5 I) C9 j6 I
嫌过程繁琐的可以直接下载我配置好的镜像,从第5部分最后开始操作,将下载的openwrt-19.07.1-bcm53xx-lxc.bin和saf-lxc-start-openwrt放入光猫上的u盘,子系统默认root密码123456。! ~) G8 h- A- e9 w; ^* f2 S/ k
  1. root@F650A:~ # dd if=/dev/mtd7 of=/mnt/USB_disc1/mtd7.bin bs=1M
    % Y0 ~1 o. S+ N- @2 N! d' V1 j! S
  2. root@F650A:~ # mtd write /mnt/USB_disc1/openwrt-19.07.1-bcm53xx-lxc.bin /dev/mtd7
    ( S9 o0 v; u. d2 R( S
  3. root@F650A:~ # mount /dev/mtdblock7 /opt/upt/framework1
    + `$ p+ K9 k8 O8 m$ L5 i
  4. root@F650A:~ # mkdir -p /usr/var/lib/lxc/openwrt
    , x- B0 Q" U% Z8 {- o
  5. root@F650A:~ # cd /usr/var/lib/lxc/openwrt. I0 E( Q7 y% z  h% C
  6. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/pre-start.sh pre-start.sh9 c' ]+ H3 o7 j0 g, }
  7. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/config config
    ; J+ R7 m; R1 l) T, M' s
  8. root@F650A:/usr/var/lib/lxc/openwrt # mkdir rootfs$ H! H. P1 J  G+ ~( g
  9. root@F650A:/usr/var/lib/lxc/openwrt # mkdir /opt/upt/apps/openwrt-rootfs$ {- x: g; C, N9 h, y% q8 Q* @% A" x
  10. root@F650A:/usr/var/lib/lxc/openwrt # lxc-start -dn openwrt  f4 ^7 R" K  U+ y3 ]% k: b$ F7 K
  11. root@F650A:/usr/var/lib/lxc/openwrt # cd ~ , V! s/ ~- w8 B) I
  12. root@F650A:~ # mv /usr/sbin/saf /usr/sbin/saf.bak1 a3 t: S* J* T5 c. g5 j
  13. root@F650A:~ # cp /mnt/USB_disc1/saf-lxc-start-openwrt /usr/sbin/saf
    / G  T) {8 k1 z; m6 h6 U
  14. root@F650A:~ # chmod 0755 /usr/sbin/saf
复制代码
   虽然子系统的openwrt可以顺利运行,但经过我的测试,kmod类app大多无法正常工作。比如F650A内核不支持ext4文件系统,在子系统安装kmod-fs-ext4,尽管可以安装成功,但重启后提示 modprobe 启用ext4模块失败。9 ^; P  D# ?( f- J
        子系统的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管理页面,需要更改光猫主系统,此操作的定制空间更大,有机会的话在后面回复中整理出自定义光猫固件的思路。
1 O9 i3 m. o4 P: D* T. M9 ^& a$ J" ?/ O8 E. I

本帖子中包含更多资源

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

×
发表于 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刷进去的?
" X2 E: f! H; V1 ~6 k6 x中兴非15.0.1出问题是你没清理/opt/upt/apps//apps目录
% ~. e1 \% W! y! T, H几乎所有光猫为了节省空间?都会有部分lib和var目录重用主系统的文件,openwrt下e8clib和e8cvar可以看看。
$ D# H/ P+ V$ a# _$ l( R0 k另外中兴编译的openwrt开始了uclibc的xlocale配置,这也是achaoge直接用omap源的APP无法运行的原因,我自己有手动开启xlocale后编译omap的openwrt放进去运行OK。
* W# P+ K0 d3 |* O; C3 c5 Y有兴趣可以一起研究玩。
 楼主| 发表于 2020-2-20 21:40:34 | 显示全部楼层
anysoft 发表于 2020-2-20 12:589 o, \* _: k* q9 v$ s5 W
坐等lxc的教程,另外19openwrt是你自己编译的还是直接下载armv7的官方bin刷进去的?  N1 _2 W) C1 S! g, x: z
中兴非15.0.1出问题是 ...

% D& u* j# z- Z
/ j$ @- C6 W1 d* ~! i# Jopenwrt1907用的官方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
' C$ d3 A: E4 I; _5 O/ u! p& Aopenwrt1907用的官方rootfs经https://github.com/mikma/lxd-openwrt修改而来;xlocale的问题我在编译主 ...
& i1 G4 Q% K  Y5 m( d. I
是的, 中兴使用的是buildroot-2015.8.1,这个strings 一下sendcmd 就可以看到
0 a' k+ c. t- W( t% C/ ^
1 a! V* Q5 m) c( k2 F1 R, G+ H看了下操作步骤,其实如果内存足够,没必要关闭saf启动的天翼网关。' `) A0 ?! |3 w0 O6 f7 M
可以让lxc容器启动两个op应该是可以的,F650A和华为hs8145V应该都是512MB内存,内存足够,openwrt可以放到apps分区文件夹下,不一定要写入mtd7再手动挂载。
1 r0 J6 E8 X0 {4 y  i) ^
; }/ @# B; ~$ Q: K0 v+ }我的HS8145V启动后内存只占用了30%,足够了。
. {+ _2 H7 d# ?& B1 `% B2 C+ {- U- g" q+ Y6 R" w; x* d6 l4 @$ P- f8 M
另外主系统下的usr/sbin目录下文件不是内存加载的rootfs对应的squash文件?这个更改应该不会回写到文件系统,重启应该就会消失?
! |! \. S& ?1 Q; D6 J不晓得中兴和华为是不是一样的。可能中兴可以修改文件吧,华为的只能dd备份rootfs分区后自己解包修改打包后再dd写进去,会有砖的风险,砖了只能上编程器。
+ S/ [+ A/ K9 e+ q8 j* G! k" q4 S) B: |- j: o
至于端口问题可以在打包openwrt的时候先修改每个服务对应监听端口就不会冲突了。
! [( K; M( T) Y1 P1 t2 i

本帖子中包含更多资源

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

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

本版积分规则

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

GMT+8, 2025-2-7 03:10 , Processed in 0.045311 second(s), 7 queries , Redis On.

Powered by Discuz! X3.5 Licensed

Copyright © 2001-2020, Tencent Cloud.

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