找回密码
 注册

QQ登录

只需一步,快速开始

查看: 82873|回复: 98

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

  [复制链接]
发表于 2020-2-17 02:14:04 | 显示全部楼层 |阅读模式
本帖最后由 songee 于 2022-4-27 21:04 编辑 0 m- x- n2 U& z8 A
' v! h" g. ~2 N& S: s3 U
家里装宽带,电信200M,送了个中兴F650A。自带的天翼3.0web界面看着不错可惜几乎没有可玩性,闲来无事研究一番。. {' }* W7 y) Q" K% ?  V% }. K
    借鉴论坛前辈achaoge的帖子:中兴 F450A/F650A 免 TTL 持久开 ssh顺利开启telnet,发现该光猫的运作机制是 主系统负责底层的硬件驱动、sendcmd管理系统(telnet、超密、ppp拨号、网络及WiFi、ftp等)、以httpd为基础的8080端口电信web管理界面,最后启动saf(lxc容器管理)程序。4 ^  ~# r) G, T% |" u
    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数据存放区,操作时需要特别注意!!
' M& b; A' a' D  x0 ?8 ?  e
  1. root@F650A:/usr/sbin # saf0 ]0 j: U+ ~5 S/ a6 \
  2. Usage: saf service FWK_MTD_ID1 FWK_MTD_ID2 APPS_MTD_ID (eg. saf service 9 10 7)
    ; i2 [" [6 s5 l. o% k/ Q
  3. saf console4 U6 W  P5 z# ^. q. l
  4. saf info
      a9 F: o7 N+ X4 L+ i
  5. saf version& M: ?; b' p+ |! H5 i: \
  6. saf getfwkver2 @' c* e. Q: |: V$ u
  7. saf getbakfwkver
    * y$ g; k% M$ N% e
  8. saf getactive
    * P0 ~! `, e/ J% W; z4 Y
  9. saf setactive FWK_MTD_ID [AFTER_REBOOT] (eg. ./saf setactive 17 1)
复制代码
  1. root@F650A:~ # cat /proc/mtd' I& c- G) M1 {2 e
  2. dev:    size   erasesize  name/ S) q3 i4 n2 \( E) V" ?
  3. mtd0: 08000000 00020000 "whole flash"
    ' `% m* W/ Y( n, |: {7 p8 x
  4. mtd1: 00100000 00020000 "u-boot"5 f# T- s( j% b
  5. mtd2: 00080000 00020000 "others"$ {5 M% i2 a* h7 H$ t8 G
  6. mtd3: 00100000 00020000 "parameter tags"0 t- C( r7 x1 j# v" r/ D3 O
  7. mtd4: 00100000 00020000 "wlan"
    7 x- j2 |. t; ?/ Y1 X
  8. mtd5: 00200000 00020000 "usercfg"1 E- K( P' H+ ]+ i
  9. mtd6: 00800000 00020000 "framework"" r" [' v5 _: c$ |5 b( [+ M9 E# _, a
  10. mtd7: 00800000 00020000 "framework1") S1 [/ B' |. t
  11. mtd8: 00780000 00020000 "dbus"
    9 V! P. t# X* K
  12. mtd9: 01280000 00020000 "kernel1"' c; f* \7 g" E
  13. mtd10: 01280000 00020000 "kernel2"% w' T6 O# X& }" e8 A& J
  14. mtd11: 03e00000 00020000 "plugin_data"" o" c$ k; k' T6 \* ^$ U! Y- c/ o6 Q  f
  15. mtd12: 01240000 00020000 "rootfs"
复制代码

4 ?8 x7 t' n. C  m0 W' {5 y' q    saf程序管理子系统,是通过系统的lxc容器实现的,在/dbus/usr/bin/目录下有lxc相关程序,但并非标准的官方版,而是定制的,lxc.lxcpath即lxc容器存放位置设定为/usr/var/lib/lxc,暂时没有发现更改的方法(也没什么必要)。
root@F650A:~ # ls -l /dbus/usr/bin
/ ]7 T2 w/ D4 o9 _total 377
# p% a" s9 u8 |3 b1 \& J" ]$ a-rwxr-xr-x    1 root     root         10143 Nov 15  2018 dbus-cleanup-sockets5 T2 F8 @( J# Y; k& L8 o
-rwxr-xr-x    1 root     root         18867 Nov 15  2018 dbus-launch, t( z, u9 r7 `4 B. m" a0 A
-rwxr-xr-x    1 root     root         22537 Nov 15  2018 dbus-monitor( O7 o0 ^" @. f
-rwxr-xr-x    1 root     root         11049 Nov 15  2018 dbus-run-session- t. c- c; |# u7 Y9 Z
-rwxr-xr-x    1 root     root         23431 Nov 15  2018 dbus-send3 c  D6 p) u# j
-rwxr-xr-x    1 root     root         19495 Nov 15  2018 dbus-test-tool
" [1 y% N7 Y0 l  z, v# _-rwxr-xr-x    1 root     root         12257 Nov 15  2018 dbus-update-activation-environment2 `# b! @) Y, U' [" |( `" d
-rwxr-xr-x    1 root     root          8365 Nov 15  2018 dbus-uuidgen
' l' b" d; s6 a) F# W: I- u( i-rwxr-xr-x    1 root     root         33112 Nov 15  2018 gdbus
6 O& n& Y9 I; y0 D9 X2 x  T-rwxrwxrwx    1 root     root         12332 Nov 15  2018 lxc-attach) z! E3 }) w$ o
-rwxrwxrwx    1 root     root         14241 Nov 15  2018 lxc-autostart
3 P* n: O$ T+ _2 E9 b8 n, J-rwxrwxrwx    1 root     root          9122 Nov 15  2018 lxc-cgroup- u7 u* y3 Z. E# B
-rwxrwxrwx    1 root     root          4414 Nov 15  2018 lxc-checkconfig& o" y% ]! }6 F% X( H( |7 W( ?- G7 G
-rwxrwxrwx    1 root     root         10175 Nov 15  2018 lxc-clone( U, G' A2 y% \. l, d
-rwxrwxrwx    1 root     root          6181 Nov 15  2018 lxc-config
- q- o0 A4 O" f6 g" @-rwxrwxrwx    1 root     root          8590 Nov 15  2018 lxc-console4 ?. W- d8 i0 Q) g0 q  U
-rwxrwxrwx    1 root     root         14556 Nov 15  2018 lxc-create  h  Y5 \  d* V6 L+ U
-rwxrwxrwx    1 root     root          8540 Nov 15  2018 lxc-destroy1 q/ y* |# M8 B& U% Q
-rwxrwxrwx    1 root     root         10027 Nov 15  2018 lxc-execute
1 D& {6 t7 |6 |' L+ t( }/ p-rwxrwxrwx    1 root     root          8630 Nov 15  2018 lxc-freeze3 X0 B+ P: B' R& `  z4 X
-rwxrwxrwx    1 root     root         18956 Nov 15  2018 lxc-info1 f4 _; y7 x# w
-rwxrwxrwx    1 root     root          2834 Nov 15  2018 lxc-ls* e! N6 U: A% |' O/ O% P5 e3 }
-rwxrwxrwx    1 root     root         11122 Nov 15  2018 lxc-monitor
4 P& X6 S8 v% `. s% p. F0 i-rwxrwxrwx    1 root     root         12270 Nov 15  2018 lxc-snapshot  d* ?0 K# P3 n( ?1 ]
-rwxrwxrwx    1 root     root         15356 Nov 15  2018 lxc-start* R" c% z2 F5 K. d, C
-rwxrwxrwx    1 root     root         10055 Nov 15  2018 lxc-stop
6 d; E7 M! ~5 h& [; J1 x! C-rwxrwxrwx    1 root     root          8634 Nov 15  2018 lxc-unfreeze
1 o  y- d& J$ U7 P+ \8 Q3 h-rwxrwxrwx    1 root     root         12380 Nov 15  2018 lxc-unshare2 I4 H6 Q6 a* d* p9 I% r/ t$ M
-rwxrwxrwx    1 root     root         13324 Nov 15  2018 lxc-usernsexec* C: [/ O3 U+ c5 L% r, B% R
-rwxrwxrwx    1 root     root          8561 Nov 15  2018 lxc-wait
  1. root@F650A:~ # lxc-config -l3 v- f9 s' L3 S+ ?
  2. lxc.default_config
    $ {, l. P* t! a" @
  3. lxc.lxcpath+ \/ [$ z  A  R7 d" V( u- n
  4. lxc.bdev.lvm.vg. H; ?% C) E$ t7 Y
  5. lxc.bdev.lvm.thin_pool, e8 D# W0 [# m
  6. lxc.bdev.zfs.root, E5 `6 b$ f# K/ e" Y; W$ p* i
复制代码
  1. root@F650A:~ # lxc-config lxc.default_config
    6 L) v3 c& D, ?$ d
  2. /usr/etc/lxc/default.conf
    : i" K) G8 q4 v! U8 m: |
复制代码
  1. root@F650A:~ # lxc-config lxc.lxcpath% C6 `% J9 G% R$ s$ I
  2. /usr/var/lib/lxc
复制代码
: Y6 O$ w  F8 M# G! A9 a
    了解系统运作机制之后,我最初打算借用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方式开启新世界,操作步骤在本文回复中细谈。
5 i, r, I6 g6 T% U    经过几番折腾,已将系统原有的openwrt中兴定制版saf子系统完全替换为官方openwrt19.07.1(lxc方式启动),不影响光猫拨号且可在线安装及更新非kmod类app,如ariang离线下载,samba文件共享,甚至各类科学上网工具(性能及安全原因不推荐)。
# l2 F' O- j$ n7 V
% j/ T% I. r+ F. q0 [
' e) g% g' P4 _6 B4 z5 h6 Q+ \! T; T0 k$ M) p/ O1 t6 M; a9 U

! x* d0 U& U) `5 Q, W
' \, P4 f3 H2 n9 U# {, n( @8 {6 ?4 t

2 q# t, k0 W- [5 O

本帖子中包含更多资源

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

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

简化并更新OpenWRT22.03.0 RC1版本

本帖最后由 songee 于 2022-4-26 23:39 编辑 & C: s# o, Q& p* B! n! t7 Y" E9 V
( |. z( U! N: _& Y, e4 ~
因二楼原帖过程过于繁琐,近期尝试了一种较为简单的办法。
) n) N+ f# A: S: Z* u& G: M5 L$ N+ Q# O% x% L

# v7 H4 b1 J2 y7 R' Z  I1、下载openwrt.org固件,我选的是openwrt-22.03.0-rc1-bcm53xx-generic-tenda_ac9-squashfs.trx,binwalk分析squashfs偏移量并用dd取出,unsquashfs提取rootfs,打包为rootfs2203rc1.tar.gz,传入光猫临时目录,如 /run/shm 。
* l+ d6 F* E8 v, X) U* D7 z! _' s2 ^1 D; B$ s( ?. e- i& w
2、将rootfs2203rc1.tar.gz提取至 (lxc-config lxc.lxcpath)/openwrt/rootfs 。
( X' Y+ u3 K9 w. Q* z) D8 ^8 p9 F% r
  1. root@F650A:/usr/var/lib/lxc/openwrt/rootfs # tar -xzvf /run/shm/rootfs2203rc1.tar.gz -C ./
复制代码
. a+ p" U. A* H+ K

: K1 l+ Z  j7 q; I: J+ L3、修改rootfs。openwrt的网络配置与主系统有冲突,需要清除。
% X4 j8 m1 y3 i0 M' L  t  E    3.1 移除 ./etc/board.d/ 目录下 01_leds 、02_network 、99-default_network 三个文件。: W+ A' J8 z/ O( U% W6 f  g
    3.2 移除 ./etc/rc.d/ 目录下 K21wpad 、K85odhcpd 、K90network 、S19dnsmasq 、S19firewall 、S19wpad 、S20network 、S35odhcpd 、S96led。, g, Y9 |$ h$ O' J( |# T2 w
    3.3 移除 ./etc/modules.d/ 和 ./etc/modules-boot.d/ 及 ./lib/modules/5.10.111/目录下所有文件,openwrt的kernel modules与光猫内核不兼容。' f* ?# S* O) n6 u

  R8 K+ ?/ B, _. u+ _    3.4 修改opkg源 ./etc/opkg/distfeeds.conf(可选)
- u2 A: E/ o* J: }! ?& @4 g. J
  1. src/gz openwrt_core https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/targets/bcm53xx/generic/packages1 H: R4 ]6 h+ a7 T! {
  2. src/gz openwrt_base https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/base
    ! I6 u* r/ m) e5 _  A
  3. src/gz openwrt_luci https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/luci
    2 o: f& Q" d  m1 H- ?
  4. src/gz openwrt_packages https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/packages) {5 p1 {. G9 Y, i9 V. e8 Z
  5. src/gz openwrt_routing https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/routing' p/ A4 B' M# M3 l! \; F- v; I1 r
  6. src/gz openwrt_telephony https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/telephony
    - c' m5 T- T( b# C& q% V7 \; H( [- N5 S
复制代码
  3.5 修改 ./etc/inittab 实现启动项自启(参考https://github.com/mikma/lxd-ope ... r/files/etc/inittab
# z/ K3 U2 ~; [4 g& ^  f" B6 p
  1. ::sysinit:/etc/init.d/rcS S boot/ O- Q) W2 D6 ]! `
  2. ::shutdown:/etc/init.d/rcS K shutdown! y4 g7 k. n+ T' U* R1 v( }
  3. console::askfirst:/usr/libexec/login.sh
复制代码
  3.6 修改密码 ( root 密码 chinadsl
+ ?9 z/ }5 F+ J. n* y* d6 O' }3 x( \( m
  1. root@F650A:/usr/var/lib/lxc/openwrt/rootfs # chroot ./- U% m: i) g- t  g# n  u% R

  2. ' T7 Z4 y1 z/ n+ x2 G: k+ Y6 m
  3. ' X4 u' G! z/ Z1 h# S
  4. BusyBox v1.35.0 (2022-04-20 10:37:37 UTC) built-in shell (ash)
    3 v5 Y$ A# |8 f

  5. , W5 m2 I/ R1 h( I
  6. root@F650A:/ # passwd/ @: ~& t5 i! o$ A) G7 ]# N2 @' X
  7. Changing password for root
    / T1 h8 g, ~. e, P1 U
  8. New password:0 a6 S0 s( A) B& c, Q! I
  9. Bad password: too weak
    2 a# E- ]( C. q  p
  10. Retype password:9 O* g" ^8 ^; V6 }7 X0 ?1 W) {
  11. passwd: password for root changed by root
复制代码
  3.7 删除 ./etc/resolv.conf 软连接并新建./etc/resolv.conf,否则openwrt无法解析域名0 S! m. ]% l/ v) b6 H1 v
  1. nameserver 223.5.5.5; s/ @! w* A3 b* n
  2. nameserver 2001:da8::666
    1 X4 S5 y7 s( {
复制代码

) u1 ]7 P2 _( w" p' u) X' S( O( D2 X- q4 |# {6 R; o- V: C
4、修改lxc配置文件 /usr/var/lib/lxc/openwrt/config ,根据各自光猫环境修改测试,这个配置我的F650A可正常使用。6 u  K8 x: U1 L( J6 J$ Q
  1. lxc.arch = arm
    ! z, C4 q/ e4 b9 x6 F
  2. lxc.utsname = openwrt
    2 }" u1 I( m+ Z/ t
  3. #lxc.rootfs.mount = /usr/var/lib/lxc/openwrt/rootfs
    8 F$ G! F- l  z1 m0 a
  4. #lxc.rootfs.path = overlayfs:/opt/upt/framework1/rootfs:/opt/upt/apps/openwrt-rootfs+ l) Z. q2 [. W7 e  [
  5. lxc.rootfs = /usr/var/lib/lxc/openwrt/rootfs
    " q! ?9 h2 c8 y/ b% N; C1 Z
  6. lxc.haltsignal = SIGUSR17 m; D* z4 t4 ]% K0 f
  7. lxc.tty = 1. ]0 F1 {( \- C1 u9 P+ t% @
  8. lxc.pts = 1
    3 j/ h# M: T3 Z0 a* `6 v( h
  9. #lxc.hook.pre-start = /usr/var/lib/lxc/openwrt/pre-start.sh
    * B( [4 S" K  Q0 q/ ?1 T
  10. lxc.aa_profile = lxc-container-default-with-nesting
    6 w, {. _2 b. A* l8 D! d
  11. lxc.network.type = none7 X1 z) G5 T# |" `! v: Z
  12. lxc.mount.auto = cgroup-full:rw1 }& z: V1 p+ J/ F
  13. #lxc.mount.auto = proc sys cgroup  j7 j; m2 @3 y: |
  14. lxc.mount.entry = sysfs sys sysfs defaults 0 0" z9 u* c' e( K! t
  15. lxc.mount.entry = proc proc proc defaults 0 0
复制代码
; a7 V$ |' B# [3 |4 C
" z4 C9 C' v. c" ]5 K
5、启动,根据提示按enter进入控制台。
# o6 m) C$ E# g7 V5 E5 ]0 ~: g3 [- i$ u
  1. root@F650A:~ # lxc-start -n openwrt: h# o5 L; R1 R1 H6 g
  2. <6>init: Console is alive
    / k2 R/ F# E. N- a
  3. <3>init: Failed to redirect stdin to /dev/null: No such file or directory5 Z5 |  J% Z3 ^, m6 W0 O; k
  4. <3>init: Failed to redirect stdout to /dev/null: No such file or directory
    . Y2 {  `& ]2 U2 u# W* H$ ^
  5. <3>init: Failed to redirect stderr to /dev/null: No such file or directory' |- W. T+ O, W0 l# c
  6. <6>kmodloader: loading kernel modules from /etc/modules-boot.d/*
    3 |9 W- e# n5 E5 V: a  b6 w
  7. <6>kmodloader: done loading kernel modules from /etc/modules-boot.d/*2 x; \. E3 S9 R; J! E
  8. <6>init: - preinit -
    " ~5 X; K; j5 D8 T% G
  9. ls: /etc/board.d/*: No such file or directory
    4 v' e# Q( X7 |" p
  10. Press the [f] key and hit [enter] to enter failsafe mode. Y& B3 \3 I: O5 z0 q# h8 j; m
  11. Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level! t7 w2 l7 }" K: Q# [' j
  12. <3>mount_root: Could not open mtd device: /dev/mtd12
    1 c+ [! F/ \( F2 a3 O
  13. <3>mount_root: reading rootfs failed, o( z- ~. i* Y) |  a. c' D$ o
  14. <5>mount_root: mounting /dev/root5 T6 a9 N  @, w" E* L' \
  15. urandom-seed: Something is wrong with /dev/urandom
    - u6 t/ w3 f8 ?3 e
  16. <6>procd: - early -
    / Q3 t8 D' k& F; e1 B0 B; v
  17. <6>procd: - ubus -
      G6 a3 T' i+ I( u9 w* I6 {, @
  18. <6>procd: - init -
    , j. Y" c9 g# r' P  u8 G# v
  19. Please press Enter to activate this console.1 V$ s# l" z+ q/ A/ L0 ~- Z
  20. <6>kmodloader: loading kernel modules from /etc/modules.d/*
    $ X% i0 K+ g; y$ j% I$ @& ^
  21. <6>kmodloader: done loading kernel modules from /etc/modules.d/*
    . r- `1 E# p9 r" D. [. g
  22. <6>urngd: v1.0.2 started.6 p8 u, g% f' d* J. }
  23. 8 p* J$ F  o) g5 b; _" D; q
  24. 0 F8 T1 |" d: c# q; P* ?
  25. 3 \8 \$ [2 I( l% g
  26. BusyBox v1.35.0 (2022-04-20 10:37:37 UTC) built-in shell (ash)' [' V& w. T( o
  27. 8 Z0 H6 c0 q1 N
  28.   _______                     ________        __7 q  x; @# s$ Z) f  C) c* @" ~6 q
  29. |       |.-----.-----.-----.|  |  |  |.----.|  |_+ O. A( F( U* z# h# D& |
  30. |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|% v8 x+ }! C  E: L
  31. |_______||   __|_____|__|__||________||__|  |____|. s' R( {& N9 |, H- ~: l
  32.           |__| W I R E L E S S   F R E E D O M
    + s. N8 D9 s$ ^$ _, {! ?! S
  33. -----------------------------------------------------
    / g1 Y4 r: _5 V* |3 t. {7 v8 R: ]# ~
  34. OpenWrt 22.03.0-rc1, r19302-df622768da, x' W, Y$ n5 m
  35. -----------------------------------------------------
    3 d% r; {3 A0 u; E/ a4 U
  36. root@openwrt:/#
复制代码
7 i6 P: @" Z! U4 ~! ]
1 e3 m2 i. P  s8 I
  1. root@openwrt:/# ps
    # s+ `; L0 p& C( R: r/ ~: u
  2.   PID USER       VSZ STAT COMMAND% C# E1 [  `. E( G. q4 ]
  3.     1 root      1452 S    /sbin/procd$ |& U7 K3 D& ]: }" c
  4.    58 ubus      1112 S    /sbin/ubusd
    % @9 E$ @3 W" P1 b
  5.    59 root      1196 S    /bin/ash --login
    5 v2 W) v7 q4 D* q% {4 a$ N# R
  6.    93 root       908 S    /sbin/urngd8 w' u% T* O6 U
  7.   204 root      3736 S    /usr/sbin/uhttpd -f -h /www -r OpenWrt -x /cgi-bin -u /ubus -t 60 -T 30
    $ {$ B3 m* S$ i1 E3 s  T
  8.   487 root      1952 S    /sbin/rpcd -s /var/run/ubus/ubus.sock -t 308 z+ o$ H' K& t( e
  9.   556 root       956 S    /usr/sbin/dropbear -F -P /var/run/dropbear.1.pid -p 22 -K 300 -T 3
    $ L8 v9 s* h4 l" k3 g1 c
  10. 1065 root      1200 R    ps
    3 e5 v) j7 t" r: [0 g
  11. root@openwrt:/#
复制代码
( L# {6 L1 b7 T

) ^9 N' z7 s. H4 L" u2 L! d% j
  1. root@openwrt:/# opkg update
    ' B0 Q9 i, B% e  s8 b  ~, n: {2 U& m  z4 s
  2. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/targets/bcm53xx/generic/packages/Packages.gz
    7 U3 g  W$ b% z. p4 @" d; U2 i
  3. Updated list of available packages in /var/opkg-lists/openwrt_core
    - X; N% F7 n. @; \  x
  4. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/targets/bcm53xx/generic/packages/Packages.sig
    * u6 o9 e9 F; a- J9 D9 w
  5. Signature check passed.8 a0 V6 q0 F, }$ H
  6. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/base/Packages.gz& `" U7 p8 U& j0 n* i7 Z$ ~% O
  7. Updated list of available packages in /var/opkg-lists/openwrt_base: d2 [: o, R; Q
  8. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/base/Packages.sig. i( k- p$ [  ]3 z( v% R
  9. Signature check passed.
    ; }* f6 f( z0 y% f: {- T, u
  10. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/luci/Packages.gz, V0 v" w+ y# u, X3 b7 L" I
  11. Updated list of available packages in /var/opkg-lists/openwrt_luci0 a3 n  S. y& P) P
  12. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/luci/Packages.sig) H' ^! H8 o6 l4 d% y# G3 Y
  13. Signature check passed.) W- Y2 x5 n5 t' e/ e
  14. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/packages/Packages.gz
    . J% E8 K. D* S' \# u
  15. Updated list of available packages in /var/opkg-lists/openwrt_packages
    8 c3 k* N1 v  A+ p; F/ E, D
  16. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/packages/Packages.sig2 h4 t% N7 R% A# ~& I0 X+ F
  17. Signature check passed.
    + p2 I7 C: N) ~/ n% O" d9 N
  18. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/routing/Packages.gz
    ) u! f  ~* o+ Z3 K" F
  19. Updated list of available packages in /var/opkg-lists/openwrt_routing5 n2 c/ q: Q+ G5 O  s5 @# E) c
  20. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/routing/Packages.sig
    - i+ y2 t7 B: H$ J+ D
  21. Signature check passed.0 G$ D; ]# o% Z
  22. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/telephony/Packages.gz$ p; y* o/ f1 W( `3 n3 M
  23. Updated list of available packages in /var/opkg-lists/openwrt_telephony
    9 y& u. j) r+ e0 O5 O6 R
  24. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/telephony/Packages.sig
    1 m. }$ }% [5 y3 C# x' J
  25. Signature check passed.
    0 `6 k! E/ Z7 T$ [* @' p+ F
  26. root@openwrt:/#
复制代码

# G- ~3 c/ l2 L! {, N' g6 F. m; s% {& x1 K
此时临时的openwrt系统已建好,运行的服务有两个:http占用主系统的80和443端口,ssh占用22端口。1 z* G9 b- o$ a+ ~+ i2 j

3 Q; |4 I0 X2 E$ R6 {- Y+ |9 m如果光猫有公网IP,请务必关闭ssh密码登录并使用密钥。
. R/ m* I4 k& h9 i0 D7 \$ t. u3 X/ ?- [) v# f5 P
后期使用建议使用 lxc-start -dn openwrt 后台启动,使用 lxc-stop -kn openwrt 命令关闭。openwrt管理使用ssh密钥登录。
' t) W. K! H4 k. r" c$ J: E, O2 B需要固化openwrt到固件的,可以打包rootfs和config(需修改配置),mksquashfs制作成squashfs,用mtd写入saf分区,就不用担心恢复出厂设置了。
, G( T% C9 m, I5 O8 f- m" f- U随光猫启动可以参考二楼。
: U! N7 O. {1 G% ~9 s5 C/ h0 z" H, I  E1 g  ]

本帖子中包含更多资源

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

×
 楼主| 发表于 2022-4-27 23:10:13 | 显示全部楼层
因光猫原系统的busybox功能不完整,也没有nano和dropbear,调试lxc可能会不方便,现分享出来。  U/ g2 W$ o0 L2 ?0 z

# ?5 e8 \3 D& w0 P
  1. root@F650A:~ # /usr/bin/busybox- o3 b; w. J7 M2 E
  2. BusyBox v1.23.2 (2020-06-16 16:53:26 CST) multi-call binary.
    1 v& D  c( N. j$ C2 d3 c- Q
  3. BusyBox is copyrighted by many authors between 1998-2012.4 x% n4 i8 K$ a  Q) Z( h
  4. Licensed under GPLv2. See source distribution for detailed) T$ f; S: |8 T
  5. copyright notices.& R6 `4 U) T" m

  6. 6 \* c- t) M7 B: v6 W8 Q
  7. Usage: busybox [function [arguments]...]) {. p$ f- s: b- F' A( u, r. B& ]
  8.    or: busybox --list[-full]/ \# X3 J. f! L1 Q& x
  9.    or: busybox --install [-s] [DIR]- Q5 r/ a2 z5 F0 }5 ^7 t
  10.    or: function [arguments]...% Q# x) V/ ^* z0 d- a; c6 H
  11. / x. h6 M1 S; F, o: X* M( ~1 M
  12.         BusyBox is a multi-call binary that combines many common Unix2 n! \( {3 |- z2 K# J9 O
  13.         utilities into a single executable.  Most people will create a* N6 G* d: W. j' K& t' f/ [( V$ F
  14.         link to busybox for each function they wish to use and BusyBox
    ! K  z" @# q  m* z
  15.         will act like whatever it was invoked as.+ o' }$ B& o, {/ ~

  16. 7 ~0 B4 U! M6 s% S6 B
  17. Currently defined functions:
    7 t* [8 Z# y7 F
  18.         [, [[, addgroup, adduser, ar, arp, arping, ash, awk, basename, blkid, brctl, bunzip2,. x) J( O. x3 B" Q$ j
  19.         bzcat, cat, catv, chattr, chgrp, chmod, chown, chroot, chrt, chvt, cksum, clear, cmp, cp,6 [) H% E- G' O3 c% M4 S& O3 n$ d
  20.         cpio, crond, crontab, cut, date, dc, dd, deallocvt, delgroup, deluser, depmod, devmem, df,
    - U. z! v6 z5 `3 i
  21.         diff, dirname, dmesg, dnsd, dnsdomainname, dos2unix, du, dumpkmap, echo, egrep, eject, env," m# ^5 o( d* G% K' q& x8 c3 y
  22.         ether-wake, expr, false, fbset, fdflush, fdformat, fdisk, fgrep, find, flock, fold, free,, z$ L$ G! P/ |7 q# D
  23.         freeramdisk, fsck, fstrim, fuser, getopt, getty, grep, gunzip, gzip, halt, hdparm, head,) }8 w4 c3 }, b
  24.         hexdump, hostid, hostname, hwclock, id, ifconfig, ifdown, ifup, inetd, init, insmod,
    6 w) l+ B. ?( [; x
  25.         install, ip, ipaddr, ipcrm, ipcs, iplink, iproute, iprule, iptunnel, kill, killall,
    . t( H' F4 F) B# d" R7 J
  26.         killall5, klogd, last, less, linux32, linux64, linuxrc, ln, loadfont, loadkmap, logger,
    # o4 s. [6 `7 G) W# R
  27.         login, logname, losetup, ls, lsattr, lsmod, lsof, lspci, lsusb, lzcat, lzma, makedevs,/ J: `( p0 ~& t0 O" H2 T' S
  28.         md5sum, mdev, mesg, microcom, mkdir, mke2fs, mkfifo, mkfs.ext2, mknod, mkswap, mktemp,
    4 W) S  g  `" E+ p
  29.         modinfo, modprobe, more, mount, mountpoint, mt, mv, nameif, nanddump, nandwrite, netstat,
    1 q! T4 l6 h) d6 X% \
  30.         nice, nohup, nslookup, od, openvt, passwd, patch, pidof, ping, pipe_progress, pivot_root,
    ' E' m- U/ W+ @/ L$ `
  31.         poweroff, printenv, printf, ps, pwd, rdate, readlink, readprofile, realpath, reboot,' m% L/ v  L/ j* ^5 k6 E
  32.         renice, reset, resize, rm, rmdir, rmmod, route, run-parts, runlevel, sed, seq, setarch,
    / x- b& x4 C+ I. \% p+ C( p
  33.         setconsole, setkeycodes, setlogcons, setserial, setsid, sh, sha1sum, sha256sum, sha3sum,
    - f6 L* E6 P# w+ E
  34.         sha512sum, sleep, sort, start-stop-daemon, strings, stty, su, sulogin, swapoff, swapon,
    * H2 k0 X9 M  r; L  N' V& D
  35.         switch_root, sync, sysctl, syslogd, tail, tar, tee, telnet, telnetd, test, tftp, time, top,
    1 J1 d, n9 M+ i  I
  36.         touch, tr, traceroute, traceroute6, true, tty, ubiattach, ubidetach, ubimkvol, ubirmvol,  h3 t' ]4 K" i# [- I! [
  37.         ubirsvol, ubiupdatevol, udhcpc, umount, uname, uniq, unix2dos, unlink, unlzma, unxz, unzip,
    7 @! e7 L# u& V1 E
  38.         uptime, usleep, uudecode, uuencode, vconfig, vi, vlock, watch, watchdog, wc, wget, which,
    , M% r1 t+ B5 F' V9 S9 G
  39.         who, whoami, xargs, xz, xzcat, yes, zcat4 M+ w2 w# x. U1 ~

  40. / ]9 U+ m5 u( U1 o9 O
复制代码
  1. root@F650A:~ # nano -h
    " i( }. }" C- T8 B7 m
  2. Usage: nano [OPTIONS] [[+LINE,COLUMN] FILE].../ c1 o" K' m  S# r- }9 H

  3. # Z* i: ~4 H/ t2 o( v. z7 f
  4. Option          GNU long option         Meaning
    ; Q4 m  g& `3 q) a
  5. +LINE,COLUMN                           Start at line LINE, column COLUMN
    + A* ]# `/ J3 e5 ]2 _, n
  6. -D             --boldtext              Use bold instead of reverse video text2 w& G  r: K1 R/ k
  7. -K             --rebindkeypad          Fix numeric keypad key confusion problem
    ; A9 X+ f( E( T8 ^
  8. -L             --nonewlines            Don't add newlines to the ends of files2 s# s  }$ R+ e
  9. -O             --morespace             Use one more line for editing
    # @2 k: p; M& m5 t
  10. -R             --restricted            Restricted mode: V# S6 p, E9 V- m! P5 A% m0 c, ]
  11. -T <#cols>     --tabsize=<#cols>       Set width of a tab to #cols columns
    % p+ A3 b! Y+ o1 [9 Q$ t; g( R2 [# z
  12. -V             --version               Print version information and exit- \9 r9 l* ~( j- G5 I. c* r
  13. -c             --const                 Constantly show cursor position" e0 d% H9 r0 k
  14. -d             --rebinddelete          Fix Backspace/Delete confusion problem- m* \- o1 M- Q9 u* ^( n8 S% m
  15. -h             --help                  Show this help text& x& P! @5 V7 J- U# s
  16. -l             --nofollow              Don't follow symbolic links, overwrite& h2 d3 K3 u0 x# p9 n( ?
  17. -n             --noread                Do not read the file (only write it)% d& n$ l7 \. C
  18. -p             --preserve              Preserve XON (^Q) and XOFF (^S) keys$ g) u1 U( I. ?9 U& g
  19. -t             --tempfile              Auto save on exit, don't prompt& ^" Y: Y0 |2 a5 t
  20. -v             --view                  View mode (read-only)" D, _! n  _! d$ M
  21. -x             --nohelp                Don't show the two help lines; j3 W( U. N0 X# B9 m
  22. -z             --suspend               Enable suspension0 m3 d9 n6 ^  {6 |* I) ^9 y2 B
  23. root@F650A:~ # nano -V
    ; E4 X# g( {- W. i! O
  24. GNU nano, version 2.4.2& q  Y- d/ a8 D3 |
  25. (C) 1999..2015 Free Software Foundation, Inc.
    * t" q: o5 B: M6 w" \
  26. Email: nano@nano-editor.org    Web: http://www.nano-editor.org/
    6 T; \6 \2 T/ y* S; ^
  27. Compiled options: --enable-tiny --disable-utf8
      E; g" |4 d. a7 Q0 x# Y1 v
复制代码
  1. root@F650A:~ # dropbear -h
    & E# g* E1 O) x* |" y
  2. Dropbear server v2015.67 https://matt.ucc.asn.au/dropbear/dropbear.html! d! g" i( n" C7 Q- r" u
  3. Usage: dropbear [options], }5 X4 a' H" i8 {  _, D
  4. -b bannerfile   Display the contents of bannerfile before user login
    ( W1 g6 s, C+ A8 T6 H" ~' d9 k- P
  5.                 (default: none)
    8 x! W, B2 _. M; I# S) ~2 ]$ ~3 v3 t
  6. -r keyfile  Specify hostkeys (repeatable)
    ( U& V5 i: K3 m& }8 Q
  7.                 defaults:9 n% y3 J4 y* e) `
  8.                 dss /etc/dropbear/dropbear_dss_host_key. n) |4 V6 A% P6 ^( `
  9.                 rsa /etc/dropbear/dropbear_rsa_host_key5 }* y+ J' c6 p
  10.                 ecdsa /etc/dropbear/dropbear_ecdsa_host_key
    / c3 `" L" W7 b/ f' o( y# {5 J* v
  11. -R              Create hostkeys as required( A+ W, h+ v& p' h# B7 L
  12. -F              Don't fork into background
    2 q) Y* ~* _, I7 e" S
  13. -E              Log to stderr rather than syslog
    * K2 y  ]+ R+ g# K& s& n
  14. -m              Don't display the motd on login; h  H$ A& {/ h. z
  15. -w              Disallow root logins
    6 |" s+ b9 U% E0 j- a8 T
  16. -s              Disable password logins: |4 O1 C* i( B
  17. -g              Disable password logins for root
    " x2 t' ?1 ]) b: v# }+ g
  18. -B              Allow blank password logins3 B0 O: d' }4 V3 e* O8 o
  19. -j              Disable local port forwarding( s8 g% f2 I8 Q4 B
  20. -k              Disable remote port forwarding8 U; `. Y0 \1 Q8 f4 t7 G- P
  21. -a              Allow connections to forwarded ports from any host0 `% Z2 o: m2 b
  22. -p [address:]port
    6 L* L. `" X# n/ D0 C3 F
  23.                 Listen on specified tcp port (and optionally address),
    # _2 E; m: r3 G; S- J- ?5 C$ ]% M
  24.                 up to 10 can be specified
    ! i1 T8 c0 L7 s5 w; A
  25.                 (default port is 22 if none specified)2 m7 C, n% T, |( Q" U% ]
  26. -P PidFile      Create pid file PidFile/ Z0 Q7 Q5 A- M3 k+ W% w! ?
  27.                 (default /var/run/dropbear.pid)
    ; H: K: q0 n1 t9 n
  28. -i              Start for inetd( H# F: P+ u4 b0 ]+ Q5 I
  29. -W <receive_window_buffer> (default 24576, larger may be faster, max 1MB); o0 B& w1 j( c; z+ @3 K, z- @
  30. -K <keepalive>  (0 is never, default 0, in seconds)9 e8 D3 k# N- D( E6 z  _
  31. -I <idle_timeout>  (0 is never, default 0, in seconds)
    + p8 s9 _" D: v! f/ j# o" B7 h' n
  32. -V    Version
    ( x3 a4 d: K6 V' \, I
复制代码
& ~  c: |. B) q6 j8 V: A. e

6 w2 \1 F$ y9 O0 Z+ X2 b

本帖子中包含更多资源

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

×
发表于 2021-11-27 21:38:54 | 显示全部楼层
本帖最后由 btworm 于 2021-11-27 21:41 编辑
  Q7 g: W- K3 Q0 z+ b
songee 发表于 2021-11-27 04:15
: b5 A$ p0 C9 q8 q4 V3 u6 V% `8 R8 O6 U1.只要lxc相关命令可以正常运行,写好配置文件,选择符合CPU架构的rootfs,就可以把容器跑起来。
$ W+ o, |! q9 n2 L; O2.我的 ...

# T) l; S) I, S& d7 s3 s: P+ B感谢指点!
8 I# X1 S' ~. T5 J: b, t) h# }/ [; V/ l7 k. y7 Q! Y+ q
关于第2点( j7 W* n( u% a' V% C+ x+ p: m3 \! ^
华为光猫 / 只读,/etc,/usr,/lib这些目录也都依附于/, 所以都不可写, /opt目录不存在,当然也无法创建。
0 a0 h0 _" h  p0 p  \
, E. x# `6 d% c之前担心/dev/pts, /proc, /sys只读,是因为以前玩路由器时,有个chroot脚本使用过这些目录,刚又看了遍那个脚本,使用的是 "-o bind"参数,所以主机目录是否可写就无所谓了。在华为猫上跑lxc应该没问题了! V. F& O: {6 b6 g
) h3 T+ T; v( M: M2 l9 \
另外想问问,光猫容器内的应用对端口的监听是:
3 n! e+ ~$ d; B8 D6 M1.直接监听光猫的端口?. W3 _3 @2 [" o4 f% x- r" R
2.还是只能监听容器内的端口,并需要光猫iptables做端口转发给容器?
 楼主| 发表于 2020-2-22 18:37:10 | 显示全部楼层
anysoft 发表于 2020-2-22 17:50
9 V( y5 [( A1 f' I3 gHS8145V HS8145V5  F650A 都是512MB+256MB 2.4G+5G方案
# Y+ z9 J7 e. a- b$ `  Y价格都还好,特别F650A 因为会玩的人少价格特别便 ...

* l2 M8 @) q. [) L1 l0 K+ shs8145v技术成熟,更适合玩,而且其实f650a是512/128,nand flash少了一半,CPU一个尿性,价格差别不大的话,能hs8145v还是别选650。
6 @% k- I, `8 \0 R( H+ c$ t% R+ n还有个大胆想法,lxc可以通过配置文件config修改子系统网络,从eth0桥接是不是就能在子系统多拨了,子系统专门离线和网络存储,不影响猫后面接的手机电脑上网,还是蛮有趣的7 \) E* V7 l  D* E2 V' \0 j
( \; W3 |7 P; [7 [$ S/ d( h; J

2 M6 X) h; Y$ _  Y. m
' x- J, F5 F; z
 楼主| 发表于 2020-2-17 02:19:26 | 显示全部楼层

二楼原帖,仅保留做参考

本帖最后由 songee 于 2022-4-27 21:17 编辑
) h8 z4 E: e* J: D  N
# g' l6 e4 |1 P8 V9 F+ K5 y$ `; r* Y
(2020年原帖初步摸索,过程过于繁杂,不建议再按这部分思路操作)# j0 u, A* P9 c1 b) C
中兴、华为等带有saf模块的光猫,以官方版openwrt替换厂商定制版的思路总结一下,供大家参考。
% t0 N5 A6 Z& u" S# U1 j' g1、准备工具: Z$ C0 S$ j' s' d
    F650A主系统没有 mtd 、 dd 和 vi 等工具,而自带的saf子系统正好都有,子系统位于framework分区即mtd6,挂载于/opt/upt/framework,cp过来可以直接使用。
root@F650A:~ # cp /opt/upt/framework/saf/rootfs/sbin/mtd /usr/bin/
8 d3 a! V# y& Eroot@F650A:~ # cp /opt/upt/framework/saf/rootfs/lib/libubox.so /lib/
1 U0 R9 i- a$ @% a4 ]root@F650A:~ # cp /opt/upt/framework/saf/rootfs/bin/busybox /usr/bin/' h$ z  O& F# p( I1 |) ^: v
root@F650A:~ # cd /usr/bin/
4 k5 _7 Y- t/ `6 t0 @% Iroot@F650A:/usr/bin # ln -s busybox dd2 S& _5 R! c$ f; F) u) t
root@F650A:/usr/bin # ln -s busybox vi

2 r# _" J' I) ?1 Z/ Z6 O2、改进lxd-openwrt生成代码。
/ H7 J+ H" r/ _/ t    本节参考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如下) J/ n# Y. c$ [) s: _
*** build.sh                2020-02-19 01:50:10.972675562 -0100. L- y3 P# B9 Z7 \5 @% ^
--- build.sh.origin        2020-02-14 19:10:45.000000000 -0100
8 [" J1 d, \3 h! h***************
5 g* F' V, T& J6 L$ V4 t/ w+ t*** 72,81 ****
) U! ?9 D' S6 A; m: p3 @1 R8 H& _                  subarch=645 j$ `7 n2 f3 s: M
                  arch_ipk=x86_64
. Y, N6 c5 k/ `: ^' k: J; W( k                  ;;
4 o& z7 f( N8 P; G! B!         arm)
3 \, f# J3 Q# q5 H0 ^!                 arch=bcm53xx( e& e9 W8 g( X. d' d) J1 {
!                 subarch=generic
0 X7 Q7 K) g. u6 d8 C2 y!                 arch_ipk=arm_cortex-a9
! T5 Q4 F- k" v% a                  ;;1 @" w$ U& v& x/ K4 T1 e0 o" T' R
          *)$ m1 H! T6 S) w8 E* V' d" r5 s! Y
                  usage/ S8 ]8 {& i$ X: H
--- 72,81 ----# U+ B% v. P4 q% [3 [- ~
                  subarch=64
% g# q* q/ O$ X, m+ P# G5 Y                  arch_ipk=x86_64
* W8 w; t- A+ E1 W- M* O7 ~                  ;;/ r+ m/ p8 T  G+ v
!         aarch64)5 [0 U7 A7 `# r
!                 arch=armvirt! D! @" B9 u9 C& }
!                 subarch=649 }  b+ ]7 w# S
!                 arch_ipk=aarch64_generic
/ V- \) J4 K' r. }8 M. `: Q! v! q                  ;;9 u- I8 U7 n( r/ B% r3 x
          *)
1 K! z: B# @; S                  usage2 h0 F2 c; m$ R  l2 S6 u; `
***************4 S- G, K, \8 d% z' m# Y( V
*** 87,97 ****
4 t' a- J0 U/ B) ^' I+ _  if test $ver = snapshot; then; J5 K$ a5 g" L1 v2 S$ n4 N  E- R1 p
          openwrt_branch=snapshot
9 x8 N: B$ ~$ A+ U- W          procd_url=https://github.com/openwrt/openwrt/trunk/package/system/procd1 b9 S+ v$ H% a' X1 ?( A
!         openwrt_url=https://mirrors.cloud.tencent.com/lede/snapshots/targets/${arch}/${subarch}4 X9 O6 n6 r; f
  else4 \; z% T( h, {% H) {9 k% ]
          openwrt_branch=${dist}-${branch_ver}
* y6 Y* E* i" E7 I          procd_url=https://github.com/openwrt/openwrt/branches/${openwrt_branch}/package/system/procd& i5 B2 A# c& m
!         openwrt_url=https://mirrors.cloud.tencent.com/lede/releases/${ver}/targets/${arch}/${subarch}! V; J. H! i2 {/ T3 V7 U* g4 S
  fi
9 B7 V' P) X7 o/ t/ s" w  & o, G& _" i; {7 F
  procd_extra_ver=lxd-3
1 U! h6 i+ O! g; `( l/ Q' y--- 87,97 ----3 H# }, n: X+ j+ ]. F3 ]3 `% O' h
  if test $ver = snapshot; then: k& l0 k: }4 c; O- Z+ D% d
          openwrt_branch=snapshot
# s# C: T2 a7 V5 x! E/ l# y1 }. \# w          procd_url=https://github.com/openwrt/openwrt/trunk/package/system/procd
6 ^1 A: |2 f& ~: {0 r' F!         openwrt_url=https://downloads.openwrt.org/snapshots/targets/${arch}/${subarch}
  F. @  @1 @5 L% s- T" y  else, _7 P5 C) n4 J
          openwrt_branch=${dist}-${branch_ver}6 a4 g1 m) B% }1 Z2 A, _# J7 ^
          procd_url=https://github.com/openwrt/openwrt/branches/${openwrt_branch}/package/system/procd7 V% _6 K9 S, \3 v1 N* B- r* k0 x
!         openwrt_url=https://downloads.openwrt.org/releases/${ver}/targets/${arch}/${subarch}7 O" z1 z8 E  @4 N( V* R
  fi
: A' w5 u# C1 L- `$ b( K4 k. {; a  
6 v+ a' [/ E( j& D# H7 \7 v  procd_extra_ver=lxd-3
9 X7 \( ^, {( l) p! w***************9 Q! `# A/ d+ Y7 R! J. b, A
*** 112,125 ****! p; i1 K, C& m6 V: ?1 a, K3 t
  }
6 x3 V8 c8 B4 }" _0 T) V. m  
( s' W$ P& B# m5 V% z1 `$ Q  download_rootfs() {
+ m  b* K, X2 H8 ^( F2 s! #        detect_url "rootfs\.tar"# n' ~2 j4 @* J) \5 h
! #        local rootfs_url=$openwrt_url/$return
& K" h6 m; n7 g/ ]- [  
, a. l: @/ @3 ^9 ~! J$ }( f( x% k          # global $rootfs
+ _. L* ]3 E8 Y- H2 Y!         rootfs=dl/openwrt-19.07.1-bcm53xx-generic-rootfs.tar.gz* _$ D2 ]; x; b. h& t
  " i" O5 c: l+ i3 S, N+ n& R* c
! #        download $rootfs_url $rootfs $rootfs
: n8 J' h" Z0 G; G3 T! #        check $rootfs $rootfs_url9 G3 ?7 P/ b" s7 `, u
  }
+ m4 J  t; j7 @8 e1 K  0 y% }6 }/ p+ u* ^# d& h* a
  download_sdk() {
' I) h5 E8 _) j; _6 x--- 112,125 ----0 l" u8 F% p" m. R2 D- F  `2 Y" ~
  }
1 U/ }# Y% A, j" b9 ]" v" e2 _  
* k' O) y  @& l4 |+ H  download_rootfs() {
& f5 a/ h$ N" j( C!         detect_url "rootfs\.tar"  K" G2 E5 `% [. |% K
!         local rootfs_url=$openwrt_url/$return& f, `9 e: m" D7 `7 L
  
0 O; l$ h9 c4 `' r5 _: {: u  J          # global $rootfs
9 p/ J+ b  M; X9 @9 _) F!         rootfs=dl/$(basename $rootfs_url)! o0 @. ~6 m1 j9 q* V: Y
  7 G6 }; L. {1 C7 T: |
!         download $rootfs_url $rootfs$ m( Z, p: _% z, N! P8 b! n2 T  Z
!         check $rootfs $rootfs_url
4 F4 j% G5 l5 b' }  d4 |4 j4 c6 `  }
0 h( }: f4 v4 T+ ^9 m! ~/ H  # U, X5 v6 D  M0 h. z8 [% X5 `
  download_sdk() {

8 b$ m. [# h7 t! d* z3、从腾讯镜像下载openwrt-19.07.1-bcm53xx-tplink-archer-c9-v1-squashfs.bin,从固件中提取rootfs并预处理。
4 R; B, S- H! D
  1. x@x-Surface-Pro-3:~/下载$ binwalk openwrt-19.07.1-bcm53xx-tplink-archer-c9-v1-squashfs.bin
    - m! r8 o/ M# y3 j- j7 c
  2. 9 c% `7 t) c' |/ n
  3. DECIMAL       HEXADECIMAL     DESCRIPTION5 f4 w' r  p, [5 g3 Q+ j( Z- s* J3 q
  4. --------------------------------------------------------------------------------8 F, k$ L  J& F- b
  5. 8317          0x207D          TRX firmware header, little endian, image size: 1810432 bytes, CRC32: 0xBCD36218, flags: 0x0, version: 1, header size: 28 bytes, loader offset: 0x1C, linux kernel offset: 0x0, rootfs offset: 0x0! Y1 o6 c0 w5 z: h
  6. 8345          0x2099          LZMA compressed data, properties: 0x5D, dictionary size: 65536 bytes, uncompressed size: 1801662 bytes1 O9 ^7 g" D4 {# K' b9 O* X
  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:354 r9 @5 f2 R# `; i) u1 Z5 X

  8. ' J5 u: I$ T6 b- M$ s. D( v6 I
  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
    0 Y& R" J& l* ?
  10. 记录了1900548+0 的读入% t& N! S2 }. y2 x
  11. 记录了1900548+0 的写出
    2 B" x* q3 l% G) }7 f! H1 A
  12. 1900548 bytes (1.9 MB, 1.8 MiB) copied, 5.16823 s, 368 kB/s
    3 t4 X. i# v8 d9 b2 h$ Y+ D* Z
  13. x@x-Surface-Pro-3:~/下载$ binwalk rootfs-squashfs.bin
    ( c$ B* z4 z, D; N! j! h

  14. ; W" O! e$ _7 a  @3 `' M" ~* R! D
  15. DECIMAL       HEXADECIMAL     DESCRIPTION  p9 J2 u' h% o; N) B) e/ }
  16. --------------------------------------------------------------------------------
    7 {. }4 I& E7 V9 |4 X; _, E
  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
    $ T& z( S& a7 m4 [
  18. 9 H6 B: f: [6 ^7 g* Q) m
  19. x@x-Surface-Pro-3:~/下载$ unsquashfs rootfs-squashfs.bin
    . t: m9 V  d% f/ o
  20. Parallel unsquashfs: Using 4 processors2 n( `4 k! c3 w& A6 L3 O' c& X
  21. 1071 inodes (1066 blocks) to write
    * h7 a4 @1 x6 n" n/ P
  22. - \1 w& m2 n: c9 P5 ?2 @1 `' d+ ?
  23. ( S4 C2 L- L' {1 }
  24. create_inode: could not create character device squashfs-root/dev/console, because you're not superuser!
    + r; Z4 i/ T4 i& e: g: d9 F& p
  25. [====================================================================================================| ] 1065/1066  99%
    * D+ Z4 ]1 @1 V" |3 p5 f
  26. 1 e8 w3 h8 f$ E. }8 S! V) Q
  27. created 875 files
    . D3 O, C; H8 ?. }
  28. created 103 directories( [5 }( N- q; Q3 V
  29. created 195 symlinks
    0 u  E7 M) _% ~# k
  30. created 0 devices+ |- K* W9 ~" v7 b; A, Y! [+ L2 K
  31. created 0 fifos
    7 w1 W0 ~! K9 _
  32. x@x-Surface-Pro-3:~/下载$ cd ./squashfs-root/% \: e( V. _! c! o; r- y2 V/ e( j
  33. x@x-Surface-Pro-3:~/下载/squashfs-root$ gedit etc/opkg/distfeeds.conf
复制代码
将opkg软件源改为腾讯镜像( H6 ^+ ^, E4 V1 \: ?1 K
src/gz openwrt_core https://mirrors.cloud.tencent.co ... xx/generic/packages( H% l/ t; l/ f+ W' g3 x
src/gz openwrt_kmods https://mirrors.cloud.tencent.co ... 92b7d7eca715b1ee0b8" `; ?& r9 X7 y  B- Q
src/gz openwrt_base https://mirrors.cloud.tencent.co ... /arm_cortex-a9/base
% T8 H0 Q9 D: F1 G0 L7 E& {src/gz openwrt_luci https://mirrors.cloud.tencent.co ... /arm_cortex-a9/luci
  X# n+ |! T6 w# A' K# hsrc/gz openwrt_packages https://mirrors.cloud.tencent.co ... _cortex-a9/packages
: M# a) A( W8 a5 S5 o2 Osrc/gz openwrt_routing https://mirrors.cloud.tencent.co ... m_cortex-a9/routing# `5 T5 P, j0 i! ~" m! y3 k# H; e5 z
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 ./, n  O( b4 ~9 o
  2. x@x-Surface-Pro-3:~/下载/squashfs-root$ cd ../. S5 S% b1 M" S! ?' U* F
  3. x@x-Surface-Pro-3:~/下载$ mkdir lxd-openwrt-master/dl
    . p& f/ d* u1 y2 e
  4. x@x-Surface-Pro-3:~/下载$ mv openwrt-19.07.1-bcm53xx-generic-rootfs.tar.gz lxd-openwrt-master/dl/
复制代码
执行修改过的build.sh; x- w9 k9 b1 ~9 ~: T
  1. x@x-Surface-Pro-3:~/下载$ cd lxd-openwrt-master/. j' F5 k$ c3 ]2 [* S8 c& Z6 s+ w& L
  2. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ ./build.sh -a arm -v 19.07.1
    2 I  b) _! j  `/ G
  3. ......: R6 Y1 ~. l! Q. k7 `% K
  4. Pack rootfs- y! D8 a3 _% O8 X' Y0 t! P, `
  5. Tarball built: bin/openwrt-19.07.1-bcm53xx-generic-lxd.tar.gz
    ; E4 b+ {8 f' P( L# k; Y) ]7 T( U
  6. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ mkdir ../openwrt-19.07.1-bcm53xx-generic-lxc
    8 w, d/ @' p) D3 w! H% H8 A
  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
    1 _& B% G' |9 P$ E/ _
  8. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ cd ../openwrt-19.07.1-bcm53xx-generic-lxc/
    : \% k- s: P# P8 F2 M
  9. x@x-Surface-Pro-3:~/下载/openwrt-19.07.1-bcm53xx-generic-lxc$ ls3 R0 a7 J$ y# k
  10. metadata.yaml  rootfs  templates# A+ `4 d' g+ }' r
  11. x@x-Surface-Pro-3:~/下载/openwrt-19.07.1-bcm53xx-generic-lxc$
复制代码

; h  U" a4 V% L+ Z4、这时我们已经创建好lxc下可运行的openwrt19.07.1的rootfs,接下来处理lxc及rootfs的配置文件。( M% B% D/ O8 e/ O: r7 f
进光猫复制自带子系统的两个文件,再通过U盘或ftp传到Ubuntu的openwrt-19.07.1-bcm53xx-generic-lxc目录下,
; ~; P1 c# s; n8 P9 A5 k
  1. root@F650A:~ # cp /opt/upt/framework/saf/config /mnt/USB_disc1/; ?$ O. L" ?; z* @8 b* D' E
  2. root@F650A:~ # cp /opt/upt/framework/pre-start.sh /mnt/USB_disc1/
复制代码
config为saf系统的配置文件,新系统下稍作修改,5 a. c" Z  d( g6 {+ T! ~0 n
lxc.arch = arm8 Q0 X6 D# |& W8 l
lxc.utsname = openwrt
& L+ j% @- s2 i% c- }lxc.rootfs.mount = /usr/var/lib/lxc/openwrt/rootfs: E8 F8 r- Y/ t3 b
lxc.rootfs.path = overlayfs:/opt/upt/framework1/rootfs:/opt/upt/apps/openwrt-rootfs 5 \8 j$ E6 r, b
# lxc.rootfs = /usr/var/lib/lxc/openwrt/rootfs 7 T' w3 p9 L& e1 \3 W% X4 F% l
lxc.haltsignal = SIGUSR1: A+ \; b" ]% V" F* p
lxc.tty = 10 v7 I6 P" }& F% ?- E& ?! z' l
lxc.pts = 1, c6 K0 V6 a1 a" ?2 \) p
lxc.hook.pre-start = /usr/var/lib/lxc/openwrt/pre-start.sh
0 G. ]2 B4 Z9 i) I1 K: Klxc.aa_profile = lxc-container-default-with-nesting4 J3 d  d- i0 T
lxc.network.type = none& ~5 G- O7 Z  u0 e- X' p. W8 Z5 ^
lxc.mount.entry = sysfs sys sysfs defaults 0 0
, K- d( D0 J  F. w2 V  L1 Slxc.mount.auto = cgroup-full:rw
( n/ y+ O& C/ Y/ Dlxc.mount.entry = proc proc proc defaults 0 07 \9 B* j  I; n2 m
lxc.mount.entry = /mnt mnt none rw,rbind 0 0
6 O# l" \( P/ {lxc.start.auto = 1

) m* ]- j3 D4 A6 q& V+ {3 |- Kpre-start.sh处理模拟终端,为避免重复挂载devpts,添加一行卸载代码,
3 f* g( Q* j6 U" g4 I* o
#!/bin/sh( P# S$ P4 [- s3 A# `
umount /dev/pts /dev/ptmx
' S" C% d+ F6 r. W7 Lmount -t devpts -o newinstance -o ptmxmode=0666,nosuid devpts /dev/pts
) d! u. f5 G7 f3 [$ M! g6 ^. kmount -o bind /dev/pts/ptmx /dev/ptmx
7 y# B/ j, H' 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镜像,
0 B! i  @" ]4 K1 q$ E
  1. x@x-Surface-Pro-3:~/下载$ mksquashfs openwrt-19.07.1-bcm53xx-generic-lxc openwrt-19.07.1-bcm53xx-lxc.bin2 O* e! j8 {7 C, K. N2 |- ]: P
  2. Parallel mksquashfs: Using 4 processors; G# \- t  `; o$ U  x
  3. Creating 4.0 filesystem on openwrt-19.07.1-bcm53xx-lxc.bin, block size 131072.
    % Z4 h5 ?2 R  ]0 E
  4. [=======================================================================================================/] 881/881 100%9 C, D# o1 {: N9 b
  5. 9 ~( \' d) D/ B* k5 W& b6 `+ t
  6. Exportable Squashfs 4.0 filesystem, gzip compressed, data block size 131072
    2 b7 |5 o$ e: Z6 J8 R$ }% [
  7.         compressed data, compressed metadata, compressed fragments,8 U% t) a- \. C- K% K' ^
  8.         compressed xattrs, compressed ids& z4 r5 Q8 h0 c7 i4 W2 B
  9.         duplicates are removed& a& q3 c& p  \  f5 r
  10. Filesystem size 3163.90 Kbytes (3.09 Mbytes)
    3 p. h+ Z9 B' q. M/ E! u1 V
  11.         48.94% of uncompressed filesystem size (6464.54 Kbytes)
    0 z* o/ _; `+ U' V, h# l
  12. Inode table size 9693 bytes (9.47 Kbytes)0 `5 d9 ]) U8 u) j4 b
  13.         25.72% of uncompressed inode table size (37693 bytes)$ u( Y# R7 a/ b4 f) ~* X
  14. Directory table size 11372 bytes (11.11 Kbytes)2 u" f" R& f9 @4 l' ^$ }! l
  15.         47.17% of uncompressed directory table size (24108 bytes)
    & S/ N+ z" w+ _/ x' n
  16. Number of duplicate files found 136
    & L- k/ ~4 F/ h& r( B9 L* Z
  17. Number of inodes 1145
    7 f6 _" |! {, C3 F% H/ W2 t3 E# }
  18. Number of files 873& n  H( Y2 s8 K+ D% Q
  19. Number of fragments 39* j% }/ i5 l4 {3 ]5 a/ a% r
  20. Number of symbolic links  171
    : w% i( R0 q* p0 C2 ~! u. A& e
  21. Number of device nodes 0
    9 L2 t: l0 ~' V; F
  22. Number of fifo nodes 0
    0 H3 ?% R2 ~# I6 k) h8 h
  23. Number of socket nodes 0; a% g9 |9 ^9 P# M7 X2 C7 `
  24. Number of directories 101- |) p, b3 E! E' [
  25. Number of ids (unique uids + gids) 18 z8 e4 Y0 Y) e6 @$ S$ o
  26. Number of uids 1/ `5 [  ^, d9 ^7 n0 m
  27.         x (1000)$ H5 F3 c9 q( O# ]
  28. Number of gids 1
    ) G) e! M3 e- T$ w, Z+ B
  29.         x (1000)0 n/ u2 S! o$ U! s: e
  30. x@x-Surface-Pro-3:~/下载$
复制代码
; R' S- w0 E% e% B* M

* W' L, D1 q. {8 G1 P( l5、生成的openwrt-19.07.1-bcm53xx-lxc.bin传入光猫,'mtd' 写入mtd7分区。: X: S5 U0 Z& O2 }1 p- c" i7 U9 @
刷之前先关掉saf,因saf有lxc-monitord进程守护,kill掉之后会自动运行,只好修改saf程序名,重启光猫。7 G! x9 q2 I3 M
  1. root@F650A:~ # mv /usr/sbin/saf /usr/sbin/saf.bak
    1 h- E9 B7 D  b1 G5 J9 s
  2. root@F650A:~ # reboot
复制代码
重启后telnet登录,'ps' 确认进程列表没有saf,备份然后写入并挂载。
root@F650A:~ # ps
! d1 p# k7 f" H$ I  PID USER     VSZ   RSS  STAT  CPU COMMAND7 C- S/ X: o6 {) O
    1 root     23160   600  S     <1>  init8 ~9 F% o5 \' R" D1 m
    ......
) V) X1 I/ I5 _1 X5 _) i* l2 u, @/ oroot@F650A:~ # dd if=/dev/mtd7 of=/mnt/USB_disc1/mtd7.bin bs=1M
$ |7 d: s5 F% Q8+0 records in) q8 ?: Y) D: q
8+0 records out
! X2 M2 O. g, ?5 E5 [root@F650A:~ # mtd write /mnt/USB_disc1/openwrt-19.07.1-bcm53xx-lxc.bin /dev/mtd75 c4 \# [: ~: Z0 }) ~& f. L! Y4 G- ?
Unlocking /dev/mtd7 ...
0 }4 d/ c! m: C  `+ [* l+ Q
* p# _* d8 C7 \7 i' B# \6 K' g6 DWriting from /mnt/USB_disc1/openwrt-19.07.1-bcm53xx-lxc.bin to /dev/mtd7 ...6 q* t) @7 }- z6 j# H$ t# g
root@F650A:~ # mount /dev/mtdblock7 /opt/upt/framework1
! o" w1 c, P! i: F
6、开启OpenWRT新世界4 Q, _0 C' Y, k" R: Q  }
    写入mtd7分区并挂载之后,开始首次启动的准备工作。F650A的lxc默认路径在/usr/var/lib/lxc(一楼有说明),按config文件创建相应文件及文件夹,
3 U2 e8 t7 q" B% x* Z; x& w" u/ V) p# n; t0 p& E8 H
  1. root@F650A:~ # mkdir -p /usr/var/lib/lxc/openwrt2 o& n: l4 [' b& v$ `1 B! `( F3 j* `4 A
  2. root@F650A:~ # cd /usr/var/lib/lxc/openwrt
    / @) J: Q( q7 f" [) H. W0 N) g+ O3 y) y% k
  3. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/pre-start.sh pre-start.sh4 r  H+ \2 V. E' T3 [( k
  4. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/config config4 R) S% U4 @1 L4 |& q3 @
  5. root@F650A:/usr/var/lib/lxc/openwrt # mkdir rootfs
    2 Y' r# P$ z+ l+ l. v
  6. root@F650A:/usr/var/lib/lxc/openwrt # mkdir /opt/upt/apps/openwrt-rootfs( u# }- ~! Y8 A" z2 t) X
  7. root@F650A:/usr/var/lib/lxc/openwrt # lxc-start -dn openwrt
    0 S, W  F; R: F4 z
  8. root@F650A:/usr/var/lib/lxc/openwrt # ps
复制代码
此时的进程列表应该可以看到/usr/sbin/uhttpd、dropbear等,或者可以尝试打开浏览器 http://光猫ip/或ssh登录,如果看到Authorization Required提示登录或ssh提示登录用户名密码,表明lxc已成功运行,但此时无密码状态无法网页和ssh登录,只能通过控制台方式添加密码后才能实现。关闭openwrt容器,'ps' 确认,前台启动。3 q. g! L) n" |( Y6 y+ T
  1. root@F650A:/usr/var/lib/lxc/openwrt # lxc-stop -kn openwrt
    0 h% D, j" Z6 v2 x4 J$ n& `
  2. root@F650A:/usr/var/lib/lxc/openwrt # ps. w) u9 r) m! A" S6 k; w" {
  3. root@F650A:/usr/var/lib/lxc/openwrt # lxc-start -n openwrt! L* ]9 n; w3 h% ?9 e: a5 Y
  4. <6>init: Console is alive
    ( p" w6 }( {9 A1 Q. A+ \/ u- t
  5. <6>kmodloader: loading kernel modules from /etc/modules-boot.d/*
    & s, l) `" X- t. y9 w8 h! P0 }3 w
  6. <6>kmodloader: done loading kernel modules from /etc/modules-boot.d/*; p$ d6 A( a6 k3 G  z6 P
  7. <6>init: - preinit -
    $ t- o  V5 z* [' _$ c! C
  8. WARNING: Variable 'network' does not exist or is not an array/object
    7 o% j7 h" A3 ~3 }) S  t) J
  9. WARNING: Variable 'lan' does not exist or is not an array/object
    ; l% f# }4 ]2 ], b& @
  10. Press the [f] key and hit [enter] to enter failsafe mode, |% x# N5 G/ ~
  11. Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
    ) R3 C: Y* D* m! }/ u- `8 M
  12. <5>mount_root: mounting /dev/root5 f( k/ _" _8 Z0 d) T( z  x( z! P
  13. urandom-seed: Seeding with /etc/urandom.seed! U& \4 r. D- }" D8 ~% X/ H3 j
  14. <6>procd: - early -! K9 e6 b/ x- c  P. {; f8 E
  15. <6>procd: - ubus -
    % M6 b3 c" p. d( W- C" k4 e
  16. <6>procd: - init -# B7 w, n1 Y4 h" @
  17. Please press Enter to activate this console.
    2 L+ }7 Y  X4 O; k6 E
  18. <6>urngd: v1.0.2 started.
复制代码
此时回车便可看到openwrt的登入界面,添加密码。8 c! }' k. `; S' b: m; g) U8 m

  1. ! D- N% U  O3 r; e$ V7 Z
  2. BusyBox v1.30.1 () built-in shell (ash)# w% V0 g- }, {$ A& H/ P# g; _

  3. - s0 t  l& C! G; `2 j, u
  4.   _______                     ________        __0 }* p9 @+ X& M- g* g9 r3 y4 i
  5. |       |.-----.-----.-----.|  |  |  |.----.|  |_8 H! {: E4 f, e" s7 v+ E' B7 D1 P2 F+ {
  6. |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
    9 [; A" C# }  o& h' W
  7. |_______||   __|_____|__|__||________||__|  |____|
    $ i# M' b" W& Y0 d9 J8 Z4 s
  8.           |__| W I R E L E S S   F R E E D O M' ^2 z7 h5 q' |! s: [6 C' r7 w
  9. -----------------------------------------------------
    ' L8 }$ ^3 z5 {1 k* b5 z8 X1 o6 _
  10. OpenWrt 19.07.1, r10911-c155900f667 G- x0 g, h7 F& T+ h3 `
  11. -----------------------------------------------------1 ?% _' O' o' g+ P1 P
  12. root@openwrt:/# passwd root$ ?5 z& Y( N8 V. ?# Q: q
  13. Changing password for root6 \. P( O+ k! Q5 A) H+ i; j
  14. New password: + W" E3 \0 U. v: }# I1 R
  15. Bad password: too weak
    # @6 i5 X4 h0 z7 c) e
  16. Retype password:
    9 p" x  z$ Z. o, a# F8 v
  17. passwd: password for root changed by root; |) b; V6 \( S5 R
  18. root@openwrt:/# exit
    0 y5 n; p. z7 t
  19. Please press Enter to activate this console.
复制代码
控制台方式进入openwrt之后,exit无效,没找到正常的退出方式,只能关闭窗口,此后就可以通过网页和ssh正常登录。
. w( C, Q# X, P  n- U/ L6 D% m% G8 A2 \6 q
7、自启动及进程守护' h  c+ e6 F# e, r. P+ \3 R
    telnet登录光猫主系统,确认saf程序已备份,2 Q" i; f- i/ e. Y  B" k( W- @

3 P/ T- J  Q: d0 O' @9 O
  1. root@F650A:~ # ls /usr/sbin/
    " I* G/ @  \  y" }/ `' l: r
  2. chroot       lsap         saf.bak      telnetd. {0 a, U# v) |4 F+ y
  3. root@F650A:~ # vi /usr/sbin/saf
复制代码
填入 (2021年5月更新:去除USB端口挂载判定,避免无挂载时LXC不能启动)
( Y2 r/ L. e4 i0 o
#!/bin/sh
: v' k' f& q. z! N; g) |( R# add user-defined startup scripts here$ L8 a$ c* w1 O& m: l7 E# j: K) ~
3 O5 E: I- ]4 `+ O& Q1 g
  df | grep mtdblock7
0 q  \3 B# ]2 W  y  if [ $? -ne 0 ]$ ?4 l$ U) Q' t- F5 ^. o
    then
+ J' e! x+ t1 v" Z      /bin/mount -n -t squashfs -o ro /dev/mtdblock7 /opt/upt/framework12 e' t- n' x4 V3 y* Q& C/ C
  fi& r0 e3 K" l* E% I) l
##
3 w! J: x4 y9 `& M  j
+ |- W1 j/ ?0 ^  |: [#  ps | grep ntfsmount | grep -v grep; P& T( i; w9 @8 }8 n( D
#  if [ $? -eq 0 ]4 v; J" C3 ?; {% w
#    then
3 g/ P& J1 {( l/ B( E/ g& H      /dbus/usr/bin/lxc-start -dn openwrt/ ^0 i" |' @" B2 h' k5 k1 s; N( x: n+ o
#  fi$ i8 _, \, L: w) b& [2 v- J
##

6 ]; H! o8 T$ ]; }$ d或者在电脑编辑好内容,命名为saf,传入/usr/sbin/,'chmod +x' 添加执行权限,重启光猫。
5 U* k7 c/ Y8 ~
/ n8 c2 C" P6 k8、后续问题: a3 H8 v& m! E3 j( @
    目前的openwrt安装或更新程序会报错,缺少 libustream-openssl 、ca-bundle 、ca-certificates 和 libopenssl1.1,还需要修改dns,添加中文等, X7 {8 n/ }  M6 @3 [/ G7 S. }

( {/ ?; M: x7 C( N
  1. root@openwrt:~# opkg update
    8 g' J3 T. U* {: d+ l& a: U8 n
  2. Downloading https://mirrors.cloud.tencent.com/lede/releases/19.07.1/targets/bcm53xx/generic/packages/Packages.gz* ^# b/ y5 l0 x8 c: `
  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.
    & g0 z2 S* b+ T, E2 q! }1 Y
  4. *** Failed to download the package list from https://mirrors.cloud.tencent.com/lede/releases/19.07.1/targets/bcm53xx/generic/packages/Packages.gz
复制代码
这些安装包可以从腾讯的镜像站下载然后手动安装。
  K. F$ a, r+ a: U& p* ^- P. M) z
  1. root@openwrt:~# cd /mnt/USB_disc1/
    3 q' L; w4 x5 Y) \; y
  2. root@openwrt:/mnt/USB_disc1# opkg install *.ipk
复制代码
修改dns
) g! B, B- t! A
  1. root@openwrt:/mnt/USB_disc1# rm /etc/resolv.conf9 I" {. x1 n# L! ~' f$ q
  2. root@openwrt:/mnt/USB_disc1# vi /etc/resolv.conf
复制代码
填入,保存8 h0 C; D9 O$ k! s- a
nameserver      223.5.5.5
0 N- i1 P9 W$ J+ L5 Z# S( Gnameserver      8.8.8.8& d. j; j6 }4 {( h. s
nameserver      2001:da8::666

5 Y6 H1 E( C: z/ C嫌过程繁琐的可以直接下载我配置好的镜像,从第5部分最后开始操作,将下载的openwrt-19.07.1-bcm53xx-lxc.bin和saf-lxc-start-openwrt放入光猫上的u盘,子系统默认root密码123456。, G8 @! r& N; V3 b+ I) S
  1. root@F650A:~ # dd if=/dev/mtd7 of=/mnt/USB_disc1/mtd7.bin bs=1M* Y5 S* I& E5 \0 \
  2. root@F650A:~ # mtd write /mnt/USB_disc1/openwrt-19.07.1-bcm53xx-lxc.bin /dev/mtd7# M2 T: j0 C( K% W
  3. root@F650A:~ # mount /dev/mtdblock7 /opt/upt/framework1
    - p: n1 e2 \% N& b7 x( z9 T
  4. root@F650A:~ # mkdir -p /usr/var/lib/lxc/openwrt. |8 g# w; m8 f( y% a9 p3 e! k
  5. root@F650A:~ # cd /usr/var/lib/lxc/openwrt* m3 l$ |' N, c- p6 R( ~  J4 j# t
  6. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/pre-start.sh pre-start.sh
    * G( n2 J2 |. D( p% _% O
  7. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/config config
    / e9 U6 ^9 A1 u& [3 x
  8. root@F650A:/usr/var/lib/lxc/openwrt # mkdir rootfs
    4 f# m" r8 f4 k$ ^7 ~8 D+ q; j- H
  9. root@F650A:/usr/var/lib/lxc/openwrt # mkdir /opt/upt/apps/openwrt-rootfs
    " x# f+ U/ c8 p& B
  10. root@F650A:/usr/var/lib/lxc/openwrt # lxc-start -dn openwrt: l" }, d6 l- ?" I$ z
  11. root@F650A:/usr/var/lib/lxc/openwrt # cd ~
    + Q0 [" x) |' r5 C/ t
  12. root@F650A:~ # mv /usr/sbin/saf /usr/sbin/saf.bak, @! N1 C$ U, k6 u6 y2 w
  13. root@F650A:~ # cp /mnt/USB_disc1/saf-lxc-start-openwrt /usr/sbin/saf
    5 `3 L8 o0 G8 D& y2 i
  14. root@F650A:~ # chmod 0755 /usr/sbin/saf
复制代码
   虽然子系统的openwrt可以顺利运行,但经过我的测试,kmod类app大多无法正常工作。比如F650A内核不支持ext4文件系统,在子系统安装kmod-fs-ext4,尽管可以安装成功,但重启后提示 modprobe 启用ext4模块失败。
! u+ ~8 s  Y1 r) d$ P        子系统的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管理页面,需要更改光猫主系统,此操作的定制空间更大,有机会的话在后面回复中整理出自定义光猫固件的思路。
' S) y6 ~/ e  Y6 R9 v: A) m4 b, Z0 n) R' k+ \3 S$ k+ T: F* n0 x

本帖子中包含更多资源

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

×
发表于 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刷进去的?
) l  o" W; A1 W9 }: R0 k中兴非15.0.1出问题是你没清理/opt/upt/apps//apps目录
; ]8 ^  w' d! p2 P+ c$ {3 R/ j' V* e几乎所有光猫为了节省空间?都会有部分lib和var目录重用主系统的文件,openwrt下e8clib和e8cvar可以看看。# h2 ]( D0 ~2 E/ t; `7 K
另外中兴编译的openwrt开始了uclibc的xlocale配置,这也是achaoge直接用omap源的APP无法运行的原因,我自己有手动开启xlocale后编译omap的openwrt放进去运行OK。
; J* o8 m0 T0 `- g有兴趣可以一起研究玩。
 楼主| 发表于 2020-2-20 21:40:34 | 显示全部楼层
anysoft 发表于 2020-2-20 12:589 h, t0 _7 t' O
坐等lxc的教程,另外19openwrt是你自己编译的还是直接下载armv7的官方bin刷进去的?
" l1 P! d: w1 I3 t* ~5 ]$ Q! S. B/ ~; o中兴非15.0.1出问题是 ...
7 p/ q, k+ M( _3 Z0 c
# i+ E9 h8 \7 L: L/ a+ l1 ?2 m' V
openwrt1907用的官方rootfs经https://github.com/mikma/lxd-openwrt修改而来;xlocale的问题我在编译主系统的busybox时也发现了,官方用的应该是buildroot2015.08.1,如果有dtb和驱动甚至可以自己写个固件了。
发表于 2020-2-21 14:42:33 | 显示全部楼层
songee 发表于 2020-2-20 21:40
9 n7 E8 `# ^3 q* T4 h& b# X7 `openwrt1907用的官方rootfs经https://github.com/mikma/lxd-openwrt修改而来;xlocale的问题我在编译主 ...
  I5 ~# d9 N- z# b! C- i1 R
是的, 中兴使用的是buildroot-2015.8.1,这个strings 一下sendcmd 就可以看到
) f* |( U$ i4 m9 c* r, [5 |# a
8 L& p5 S( b- Y( l4 |看了下操作步骤,其实如果内存足够,没必要关闭saf启动的天翼网关。5 E/ P! g3 X: X! t5 ?7 z# Y% X6 J
可以让lxc容器启动两个op应该是可以的,F650A和华为hs8145V应该都是512MB内存,内存足够,openwrt可以放到apps分区文件夹下,不一定要写入mtd7再手动挂载。
- H+ J4 {7 z8 M2 [1 x" F8 ?1 b8 M4 r5 V/ V& t
我的HS8145V启动后内存只占用了30%,足够了。
* N/ r5 B0 i$ N: i3 z6 D6 J" R' a  K: t7 A
另外主系统下的usr/sbin目录下文件不是内存加载的rootfs对应的squash文件?这个更改应该不会回写到文件系统,重启应该就会消失?/ t$ J7 _7 D( z. |; @( B
不晓得中兴和华为是不是一样的。可能中兴可以修改文件吧,华为的只能dd备份rootfs分区后自己解包修改打包后再dd写进去,会有砖的风险,砖了只能上编程器。# ?& P0 U! K) N) E/ P2 V

; r8 v( U" }7 ^; V0 @( h' k$ b' ^至于端口问题可以在打包openwrt的时候先修改每个服务对应监听端口就不会冲突了。  M7 L; f7 u) a! V" A

本帖子中包含更多资源

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

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

本版积分规则

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

GMT+8, 2025-6-15 10:46 , Processed in 0.047076 second(s), 7 queries , Redis On.

Powered by Discuz! X3.5 Licensed

Copyright © 2001-2020, Tencent Cloud.

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