找回密码
 注册

QQ登录

只需一步,快速开始

查看: 83062|回复: 98

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

  [复制链接]
发表于 2020-2-17 02:14:04 | 显示全部楼层 |阅读模式
本帖最后由 songee 于 2022-4-27 21:04 编辑 5 P: E4 }, W& k$ M7 a6 N

5 J6 C/ k7 e. t, R- c$ y家里装宽带,电信200M,送了个中兴F650A。自带的天翼3.0web界面看着不错可惜几乎没有可玩性,闲来无事研究一番。1 j* c$ a* j/ Q. Z/ u) j
    借鉴论坛前辈achaoge的帖子:中兴 F450A/F650A 免 TTL 持久开 ssh顺利开启telnet,发现该光猫的运作机制是 主系统负责底层的硬件驱动、sendcmd管理系统(telnet、超密、ppp拨号、网络及WiFi、ftp等)、以httpd为基础的8080端口电信web管理界面,最后启动saf(lxc容器管理)程序。
$ y0 l. ]! c/ G: H1 M+ Q    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数据存放区,操作时需要特别注意!!/ B+ a5 G4 l5 R+ r
  1. root@F650A:/usr/sbin # saf6 y$ [7 {3 |& E6 Q8 Y8 W$ c5 j& g1 p
  2. Usage: saf service FWK_MTD_ID1 FWK_MTD_ID2 APPS_MTD_ID (eg. saf service 9 10 7)
    5 m2 d* w& i$ o) T0 u
  3. saf console+ j" O( O- m1 H, S  ^3 X
  4. saf info% k1 ~4 p2 H2 D/ f2 Z
  5. saf version
    ' \- i9 c, ?  y" p& B
  6. saf getfwkver3 l2 }. G2 s, E$ ^
  7. saf getbakfwkver% I( k: [  q- i, f2 G
  8. saf getactive% e5 ]* k8 m+ w9 \
  9. saf setactive FWK_MTD_ID [AFTER_REBOOT] (eg. ./saf setactive 17 1)
复制代码
  1. root@F650A:~ # cat /proc/mtd
    3 E/ x6 z. a7 m- a- o
  2. dev:    size   erasesize  name& e$ Y2 |8 N/ v- ~* U6 R1 Y( J. `
  3. mtd0: 08000000 00020000 "whole flash"2 X# R7 F; D. }2 x5 K
  4. mtd1: 00100000 00020000 "u-boot", E/ a) C" d: v5 o4 P7 x: _
  5. mtd2: 00080000 00020000 "others"
    % W5 B! S. `: ^2 }3 u7 d5 [- ]
  6. mtd3: 00100000 00020000 "parameter tags"
    2 s: {8 W) a8 Y: U# p+ X
  7. mtd4: 00100000 00020000 "wlan". }: ?8 ?  c) F
  8. mtd5: 00200000 00020000 "usercfg"
    9 M6 g+ }  a9 y! y8 ]8 s7 J
  9. mtd6: 00800000 00020000 "framework"
    2 \" |9 w# G) Q/ C# C% Z0 B# Y& t% A
  10. mtd7: 00800000 00020000 "framework1"
    & X8 G" {) @) K, E3 ?5 U; R% e" S5 b
  11. mtd8: 00780000 00020000 "dbus"* Y' u2 m% v" r
  12. mtd9: 01280000 00020000 "kernel1"
    " X; V& L  t; q
  13. mtd10: 01280000 00020000 "kernel2"# x6 l6 b$ }& K  J9 k5 P9 L
  14. mtd11: 03e00000 00020000 "plugin_data"
    5 y. T; a, a: ~) G2 D5 `# P
  15. mtd12: 01240000 00020000 "rootfs"
复制代码
6 l1 U/ d, W6 t2 u
    saf程序管理子系统,是通过系统的lxc容器实现的,在/dbus/usr/bin/目录下有lxc相关程序,但并非标准的官方版,而是定制的,lxc.lxcpath即lxc容器存放位置设定为/usr/var/lib/lxc,暂时没有发现更改的方法(也没什么必要)。
root@F650A:~ # ls -l /dbus/usr/bin+ B& K4 }2 \* R# l0 j3 _9 U' h
total 377% J/ v, K, w5 q2 Z/ q, `% k+ i2 S
-rwxr-xr-x    1 root     root         10143 Nov 15  2018 dbus-cleanup-sockets
9 _# t5 i2 v" O( a+ w! e-rwxr-xr-x    1 root     root         18867 Nov 15  2018 dbus-launch# |6 R: y; w" _# a
-rwxr-xr-x    1 root     root         22537 Nov 15  2018 dbus-monitor+ T' c/ R6 y8 |- n0 y: w" x/ d
-rwxr-xr-x    1 root     root         11049 Nov 15  2018 dbus-run-session
9 ?  M& V* Q* m) u5 U1 n-rwxr-xr-x    1 root     root         23431 Nov 15  2018 dbus-send
0 W, b' M7 A& Q. l3 Z3 }2 P  \/ [-rwxr-xr-x    1 root     root         19495 Nov 15  2018 dbus-test-tool* j; s+ x# J- p" }+ D# B3 L7 U/ x
-rwxr-xr-x    1 root     root         12257 Nov 15  2018 dbus-update-activation-environment+ ]$ H' J. V+ F5 m# z. u
-rwxr-xr-x    1 root     root          8365 Nov 15  2018 dbus-uuidgen
& ?1 c1 I' @0 I* V-rwxr-xr-x    1 root     root         33112 Nov 15  2018 gdbus
/ o0 S" \( y1 D2 P3 e-rwxrwxrwx    1 root     root         12332 Nov 15  2018 lxc-attach) f( b6 `% Q/ b8 g. c1 l& q8 K
-rwxrwxrwx    1 root     root         14241 Nov 15  2018 lxc-autostart
! r; u4 Y; }9 ~, G  C-rwxrwxrwx    1 root     root          9122 Nov 15  2018 lxc-cgroup, d+ `% @; h& D) c$ P* H6 m
-rwxrwxrwx    1 root     root          4414 Nov 15  2018 lxc-checkconfig8 d5 ^8 V6 l7 K7 s
-rwxrwxrwx    1 root     root         10175 Nov 15  2018 lxc-clone
1 B6 w6 R* ]# O5 Y-rwxrwxrwx    1 root     root          6181 Nov 15  2018 lxc-config; h! ~  J$ J1 S
-rwxrwxrwx    1 root     root          8590 Nov 15  2018 lxc-console: _& s1 g( G+ }2 o  o
-rwxrwxrwx    1 root     root         14556 Nov 15  2018 lxc-create: E7 O+ `9 _* G. C! N( Q# D
-rwxrwxrwx    1 root     root          8540 Nov 15  2018 lxc-destroy9 e! w4 u, b* A6 a3 X2 W1 G! V
-rwxrwxrwx    1 root     root         10027 Nov 15  2018 lxc-execute2 p' I4 y: m2 o  L
-rwxrwxrwx    1 root     root          8630 Nov 15  2018 lxc-freeze7 X$ R' }/ }# Q7 S- o& m- m
-rwxrwxrwx    1 root     root         18956 Nov 15  2018 lxc-info
) n1 @( g3 [# m( C-rwxrwxrwx    1 root     root          2834 Nov 15  2018 lxc-ls
* L; S' e/ S2 |( t. N/ l: Z& d-rwxrwxrwx    1 root     root         11122 Nov 15  2018 lxc-monitor" g! M# Q' A* s, l) l
-rwxrwxrwx    1 root     root         12270 Nov 15  2018 lxc-snapshot, `, x- M. X1 ?1 d" G1 h
-rwxrwxrwx    1 root     root         15356 Nov 15  2018 lxc-start, q* d$ H& o. M. m6 B" P
-rwxrwxrwx    1 root     root         10055 Nov 15  2018 lxc-stop: l8 V6 f# p5 \) N
-rwxrwxrwx    1 root     root          8634 Nov 15  2018 lxc-unfreeze
& k; W1 V% ?7 R# p-rwxrwxrwx    1 root     root         12380 Nov 15  2018 lxc-unshare1 @/ [" e" m3 |1 v% Q; t
-rwxrwxrwx    1 root     root         13324 Nov 15  2018 lxc-usernsexec
1 Q- ~3 P3 Z. `, h$ k5 p' }. m-rwxrwxrwx    1 root     root          8561 Nov 15  2018 lxc-wait
  1. root@F650A:~ # lxc-config -l: i* H, k6 N6 D- x4 N* T8 H
  2. lxc.default_config
    , q* V+ s2 g$ X  i6 l# @: a
  3. lxc.lxcpath1 x  C5 P3 L2 s" Z7 q
  4. lxc.bdev.lvm.vg: x& j" S5 [. Z6 u  N3 p
  5. lxc.bdev.lvm.thin_pool( V# M7 m6 {. d2 d2 J2 k; \+ i6 _
  6. lxc.bdev.zfs.root
    3 t# ^! T. v7 K' L, p, H
复制代码
  1. root@F650A:~ # lxc-config lxc.default_config
    % D) u# L3 c( Y! b
  2. /usr/etc/lxc/default.conf
    . Z, m9 h( {: `& |% W: j* q9 y: a
复制代码
  1. root@F650A:~ # lxc-config lxc.lxcpath
    ) L$ C' s+ N7 O
  2. /usr/var/lib/lxc
复制代码

6 l3 e/ Z# d5 \$ u- T- I+ B    了解系统运作机制之后,我最初打算借用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方式开启新世界,操作步骤在本文回复中细谈。
, m9 Z+ {* S* @. n6 m7 U    经过几番折腾,已将系统原有的openwrt中兴定制版saf子系统完全替换为官方openwrt19.07.1(lxc方式启动),不影响光猫拨号且可在线安装及更新非kmod类app,如ariang离线下载,samba文件共享,甚至各类科学上网工具(性能及安全原因不推荐)。. a! ~- P" J9 s- M$ W

1 @: S( h, |, x, @  E# \: N% \/ e& B1 u0 C+ T

0 X0 j" G6 C1 M
* `  V& S% t2 i* O2 x/ o1 t  N
8 g$ h0 J9 p' N1 ]' k: ?
7 A/ q8 a8 _, Z' E0 y9 }2 ?6 y" d  L+ S: @3 q

本帖子中包含更多资源

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

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

简化并更新OpenWRT22.03.0 RC1版本

本帖最后由 songee 于 2022-4-26 23:39 编辑 5 D: x* c* Z$ @4 t0 b. B* |
8 W, R# y, u) h2 C' j% e
因二楼原帖过程过于繁琐,近期尝试了一种较为简单的办法。/ N) q9 ^9 N& n( `0 J: L0 |4 _

; U0 u3 u' y% D3 a* d  Q
5 h* V+ ^0 x: w3 D; q( u1、下载openwrt.org固件,我选的是openwrt-22.03.0-rc1-bcm53xx-generic-tenda_ac9-squashfs.trx,binwalk分析squashfs偏移量并用dd取出,unsquashfs提取rootfs,打包为rootfs2203rc1.tar.gz,传入光猫临时目录,如 /run/shm 。: O5 X6 ~" |, x6 `

/ ^  @! v) ~" g( c! l2、将rootfs2203rc1.tar.gz提取至 (lxc-config lxc.lxcpath)/openwrt/rootfs 。
0 w( k, ]$ p* \  Y" x9 H
  1. root@F650A:/usr/var/lib/lxc/openwrt/rootfs # tar -xzvf /run/shm/rootfs2203rc1.tar.gz -C ./
复制代码

1 ]% o- p( E4 D- G; x; ]( N: W8 o6 J  w" {' U
3、修改rootfs。openwrt的网络配置与主系统有冲突,需要清除。- l* c. r. X& A# L
    3.1 移除 ./etc/board.d/ 目录下 01_leds 、02_network 、99-default_network 三个文件。
( \2 I+ L0 f8 C- z( t. ^. }2 F    3.2 移除 ./etc/rc.d/ 目录下 K21wpad 、K85odhcpd 、K90network 、S19dnsmasq 、S19firewall 、S19wpad 、S20network 、S35odhcpd 、S96led。
5 u% ^8 ?) U6 T2 Y    3.3 移除 ./etc/modules.d/ 和 ./etc/modules-boot.d/ 及 ./lib/modules/5.10.111/目录下所有文件,openwrt的kernel modules与光猫内核不兼容。' _# n" s! ^" @4 j* ]
6 t3 e6 S/ i7 b, o
    3.4 修改opkg源 ./etc/opkg/distfeeds.conf(可选)
, g) K! w, k$ g6 P2 k9 Z9 d
  1. src/gz openwrt_core https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/targets/bcm53xx/generic/packages
    * z( a- g  y. L; C
  2. src/gz openwrt_base https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/base
    6 @9 g* f& _3 v$ q& h  v
  3. src/gz openwrt_luci https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/luci
      p& P6 S) B- P
  4. src/gz openwrt_packages https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/packages
    " k' c8 I# x7 t; g* M* Z. ^
  5. src/gz openwrt_routing https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/routing$ ^# [9 n. p6 t, b
  6. src/gz openwrt_telephony https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/telephony
    0 n( V( |* g6 M8 a
复制代码
  3.5 修改 ./etc/inittab 实现启动项自启(参考https://github.com/mikma/lxd-ope ... r/files/etc/inittab  i: F- d/ B8 w1 J5 ]
  1. ::sysinit:/etc/init.d/rcS S boot
    ' Z" G% \; N1 S0 k* L2 G! r
  2. ::shutdown:/etc/init.d/rcS K shutdown
    ' w' R) B! e2 U3 ~9 ]
  3. console::askfirst:/usr/libexec/login.sh
复制代码
  3.6 修改密码 ( root 密码 chinadsl
2 q) W6 Y* g7 ]$ o
  1. root@F650A:/usr/var/lib/lxc/openwrt/rootfs # chroot ./
    3 R% E$ U; S5 ~3 T# a
  2. : x6 Y# [8 N% O+ U
  3. + H. Q& H% L6 x" o2 A
  4. BusyBox v1.35.0 (2022-04-20 10:37:37 UTC) built-in shell (ash)" g+ C0 f. [  l. p

  5. . S, {# d% u; y8 H5 E5 Q' O
  6. root@F650A:/ # passwd
    7 Q/ K% ^- s9 ~$ t$ H' G: X
  7. Changing password for root
    - p+ [1 c; y( ^) j4 }6 Y$ o) T
  8. New password:  G# m% s' ~3 }: q7 e
  9. Bad password: too weak
    * z6 U4 f4 M/ c. U# T
  10. Retype password:
    + @; Y' j1 e3 y, l0 p* s
  11. passwd: password for root changed by root
复制代码
  3.7 删除 ./etc/resolv.conf 软连接并新建./etc/resolv.conf,否则openwrt无法解析域名7 n: a  \! P/ \/ W8 D# K3 o+ Q2 H
  1. nameserver 223.5.5.5
    + w5 R% X' X7 J" F' ^& t
  2. nameserver 2001:da8::666) ~0 X; a: I# Z( P! p
复制代码

. e3 {2 m8 X" X$ f# ?
2 L' _: `' n9 d! A! y- b5 j4、修改lxc配置文件 /usr/var/lib/lxc/openwrt/config ,根据各自光猫环境修改测试,这个配置我的F650A可正常使用。
! y$ d, Z4 j- E' E- _: |- Y
  1. lxc.arch = arm$ ~( t8 p) P! b1 b, \# P
  2. lxc.utsname = openwrt
    : i! `. p/ _1 J$ Z4 Y1 X
  3. #lxc.rootfs.mount = /usr/var/lib/lxc/openwrt/rootfs! h0 s3 \: t$ B  D
  4. #lxc.rootfs.path = overlayfs:/opt/upt/framework1/rootfs:/opt/upt/apps/openwrt-rootfs4 G) ^8 ~0 K/ L! S4 l: \; f
  5. lxc.rootfs = /usr/var/lib/lxc/openwrt/rootfs
    ' e8 J- r" C0 A7 K" r' Z
  6. lxc.haltsignal = SIGUSR1
    " ]) e* j3 W" d7 s! a( Q
  7. lxc.tty = 1- I. S3 @" _+ d/ K, f
  8. lxc.pts = 1
    6 R8 ^6 c3 {  `( ~: C: b6 n
  9. #lxc.hook.pre-start = /usr/var/lib/lxc/openwrt/pre-start.sh- }1 o6 b% g# C, {6 E3 n
  10. lxc.aa_profile = lxc-container-default-with-nesting
      f8 y. Y, U( ~7 }. @1 J( \. h
  11. lxc.network.type = none
    & v$ F3 P  z* _
  12. lxc.mount.auto = cgroup-full:rw& H% r; y# p9 ~9 [, s! ~2 A9 @
  13. #lxc.mount.auto = proc sys cgroup" `: t' r8 R% I" l% Q
  14. lxc.mount.entry = sysfs sys sysfs defaults 0 00 w* P/ Y) a8 [3 B
  15. lxc.mount.entry = proc proc proc defaults 0 0
复制代码
+ v" V! K* O9 j1 h8 p
' j, ~9 p2 k  X+ p) M& l/ E+ @; X
5、启动,根据提示按enter进入控制台。
( E: ^+ {; j. {# H( P5 a6 ^$ x
  1. root@F650A:~ # lxc-start -n openwrt# U( e* U- W# D
  2. <6>init: Console is alive
    + X4 _3 Y2 K' K5 }2 f$ m) P
  3. <3>init: Failed to redirect stdin to /dev/null: No such file or directory
    ( u+ X4 E( b- q: f% y
  4. <3>init: Failed to redirect stdout to /dev/null: No such file or directory+ k, c; Z7 f# J2 Z9 c# {/ y# g" K+ u+ z
  5. <3>init: Failed to redirect stderr to /dev/null: No such file or directory% _5 {/ D+ m3 D4 `
  6. <6>kmodloader: loading kernel modules from /etc/modules-boot.d/*
    " w) m  ~& P- D7 [# A4 f
  7. <6>kmodloader: done loading kernel modules from /etc/modules-boot.d/*
    # F3 R( L: E# G3 m8 F
  8. <6>init: - preinit -) E2 C+ q  Q7 N
  9. ls: /etc/board.d/*: No such file or directory+ Y1 i( n8 F  p+ E
  10. Press the [f] key and hit [enter] to enter failsafe mode6 d* j% G% P# D3 _
  11. Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level+ Y. `4 ]; n9 m+ X
  12. <3>mount_root: Could not open mtd device: /dev/mtd123 ]+ D1 A( X" s
  13. <3>mount_root: reading rootfs failed4 ^; [5 y1 N5 T! ?
  14. <5>mount_root: mounting /dev/root
    $ z2 {+ \( v) K8 w+ H3 x
  15. urandom-seed: Something is wrong with /dev/urandom
    5 s+ y) u! U* J! A9 o- \
  16. <6>procd: - early -2 K9 f6 y- Y6 m  f' \' ]) f+ Y$ f+ _' K
  17. <6>procd: - ubus -
    * p$ w1 A0 C% R: l! [, d5 N
  18. <6>procd: - init -' [: X, a6 s# \9 z% P( Y
  19. Please press Enter to activate this console.
    ( K, ^: @3 l; y! N, u$ z* `
  20. <6>kmodloader: loading kernel modules from /etc/modules.d/*; j9 G7 n4 n" S, e. q9 F$ C1 e6 P
  21. <6>kmodloader: done loading kernel modules from /etc/modules.d/*3 Y% L& ?6 y8 b* ^0 |3 R0 j
  22. <6>urngd: v1.0.2 started.6 c, a' ^% q4 B) q
  23. 2 G2 `9 Q( b4 g% K# V+ ?

  24. 2 {& l7 o( n' ^2 ]* O

  25. 8 o. W# j- u% W7 v
  26. BusyBox v1.35.0 (2022-04-20 10:37:37 UTC) built-in shell (ash)5 O, ?8 }8 p  f( z  b4 g
  27. ) H, |% l( D8 ~: w& G. }" E6 K
  28.   _______                     ________        __
    7 z2 L9 J5 _6 ^
  29. |       |.-----.-----.-----.|  |  |  |.----.|  |_
    9 [0 x% z7 L/ I. u6 ~6 n, |
  30. |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
    $ s! u7 o# ]$ |$ a) |4 S; Y. u
  31. |_______||   __|_____|__|__||________||__|  |____|: i/ @3 H/ K* D  {3 o
  32.           |__| W I R E L E S S   F R E E D O M6 G  K1 W3 B3 C2 ^5 |+ o# B
  33. -----------------------------------------------------
    0 m; N* c3 J, ?; w5 V' A
  34. OpenWrt 22.03.0-rc1, r19302-df622768da
    4 z$ R$ k- u% t' J3 W
  35. -----------------------------------------------------
    $ a4 N$ ~- v5 X: s8 z- a7 W' ^4 p
  36. root@openwrt:/#
复制代码
$ f1 T0 a" o& q2 |* Q$ k/ Y' B

4 o" l% b! R0 T8 a
  1. root@openwrt:/# ps% n  c8 I4 }6 O2 c) @9 f
  2.   PID USER       VSZ STAT COMMAND$ S4 u* T2 P; }) D4 K
  3.     1 root      1452 S    /sbin/procd
    & V9 J1 n1 \# F7 k+ v0 E
  4.    58 ubus      1112 S    /sbin/ubusd8 I% U- G- _  b% ]; W4 s
  5.    59 root      1196 S    /bin/ash --login
    0 d( `/ W0 T; F' j3 c* G: ~
  6.    93 root       908 S    /sbin/urngd
    8 _2 e( A$ `( L' j( W3 e& M
  7.   204 root      3736 S    /usr/sbin/uhttpd -f -h /www -r OpenWrt -x /cgi-bin -u /ubus -t 60 -T 30
    ; O9 r, p2 p2 z2 s+ Q1 B
  8.   487 root      1952 S    /sbin/rpcd -s /var/run/ubus/ubus.sock -t 301 a( ?; g- Y6 }) ~  m( P
  9.   556 root       956 S    /usr/sbin/dropbear -F -P /var/run/dropbear.1.pid -p 22 -K 300 -T 3
    ' C0 n5 T5 g1 m- m
  10. 1065 root      1200 R    ps
    6 v# t1 }( N. C" }
  11. root@openwrt:/#
复制代码
3 t3 s9 e! Z' D$ a$ K8 I

) a7 m4 Y7 C5 N5 K8 g
  1. root@openwrt:/# opkg update+ w) @/ Z- n3 @9 J
  2. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/targets/bcm53xx/generic/packages/Packages.gz
    " Z% o% \9 a1 b7 ~2 p" l
  3. Updated list of available packages in /var/opkg-lists/openwrt_core4 ~5 o" m- |0 p* R4 W) C
  4. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/targets/bcm53xx/generic/packages/Packages.sig, O! D# c- j+ j. k% _& w/ P# g
  5. Signature check passed.
    1 D" {' _4 |/ B) A/ |* B, l
  6. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/base/Packages.gz5 E( O4 O3 i; E) z! }
  7. Updated list of available packages in /var/opkg-lists/openwrt_base
    ! U5 U# {$ Q  t+ S! g# Q
  8. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/base/Packages.sig
    $ ^! W/ y- z- W; N$ k! ~3 G
  9. Signature check passed.( r$ R5 {6 N! g7 u2 E/ m2 P- u! M
  10. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/luci/Packages.gz
    % l0 R9 f2 m7 k% {* }7 J
  11. Updated list of available packages in /var/opkg-lists/openwrt_luci2 C/ m2 Y* |! Z: r) F! c
  12. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/luci/Packages.sig
    7 F9 V5 l) k2 f( n9 B
  13. Signature check passed.
    * e  v  c9 [0 q8 e; X& Y" `6 u; g
  14. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/packages/Packages.gz
      F7 C1 c9 ?8 d& k/ |/ n' {2 ]# L
  15. Updated list of available packages in /var/opkg-lists/openwrt_packages# M1 U: t* V1 `5 u4 m
  16. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/packages/Packages.sig# k: z3 X  F1 C; Q( `. v/ K2 X& S- e
  17. Signature check passed./ u  j: T& T, @
  18. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/routing/Packages.gz1 y* `% `! U; p4 w
  19. Updated list of available packages in /var/opkg-lists/openwrt_routing
    : @! \/ l" k, g* j2 P
  20. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/routing/Packages.sig, C3 a  l8 H2 e1 `6 `: g
  21. Signature check passed.8 F$ i. B6 f, }" W1 ]
  22. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/telephony/Packages.gz
    ( m3 P7 c& T% @9 X
  23. Updated list of available packages in /var/opkg-lists/openwrt_telephony! M2 R' P: E# o" U- k
  24. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/telephony/Packages.sig9 D+ k% @) ?& d
  25. Signature check passed.
    9 m0 O+ L& W' k4 K! U
  26. root@openwrt:/#
复制代码
; Z: s) v  F" c% i- d
, T% r. e8 I; _0 J, p+ @8 \% L
此时临时的openwrt系统已建好,运行的服务有两个:http占用主系统的80和443端口,ssh占用22端口。1 U4 b! Z3 a, l8 [& f- e
  a) \$ f+ D* u- i9 \; b1 D; D' W
如果光猫有公网IP,请务必关闭ssh密码登录并使用密钥。6 X8 \1 x4 m0 k( D: k! K9 k

! i; j, E/ N# Z3 u  p" B后期使用建议使用 lxc-start -dn openwrt 后台启动,使用 lxc-stop -kn openwrt 命令关闭。openwrt管理使用ssh密钥登录。
( P9 A2 j, U6 _# ?需要固化openwrt到固件的,可以打包rootfs和config(需修改配置),mksquashfs制作成squashfs,用mtd写入saf分区,就不用担心恢复出厂设置了。  Q' t- |: w4 `9 }7 ]4 z2 p& O
随光猫启动可以参考二楼。
( t  ^- ?2 ^8 j& i6 h+ |& l
  X: A; l1 s0 o5 Y

本帖子中包含更多资源

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

×
 楼主| 发表于 2022-4-27 23:10:13 | 显示全部楼层
因光猫原系统的busybox功能不完整,也没有nano和dropbear,调试lxc可能会不方便,现分享出来。9 n, k, q6 b9 F8 R/ t
9 c3 r* w+ e4 x: l& |0 c
  1. root@F650A:~ # /usr/bin/busybox
    / e' @  P, ?! J0 I5 m# A
  2. BusyBox v1.23.2 (2020-06-16 16:53:26 CST) multi-call binary.4 o# U5 U/ @" k
  3. BusyBox is copyrighted by many authors between 1998-2012.
    0 T8 \( O1 H" P$ x# {1 c* D
  4. Licensed under GPLv2. See source distribution for detailed, ]3 f" p( p; T( }; f) {
  5. copyright notices.
    ' [. Z1 J& i4 |

  6. % }: P5 |+ m5 ~8 k5 g4 ?
  7. Usage: busybox [function [arguments]...]
    ! B- O. H$ f( i$ n$ J- v7 w
  8.    or: busybox --list[-full]
    1 p# l+ \2 e, m, W, d  l- C$ z
  9.    or: busybox --install [-s] [DIR]9 l5 W0 R3 |  X+ V7 N! \; r4 x( m
  10.    or: function [arguments]...
    1 S8 F; L, Y" p
  11. ) ?# f+ f$ |$ m9 B
  12.         BusyBox is a multi-call binary that combines many common Unix: q4 ~' Q0 M3 S; h
  13.         utilities into a single executable.  Most people will create a
    * O3 {! c/ G+ b' V1 B- v
  14.         link to busybox for each function they wish to use and BusyBox
    - X, k' N9 `) m5 P
  15.         will act like whatever it was invoked as.* K- y  b* v" P1 o9 x+ T

  16. " p5 K$ g/ C+ P/ ]  H$ s
  17. Currently defined functions:* }; |' Q" X, _0 \7 A
  18.         [, [[, addgroup, adduser, ar, arp, arping, ash, awk, basename, blkid, brctl, bunzip2,( a0 L6 I* q& J6 ?6 z
  19.         bzcat, cat, catv, chattr, chgrp, chmod, chown, chroot, chrt, chvt, cksum, clear, cmp, cp,& q  o  s8 w  O( b: f
  20.         cpio, crond, crontab, cut, date, dc, dd, deallocvt, delgroup, deluser, depmod, devmem, df,
      v( I& u+ r2 w
  21.         diff, dirname, dmesg, dnsd, dnsdomainname, dos2unix, du, dumpkmap, echo, egrep, eject, env,; ]( H; P  P: H1 ?) E* K4 j% f0 c
  22.         ether-wake, expr, false, fbset, fdflush, fdformat, fdisk, fgrep, find, flock, fold, free,7 q- W- L* s2 B9 x
  23.         freeramdisk, fsck, fstrim, fuser, getopt, getty, grep, gunzip, gzip, halt, hdparm, head,
    ( F3 q( \/ r2 A/ Q/ @: p8 u
  24.         hexdump, hostid, hostname, hwclock, id, ifconfig, ifdown, ifup, inetd, init, insmod,
    & d' o$ U4 B: n+ j
  25.         install, ip, ipaddr, ipcrm, ipcs, iplink, iproute, iprule, iptunnel, kill, killall,# Z5 |/ ~4 R" j7 K( Q' t* {
  26.         killall5, klogd, last, less, linux32, linux64, linuxrc, ln, loadfont, loadkmap, logger,6 a( I, a- S/ U0 [; z: t
  27.         login, logname, losetup, ls, lsattr, lsmod, lsof, lspci, lsusb, lzcat, lzma, makedevs,! ^) f1 f, _- P9 R  h. c- [  Q
  28.         md5sum, mdev, mesg, microcom, mkdir, mke2fs, mkfifo, mkfs.ext2, mknod, mkswap, mktemp,% H% c! d/ U3 j+ y
  29.         modinfo, modprobe, more, mount, mountpoint, mt, mv, nameif, nanddump, nandwrite, netstat,
    $ X9 c, D0 i# X% f8 {+ M
  30.         nice, nohup, nslookup, od, openvt, passwd, patch, pidof, ping, pipe_progress, pivot_root,8 Z0 E  `+ B) N! _0 ^
  31.         poweroff, printenv, printf, ps, pwd, rdate, readlink, readprofile, realpath, reboot,
    : k7 O4 B: V% ~2 \. Q
  32.         renice, reset, resize, rm, rmdir, rmmod, route, run-parts, runlevel, sed, seq, setarch," z7 C. Q9 D9 ~3 u! l
  33.         setconsole, setkeycodes, setlogcons, setserial, setsid, sh, sha1sum, sha256sum, sha3sum,
    3 W; X, Z, ~3 z% R; C* t
  34.         sha512sum, sleep, sort, start-stop-daemon, strings, stty, su, sulogin, swapoff, swapon,* e* j) W, n. ^/ a5 F3 v
  35.         switch_root, sync, sysctl, syslogd, tail, tar, tee, telnet, telnetd, test, tftp, time, top,
    8 s  o% ]8 w, X, F% z3 E/ M; Y
  36.         touch, tr, traceroute, traceroute6, true, tty, ubiattach, ubidetach, ubimkvol, ubirmvol,
    6 s% g, Z# C: {6 L
  37.         ubirsvol, ubiupdatevol, udhcpc, umount, uname, uniq, unix2dos, unlink, unlzma, unxz, unzip,
    3 e; t5 ~& o/ F5 T/ |3 {- u( E
  38.         uptime, usleep, uudecode, uuencode, vconfig, vi, vlock, watch, watchdog, wc, wget, which,  F- i, u2 B" q3 _8 C! y7 c
  39.         who, whoami, xargs, xz, xzcat, yes, zcat
    9 E; f6 g* p# U8 b, P' u+ j0 X

  40. 6 E2 S: s3 @! `7 p6 g) y+ Q
复制代码
  1. root@F650A:~ # nano -h8 x9 v/ O$ a. r  L* d
  2. Usage: nano [OPTIONS] [[+LINE,COLUMN] FILE]...% ?: i9 E* U: K& a, R

  3. . P/ f- m" r  @
  4. Option          GNU long option         Meaning
      v* z  n1 I2 K6 o' I& X8 ]/ f1 y
  5. +LINE,COLUMN                           Start at line LINE, column COLUMN
    * ^$ {% Y& N) F: c$ D
  6. -D             --boldtext              Use bold instead of reverse video text
    - ]2 C2 g" }" v  I/ P
  7. -K             --rebindkeypad          Fix numeric keypad key confusion problem
    $ r' T5 d; _# ~( Q4 @$ e6 k
  8. -L             --nonewlines            Don't add newlines to the ends of files
    ; v% O6 b! y: k1 ~1 i9 [) u/ `
  9. -O             --morespace             Use one more line for editing& [8 J& F6 o: Q6 j- V' I' [
  10. -R             --restricted            Restricted mode
    5 ]# z- t  r: x* M4 L# X- V* Q
  11. -T <#cols>     --tabsize=<#cols>       Set width of a tab to #cols columns
    # M6 I8 d8 J; i( I
  12. -V             --version               Print version information and exit
    2 [& x1 R( t. r+ v8 F5 f
  13. -c             --const                 Constantly show cursor position
    + S; ~$ X2 e" v) d: R+ |* e
  14. -d             --rebinddelete          Fix Backspace/Delete confusion problem) ?& t0 S* A' ~3 I% F) \
  15. -h             --help                  Show this help text
    9 X! W* Y5 I+ C2 y" w# g
  16. -l             --nofollow              Don't follow symbolic links, overwrite
    + ^0 P) m! ]. [
  17. -n             --noread                Do not read the file (only write it)0 n, Z/ B$ ]; G% ]8 a
  18. -p             --preserve              Preserve XON (^Q) and XOFF (^S) keys( W2 z  Z2 n7 ?& f. l
  19. -t             --tempfile              Auto save on exit, don't prompt
    % ?- U0 g/ X/ k/ q
  20. -v             --view                  View mode (read-only)
    4 H$ e' O+ h# r) m4 }8 k4 i
  21. -x             --nohelp                Don't show the two help lines- R- U+ m5 U7 ?3 z! g/ a& q
  22. -z             --suspend               Enable suspension( V; d( w' Y$ ^/ ~
  23. root@F650A:~ # nano -V
    " B9 C+ D' j7 f
  24. GNU nano, version 2.4.2
    " ^* ^  y. H  g! o1 B, C
  25. (C) 1999..2015 Free Software Foundation, Inc.
    6 S+ H2 n; k" x3 B' U
  26. Email: nano@nano-editor.org    Web: http://www.nano-editor.org/
    ! B3 i9 w* F  M
  27. Compiled options: --enable-tiny --disable-utf8" o* `- X  r5 E
复制代码
  1. root@F650A:~ # dropbear -h6 Z* ^- q" c" u8 Z9 a
  2. Dropbear server v2015.67 https://matt.ucc.asn.au/dropbear/dropbear.html: w& x3 L$ k$ e  i* d
  3. Usage: dropbear [options]
    0 |7 x; I+ \+ I- V
  4. -b bannerfile   Display the contents of bannerfile before user login8 v7 z8 o, \1 X  i" o# Q
  5.                 (default: none), z! g" K$ w3 r6 ~8 o
  6. -r keyfile  Specify hostkeys (repeatable)
      o' y5 g! j" Q9 a# X
  7.                 defaults:
    , b' G" z' h+ `! f/ F
  8.                 dss /etc/dropbear/dropbear_dss_host_key
    " m' p$ m0 \9 j% R: D$ Y
  9.                 rsa /etc/dropbear/dropbear_rsa_host_key% V9 q9 j0 X/ q
  10.                 ecdsa /etc/dropbear/dropbear_ecdsa_host_key
    ' z/ U7 ?' h; B2 W9 g9 s
  11. -R              Create hostkeys as required
    % o% u) M5 Y/ M0 s( n
  12. -F              Don't fork into background
    & s$ |, x- p/ ?: i$ h
  13. -E              Log to stderr rather than syslog8 C5 d8 y  H( f1 V$ M
  14. -m              Don't display the motd on login0 \# i# N! c% [- _, M+ \
  15. -w              Disallow root logins1 X3 @: [2 \* W* M
  16. -s              Disable password logins
    / j- M# P9 M( f
  17. -g              Disable password logins for root
    $ e2 A. s7 m$ S* `& A0 g
  18. -B              Allow blank password logins0 q+ v) ^1 k5 \7 ~
  19. -j              Disable local port forwarding
    & Z/ ]4 \  R7 q: S
  20. -k              Disable remote port forwarding# ~% b) Q& J' i" k" O- i5 |" A5 I
  21. -a              Allow connections to forwarded ports from any host
    1 ^# }' h! e8 S/ C) a
  22. -p [address:]port5 X; L" S% M6 M  y
  23.                 Listen on specified tcp port (and optionally address),
    7 F! c  V# C' y5 v
  24.                 up to 10 can be specified
    ! k3 y2 o4 c# z# m
  25.                 (default port is 22 if none specified)  x. U6 k  j& o1 E! ^
  26. -P PidFile      Create pid file PidFile
    , G- L: ~. N# m+ v. W
  27.                 (default /var/run/dropbear.pid)
    : ]$ U, I: Q8 A  a0 l/ H
  28. -i              Start for inetd) f2 k* q$ p  I3 ~  s
  29. -W <receive_window_buffer> (default 24576, larger may be faster, max 1MB)* R) m1 ?% \* b" N( {
  30. -K <keepalive>  (0 is never, default 0, in seconds), r/ B; m6 I7 p, q" e! s" O# Z
  31. -I <idle_timeout>  (0 is never, default 0, in seconds)
    5 k" D" }/ Y! C4 J* }- C) Z
  32. -V    Version
    ; I* b' X/ r/ Y! I# ]6 s
复制代码
( Z( O+ ?" }) |2 o6 q3 t- H
( C# ^0 |3 E! X6 t

本帖子中包含更多资源

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

×
发表于 2021-11-27 21:38:54 | 显示全部楼层
本帖最后由 btworm 于 2021-11-27 21:41 编辑 + n  }/ S) e) o& Y5 J2 H
songee 发表于 2021-11-27 04:15/ h1 g5 c; G. V3 c! k: y' k* }# J& P
1.只要lxc相关命令可以正常运行,写好配置文件,选择符合CPU架构的rootfs,就可以把容器跑起来。
# c8 V) E: M  j4 t: p  T3 e2.我的 ...

8 y, E+ ~) x. E; }- \感谢指点!5 e" A3 c( p" D, i  Q9 u) _: I# c
7 w. L; Q# J: @+ V
关于第2点
7 ]5 ?7 _* j  V0 Q1 Y% _华为光猫 / 只读,/etc,/usr,/lib这些目录也都依附于/, 所以都不可写, /opt目录不存在,当然也无法创建。# B7 E4 d9 Y4 p9 {$ X# w0 [
' G- ^% v: `$ W- N0 |' w& v
之前担心/dev/pts, /proc, /sys只读,是因为以前玩路由器时,有个chroot脚本使用过这些目录,刚又看了遍那个脚本,使用的是 "-o bind"参数,所以主机目录是否可写就无所谓了。在华为猫上跑lxc应该没问题了
8 [! Y2 J  T7 X7 c1 y, m) q
3 D$ X& S: O% f. t另外想问问,光猫容器内的应用对端口的监听是:3 o* P) v- H7 c. C: H  h5 ^
1.直接监听光猫的端口?
2 \/ T# W4 g" N! ^2.还是只能监听容器内的端口,并需要光猫iptables做端口转发给容器?
 楼主| 发表于 2020-2-22 18:37:10 | 显示全部楼层
anysoft 发表于 2020-2-22 17:50, f  `3 m+ G8 ^: g2 t) Q/ |
HS8145V HS8145V5  F650A 都是512MB+256MB 2.4G+5G方案& r9 ~* o6 S: @+ ^) l
价格都还好,特别F650A 因为会玩的人少价格特别便 ...
+ y5 H  A2 ^: K9 x/ ~
hs8145v技术成熟,更适合玩,而且其实f650a是512/128,nand flash少了一半,CPU一个尿性,价格差别不大的话,能hs8145v还是别选650。
( V/ p' C" i* o还有个大胆想法,lxc可以通过配置文件config修改子系统网络,从eth0桥接是不是就能在子系统多拨了,子系统专门离线和网络存储,不影响猫后面接的手机电脑上网,还是蛮有趣的/ L' }  o6 v6 i

" a6 {* A' }/ ]0 x2 j2 ~/ e$ {; [' t5 k

, d5 C) R; E$ S( y3 o0 N
 楼主| 发表于 2020-2-17 02:19:26 | 显示全部楼层

二楼原帖,仅保留做参考

本帖最后由 songee 于 2022-4-27 21:17 编辑
2 g* B" S" H  ?7 q. V, ~; o2 m: H! M+ Z. t

% y6 u' \4 A! D+ q/ B& a2 H8 y(2020年原帖初步摸索,过程过于繁杂,不建议再按这部分思路操作)
8 k# h4 {; p0 S中兴、华为等带有saf模块的光猫,以官方版openwrt替换厂商定制版的思路总结一下,供大家参考。" n6 F' N; b+ r% z  `
1、准备工具
$ y' n" E$ q% Q6 B' r3 Q    F650A主系统没有 mtd 、 dd 和 vi 等工具,而自带的saf子系统正好都有,子系统位于framework分区即mtd6,挂载于/opt/upt/framework,cp过来可以直接使用。
root@F650A:~ # cp /opt/upt/framework/saf/rootfs/sbin/mtd /usr/bin/
/ m% N- Q2 ^# o8 w5 Eroot@F650A:~ # cp /opt/upt/framework/saf/rootfs/lib/libubox.so /lib/
; v5 V) H' h! M# A! `root@F650A:~ # cp /opt/upt/framework/saf/rootfs/bin/busybox /usr/bin/; I- [' Y7 u6 N9 |9 @
root@F650A:~ # cd /usr/bin/
3 `- ]2 [& r% a0 M$ z: ^. @root@F650A:/usr/bin # ln -s busybox dd
& r% A; s. R( Yroot@F650A:/usr/bin # ln -s busybox vi

' T! N1 m- `- K& I, @  u# f2、改进lxd-openwrt生成代码。
0 n3 h; d1 K% 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如下
: O& ?4 d  ^, j  L9 G8 l
*** build.sh                2020-02-19 01:50:10.972675562 -0100
3 \" H4 G) d2 F- j' n. N--- build.sh.origin        2020-02-14 19:10:45.000000000 -01001 i/ @+ S+ v+ |& @* ~
***************
- o& I* D! ]1 r( ^" w' z*** 72,81 ****3 R# g# b+ A/ c8 s$ K' [7 z4 s
                  subarch=649 }3 O5 q' I% N$ `
                  arch_ipk=x86_64
& ~# [5 Z  M1 d# K1 j' L7 }                  ;;' Z( ~' X1 M% j0 z5 ?. @0 u
!         arm)
7 v( U6 H$ C: U!                 arch=bcm53xx  E  s) _$ Q# V
!                 subarch=generic7 ^! V$ p. Z" G  b- v
!                 arch_ipk=arm_cortex-a9  V  B: n2 }$ i2 t6 z
                  ;;
' i+ y+ W& Y$ N: N1 R          *)2 d& O; C: f8 b% D
                  usage
  J& o4 ]: L. t--- 72,81 ----" a/ i6 ^0 |( v8 D* y
                  subarch=646 m6 j& ~7 g8 Z
                  arch_ipk=x86_64
) f1 _3 l4 O. U6 B                  ;;$ u! Y1 U( i0 U: _
!         aarch64)  h: v5 W& P' [9 }9 J3 g
!                 arch=armvirt
, v3 n& T: b' Q% t6 O5 Y!                 subarch=64& N' k; x6 S% C* ^  i) R8 g' {
!                 arch_ipk=aarch64_generic
/ N: V3 ]3 |# y$ Z4 `' e6 w                  ;;3 w, a5 Q! }3 i: w% H
          *)* t9 h, f0 m2 r. g1 Y. k' Y: M
                  usage
8 T8 ?: R. U. M+ Q% \; L4 i***************5 D8 F' T. Q0 K) T3 `( N. X
*** 87,97 ****
1 a3 C$ s6 t7 K* ]  I/ N  if test $ver = snapshot; then$ C) M, [9 Z4 F- f0 Y
          openwrt_branch=snapshot7 Q8 ~" V+ b4 L* i
          procd_url=https://github.com/openwrt/openwrt/trunk/package/system/procd7 O2 e. h+ @( w7 F7 U& }
!         openwrt_url=https://mirrors.cloud.tencent.com/lede/snapshots/targets/${arch}/${subarch}
. Q; \; ~) F. k0 N" R7 H- d5 u  else
9 N6 u$ p& f* c2 l  q) I5 L          openwrt_branch=${dist}-${branch_ver}
; n9 _8 ]8 f+ e# r+ ~4 L          procd_url=https://github.com/openwrt/openwrt/branches/${openwrt_branch}/package/system/procd' \# i. k; U2 C: M. f
!         openwrt_url=https://mirrors.cloud.tencent.com/lede/releases/${ver}/targets/${arch}/${subarch}
4 b) I+ _8 H9 x. ~( f  fi/ J7 W" \: |% Y6 s: F' b
  
$ n% Q) r% u9 q$ u1 T" P8 g  procd_extra_ver=lxd-3
7 }  t$ V. H8 j--- 87,97 ----) g. ?; f: c: {
  if test $ver = snapshot; then
5 \3 I. g2 j7 _$ e: Q1 v7 f  Z          openwrt_branch=snapshot
6 T. ~' `5 h) W. F! c; T2 g          procd_url=https://github.com/openwrt/openwrt/trunk/package/system/procd2 p" k6 k7 }' q. Z
!         openwrt_url=https://downloads.openwrt.org/snapshots/targets/${arch}/${subarch}
( Y/ s: T. b/ f1 x8 H4 n  else
  z9 h$ m! R* m, p2 w! F, T* P; R5 m" Q          openwrt_branch=${dist}-${branch_ver}
3 i; \7 D1 |  \8 K          procd_url=https://github.com/openwrt/openwrt/branches/${openwrt_branch}/package/system/procd! [/ t! H8 V- Z8 m, r/ |8 o5 p
!         openwrt_url=https://downloads.openwrt.org/releases/${ver}/targets/${arch}/${subarch}) d# e8 t$ ~2 u( L8 K4 A- p6 F
  fi
  u4 `7 C* r/ i  M: [1 |- z0 i  
/ i0 L% Y$ c+ }/ d% n+ ], H  procd_extra_ver=lxd-3( M: M, h  e6 z# I% b9 H
**************** I5 D4 v1 p$ _/ w
*** 112,125 ****
3 r+ x8 F, [9 x1 g6 p  }
- x8 F8 l0 a2 \0 n+ _0 ?0 C    Y5 [, K+ j# `; w0 \! A
  download_rootfs() {
. u9 g# n6 }, u& q: }( d$ Y7 J! #        detect_url "rootfs\.tar"
; ^1 [0 k; Q8 i$ l1 C5 G! #        local rootfs_url=$openwrt_url/$return6 O  P4 e4 K" d& w2 I- X5 B. F6 X
  
- w/ ]2 q2 l* M- x* z- ?+ l5 K          # global $rootfs; U* P7 S+ x' I. n* G& ~7 @" A
!         rootfs=dl/openwrt-19.07.1-bcm53xx-generic-rootfs.tar.gz: T" n) ]$ z. q8 ?: L+ S6 `( m
  4 v0 H8 L0 h/ {# k/ `$ `: P, ~# ^
! #        download $rootfs_url $rootfs $rootfs: H" v& a+ Y4 O" A& U. j& ?0 B
! #        check $rootfs $rootfs_url
! b# |/ o. P/ o( [* o- M) h  }  g% v! b5 ?5 u+ u
  5 n( j4 X. @# J7 b' v2 N7 S
  download_sdk() {
0 R; m6 ~4 V* [6 U! `# a--- 112,125 ----
  `# v/ c, Y+ c  }
$ v2 T# ]  _8 y- Q, f; ?& z  
4 q: p9 E, x9 k+ D( `- J* t  download_rootfs() {
) t; x: d7 W9 Z: k( O+ v* C!         detect_url "rootfs\.tar"' ]. ?) L" H9 a% g4 t: q
!         local rootfs_url=$openwrt_url/$return
0 R  `5 ]$ j' |/ @  
! x/ r4 E1 Y0 F( ~          # global $rootfs7 A* j% p" F2 |% ^
!         rootfs=dl/$(basename $rootfs_url)
0 _' T( C& l. g- c  
) B; `8 N6 v% Z) F5 S# B4 ~!         download $rootfs_url $rootfs
9 r- B" ?3 M/ c. S8 |4 d+ h!         check $rootfs $rootfs_url8 e. T' {4 r+ i  Z
  }; N1 d4 O' q# Y4 a& a
  ( q+ v( L& V: i0 Q' ^* c' Z
  download_sdk() {

2 A6 L) T* B! B  |" }3、从腾讯镜像下载openwrt-19.07.1-bcm53xx-tplink-archer-c9-v1-squashfs.bin,从固件中提取rootfs并预处理。8 }0 w( z2 @/ O0 a
  1. x@x-Surface-Pro-3:~/下载$ binwalk openwrt-19.07.1-bcm53xx-tplink-archer-c9-v1-squashfs.bin
    1 [, \6 z) I; @

  2. * u" x1 z& B+ N( P& K3 K# u8 J
  3. DECIMAL       HEXADECIMAL     DESCRIPTION$ V; w5 Y! \6 Z2 W. Q- |3 @
  4. --------------------------------------------------------------------------------
    & t9 l6 R2 }( n  L! q' Q8 m6 m
  5. 8317          0x207D          TRX firmware header, little endian, image size: 1810432 bytes, CRC32: 0xBCD36218, flags: 0x0, version: 1, header size: 28 bytes, loader offset: 0x1C, linux kernel offset: 0x0, rootfs offset: 0x0
    $ G, v% D- H2 W  K. \0 _7 d
  6. 8345          0x2099          LZMA compressed data, properties: 0x5D, dictionary size: 65536 bytes, uncompressed size: 1801662 bytes
    $ n5 x, `# N1 _5 e& Y  j- R/ j8 V
  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' i0 T, v; b( v# X& W; r/ a
  8. 2 v  F. }0 J8 S# L: M
  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' u& J" `1 Y" H, E
  10. 记录了1900548+0 的读入
    & r* X! d0 I! @* N4 l2 H* M8 Q
  11. 记录了1900548+0 的写出  q8 e1 ~& u% A( T6 Q* m( |
  12. 1900548 bytes (1.9 MB, 1.8 MiB) copied, 5.16823 s, 368 kB/s2 \& U; x/ f! @: ?8 ~/ F; y/ v9 O
  13. x@x-Surface-Pro-3:~/下载$ binwalk rootfs-squashfs.bin $ _$ l0 t' O, G3 d$ ]4 T& P  s- q# O

  14. ; q; I& ]4 V7 G: W! U* o. ]
  15. DECIMAL       HEXADECIMAL     DESCRIPTION
    - j% @+ P% r. M1 V
  16. --------------------------------------------------------------------------------% a' s0 G) {* _2 [5 |, Z
  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; F9 {7 b& x4 U- j# q: O

  18. 0 M# x8 ]/ _% h, L  n
  19. x@x-Surface-Pro-3:~/下载$ unsquashfs rootfs-squashfs.bin " N) m; G9 a: G6 ~
  20. Parallel unsquashfs: Using 4 processors
    . j6 i& h. b" }) a; Y- V4 _, c! m
  21. 1071 inodes (1066 blocks) to write
    ! h: h. q$ S! U1 }' ~: h' a
  22. 3 Y1 `! Y! x9 E! L. ?+ h

  23. 1 D1 Q; K2 `1 m3 H$ [4 G
  24. create_inode: could not create character device squashfs-root/dev/console, because you're not superuser!
    ' ]" C- [' o: A! Y- X/ ^
  25. [====================================================================================================| ] 1065/1066  99%' Y, ]1 W/ p* t, p

  26. % ]( s& ?9 w2 X' O! N9 c
  27. created 875 files5 N: B/ v1 d5 O
  28. created 103 directories
    & c( }3 s% S- y* Y3 c. w+ g9 y
  29. created 195 symlinks
    . N& D$ M+ I3 m% t7 q
  30. created 0 devices
    / H( V, p; U; y5 N
  31. created 0 fifos5 ^: A: y- M! G: w6 j
  32. x@x-Surface-Pro-3:~/下载$ cd ./squashfs-root/  K9 `6 C% |; V0 V/ c- u% \  K
  33. x@x-Surface-Pro-3:~/下载/squashfs-root$ gedit etc/opkg/distfeeds.conf
复制代码
将opkg软件源改为腾讯镜像
& Q9 m3 F6 ]& O: W5 j1 R
src/gz openwrt_core https://mirrors.cloud.tencent.co ... xx/generic/packages
, a3 t5 E/ k1 \9 O/ d- H7 ?src/gz openwrt_kmods https://mirrors.cloud.tencent.co ... 92b7d7eca715b1ee0b8
( G6 x4 L. m. t, T; u; Asrc/gz openwrt_base https://mirrors.cloud.tencent.co ... /arm_cortex-a9/base
0 I2 w$ i; @& `src/gz openwrt_luci https://mirrors.cloud.tencent.co ... /arm_cortex-a9/luci
+ n/ P/ W% F. P; \src/gz openwrt_packages https://mirrors.cloud.tencent.co ... _cortex-a9/packages
" V# `+ n% w! ~src/gz openwrt_routing https://mirrors.cloud.tencent.co ... m_cortex-a9/routing% x' ?" p' o1 a
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 ./3 E- @4 e5 p( u* \, P
  2. x@x-Surface-Pro-3:~/下载/squashfs-root$ cd ../8 }, t" }' w* f6 k3 j! w3 h
  3. x@x-Surface-Pro-3:~/下载$ mkdir lxd-openwrt-master/dl
    5 n- K8 ^$ i4 @0 y( x6 ~6 l# Q
  4. x@x-Surface-Pro-3:~/下载$ mv openwrt-19.07.1-bcm53xx-generic-rootfs.tar.gz lxd-openwrt-master/dl/
复制代码
执行修改过的build.sh
0 _9 D; ]4 B1 ^/ U0 Y) F
  1. x@x-Surface-Pro-3:~/下载$ cd lxd-openwrt-master/: c5 z5 X0 R4 X8 V
  2. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ ./build.sh -a arm -v 19.07.1" U9 C( a% T  r) [7 n5 i( G" ~
  3. ......
    ( S# S5 S# G$ C3 g" _
  4. Pack rootfs
    - P) }& f4 Y$ W
  5. Tarball built: bin/openwrt-19.07.1-bcm53xx-generic-lxd.tar.gz' P. O. ?+ d  ?* ^
  6. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ mkdir ../openwrt-19.07.1-bcm53xx-generic-lxc  J2 A8 }8 x. A2 ?) y! g5 o
  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
    0 j8 r' c0 m, F: b# h) ^
  8. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ cd ../openwrt-19.07.1-bcm53xx-generic-lxc/2 g3 W) ?, f- s% x3 ]1 \5 C/ v* b3 _
  9. x@x-Surface-Pro-3:~/下载/openwrt-19.07.1-bcm53xx-generic-lxc$ ls* f7 E0 w5 _) A8 B2 ^
  10. metadata.yaml  rootfs  templates. @& A9 `/ z; d: W- w" r% D
  11. x@x-Surface-Pro-3:~/下载/openwrt-19.07.1-bcm53xx-generic-lxc$
复制代码
. Y+ B3 [% d/ Z) W' j
4、这时我们已经创建好lxc下可运行的openwrt19.07.1的rootfs,接下来处理lxc及rootfs的配置文件。
/ x1 G/ m9 ^" r1 B& `进光猫复制自带子系统的两个文件,再通过U盘或ftp传到Ubuntu的openwrt-19.07.1-bcm53xx-generic-lxc目录下,
- w3 [- i- _( D5 Q
  1. root@F650A:~ # cp /opt/upt/framework/saf/config /mnt/USB_disc1/
    ' J0 G( l7 w3 J$ O( |# m3 R4 h
  2. root@F650A:~ # cp /opt/upt/framework/pre-start.sh /mnt/USB_disc1/
复制代码
config为saf系统的配置文件,新系统下稍作修改,: Y& ^) _2 a; O, l6 F
lxc.arch = arm* T% q+ n; ~# v" j, |; w
lxc.utsname = openwrt
# R  E3 I) s: N7 X8 ~0 clxc.rootfs.mount = /usr/var/lib/lxc/openwrt/rootfs
0 m1 V- H* ]1 A7 B2 W+ o7 wlxc.rootfs.path = overlayfs:/opt/upt/framework1/rootfs:/opt/upt/apps/openwrt-rootfs
. a; Q" U7 M0 b( r( F) f, A% y6 s# lxc.rootfs = /usr/var/lib/lxc/openwrt/rootfs # Y+ J7 }" W# S/ |4 C
lxc.haltsignal = SIGUSR1
4 Q$ _" i  `- P1 S6 rlxc.tty = 1
) n" ^6 M; a  y, {lxc.pts = 1
. i" a& E7 C$ Zlxc.hook.pre-start = /usr/var/lib/lxc/openwrt/pre-start.sh
0 N& W6 S( I  ilxc.aa_profile = lxc-container-default-with-nesting0 q& j+ e; T9 Y+ n% l0 Y
lxc.network.type = none$ D. Y1 a$ [: L6 [7 }: z- U. x
lxc.mount.entry = sysfs sys sysfs defaults 0 0
% G& t; s: \9 Y0 d; C; dlxc.mount.auto = cgroup-full:rw
2 S2 V% g" E3 c# [lxc.mount.entry = proc proc proc defaults 0 0, B4 O" A2 X  `" X+ Y/ Z
lxc.mount.entry = /mnt mnt none rw,rbind 0 0" f9 T6 Q- I/ Q7 s
lxc.start.auto = 1
& Y! J* H+ Z+ p0 S# ]$ Y1 A
pre-start.sh处理模拟终端,为避免重复挂载devpts,添加一行卸载代码,* ^. S- ^: q: y4 S: G% b, l& M6 v# V
#!/bin/sh; g' o2 _( P/ h0 @$ Z. B. J
umount /dev/pts /dev/ptmx, @: _, ?9 Z% A8 h  Q6 R
mount -t devpts -o newinstance -o ptmxmode=0666,nosuid devpts /dev/pts3 ^  D- S0 C2 ]  T7 b
mount -o bind /dev/pts/ptmx /dev/ptmx
6 ?# I( P# K1 U: L0 z& q
再删除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镜像,( m9 |2 T4 k3 {$ b/ q" t
  1. x@x-Surface-Pro-3:~/下载$ mksquashfs openwrt-19.07.1-bcm53xx-generic-lxc openwrt-19.07.1-bcm53xx-lxc.bin# s1 V: n, E1 z5 ~
  2. Parallel mksquashfs: Using 4 processors
    8 N, R5 R1 C( m7 x
  3. Creating 4.0 filesystem on openwrt-19.07.1-bcm53xx-lxc.bin, block size 131072.5 i; z" j3 u+ g3 s# H, G
  4. [=======================================================================================================/] 881/881 100%6 Y2 d, P4 L& G  Z1 r5 ]

  5. , d; C) S" q& A6 d4 }8 ~
  6. Exportable Squashfs 4.0 filesystem, gzip compressed, data block size 1310726 X$ D/ m. E  e+ T/ h! }
  7.         compressed data, compressed metadata, compressed fragments,+ C: F  k0 T. d- D% ?6 n
  8.         compressed xattrs, compressed ids0 ~1 w9 N' I" B- p  j6 M
  9.         duplicates are removed2 L( A" |( X& L, n0 X, L' M: {9 |! ^
  10. Filesystem size 3163.90 Kbytes (3.09 Mbytes)( k5 Y% y! b: f" b- i9 W0 j
  11.         48.94% of uncompressed filesystem size (6464.54 Kbytes)7 t& w" B$ f4 W$ G$ H1 h3 l* a+ F
  12. Inode table size 9693 bytes (9.47 Kbytes)
    5 R, \, o5 V, L& p
  13.         25.72% of uncompressed inode table size (37693 bytes)
    2 Q% k0 y2 v5 \* S- Q) N: t
  14. Directory table size 11372 bytes (11.11 Kbytes)# C- O& G3 {1 G+ r* |' U
  15.         47.17% of uncompressed directory table size (24108 bytes)# |- N8 W. o; ?7 |4 P
  16. Number of duplicate files found 1365 ?) v& ~+ X' X# d9 j: X: l
  17. Number of inodes 1145. \0 _7 ^# }6 ?7 s. f4 m
  18. Number of files 873
    - o1 @3 _' l3 Y  c8 ~- U" r
  19. Number of fragments 39
    - _/ H. N2 _2 m% P9 o
  20. Number of symbolic links  1715 G  }9 \4 I4 W0 ~5 }; s' F' r
  21. Number of device nodes 0
    7 y! d: M1 I' M2 Y! a4 ?+ ]
  22. Number of fifo nodes 0
    ( w- s6 k8 Z. \
  23. Number of socket nodes 0$ H# C% g' T$ g4 @5 x
  24. Number of directories 1015 Z" ]7 ]3 O& O/ \; ~& D5 @
  25. Number of ids (unique uids + gids) 1
    $ s$ h+ N4 g7 I. C. S7 L
  26. Number of uids 18 E6 x- Z* d9 U* ?! {" B
  27.         x (1000)
    % I3 ^, w: D3 L/ K
  28. Number of gids 1$ L" P8 l7 V) v
  29.         x (1000)7 O) E  y' L' X6 j# e
  30. x@x-Surface-Pro-3:~/下载$
复制代码
% I. H- m/ a8 R) [

+ G0 r+ N+ E/ @, N: F2 s) M5、生成的openwrt-19.07.1-bcm53xx-lxc.bin传入光猫,'mtd' 写入mtd7分区。
! P' A, w+ Y3 _: C9 F刷之前先关掉saf,因saf有lxc-monitord进程守护,kill掉之后会自动运行,只好修改saf程序名,重启光猫。
' z# H  s  Y& }% p8 B8 P5 {
  1. root@F650A:~ # mv /usr/sbin/saf /usr/sbin/saf.bak9 g6 @6 O0 P$ }2 H
  2. root@F650A:~ # reboot
复制代码
重启后telnet登录,'ps' 确认进程列表没有saf,备份然后写入并挂载。
root@F650A:~ # ps& ~) q: @. ~  O3 l
  PID USER     VSZ   RSS  STAT  CPU COMMAND
  Z* A2 b2 ]  h    1 root     23160   600  S     <1>  init9 {" g$ S7 X) Q, d
    ......9 D& G$ }, d% d7 Y* d& w# D
root@F650A:~ # dd if=/dev/mtd7 of=/mnt/USB_disc1/mtd7.bin bs=1M
7 G; v3 w! d9 N8+0 records in5 Z/ ~9 s. G$ O  j! o% A
8+0 records out
8 h! @& n, D8 u8 z; x) z8 o4 S7 r5 Lroot@F650A:~ # mtd write /mnt/USB_disc1/openwrt-19.07.1-bcm53xx-lxc.bin /dev/mtd7
0 I5 f8 g: y3 h$ k! s" V: OUnlocking /dev/mtd7 ...
% T" e0 V  J8 t) S8 B
3 g% A4 s: `. `Writing from /mnt/USB_disc1/openwrt-19.07.1-bcm53xx-lxc.bin to /dev/mtd7 ...0 H8 d& _# p3 s( k, @7 V" S
root@F650A:~ # mount /dev/mtdblock7 /opt/upt/framework1
6 Y+ k( O, }( |7 c7 ?
6、开启OpenWRT新世界
2 g5 K" M/ Y% b3 W( v    写入mtd7分区并挂载之后,开始首次启动的准备工作。F650A的lxc默认路径在/usr/var/lib/lxc(一楼有说明),按config文件创建相应文件及文件夹,2 ?  F- r* D) H: i; O7 j6 a8 g4 H
9 H& x8 Q( |" A  ]5 ]
  1. root@F650A:~ # mkdir -p /usr/var/lib/lxc/openwrt
    5 R9 a+ ]# ~- x* W
  2. root@F650A:~ # cd /usr/var/lib/lxc/openwrt
    & C- J9 V$ d$ e6 U
  3. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/pre-start.sh pre-start.sh
    , I: v! K. b& u% l3 M( m
  4. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/config config6 \) b% K* v% @6 [: h
  5. root@F650A:/usr/var/lib/lxc/openwrt # mkdir rootfs
    " y+ I1 c) F, {! [# X# s
  6. root@F650A:/usr/var/lib/lxc/openwrt # mkdir /opt/upt/apps/openwrt-rootfs
    % Z+ D0 ]* \2 \. t
  7. root@F650A:/usr/var/lib/lxc/openwrt # lxc-start -dn openwrt
    : v" b1 w2 D$ {9 u
  8. root@F650A:/usr/var/lib/lxc/openwrt # ps
复制代码
此时的进程列表应该可以看到/usr/sbin/uhttpd、dropbear等,或者可以尝试打开浏览器 http://光猫ip/或ssh登录,如果看到Authorization Required提示登录或ssh提示登录用户名密码,表明lxc已成功运行,但此时无密码状态无法网页和ssh登录,只能通过控制台方式添加密码后才能实现。关闭openwrt容器,'ps' 确认,前台启动。
6 }% U! x6 F2 d! \, P
  1. root@F650A:/usr/var/lib/lxc/openwrt # lxc-stop -kn openwrt0 F+ Y+ H3 n  ~/ y$ J2 g; @. S
  2. root@F650A:/usr/var/lib/lxc/openwrt # ps
    4 N3 w  D3 g$ J/ U9 a! m) Z
  3. root@F650A:/usr/var/lib/lxc/openwrt # lxc-start -n openwrt
    1 ?! \5 P# f  H) I. n( J
  4. <6>init: Console is alive  n% ^' V" A* I4 k( u* l
  5. <6>kmodloader: loading kernel modules from /etc/modules-boot.d/*& b4 K" \2 ~2 r# E6 v( z, ?: ?; J
  6. <6>kmodloader: done loading kernel modules from /etc/modules-boot.d/*
    0 `0 q: }1 T1 n0 V
  7. <6>init: - preinit -
    ) L, _* g' K# g/ A, L3 `
  8. WARNING: Variable 'network' does not exist or is not an array/object
    4 ]6 Y& m" A7 j/ k( N4 x* N
  9. WARNING: Variable 'lan' does not exist or is not an array/object
    " @0 m3 X5 ]* n* [" U# W* ?1 |
  10. Press the [f] key and hit [enter] to enter failsafe mode
    5 c* Q) j; {/ ^4 i  x! R! H( L
  11. Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
    0 Y' `2 X7 X0 x5 F( p
  12. <5>mount_root: mounting /dev/root
    ) A; ]0 i1 \/ i& U' L8 e
  13. urandom-seed: Seeding with /etc/urandom.seed
    ' m; s- k. A% Q, C, F& O* m
  14. <6>procd: - early -
    * P$ |# s& w0 e
  15. <6>procd: - ubus -
      i- d" k  o1 O+ I2 x
  16. <6>procd: - init -
    - s' L& H/ ^- P6 |: o- G- E& B; [
  17. Please press Enter to activate this console.( ?& W0 b. i; W1 }& _
  18. <6>urngd: v1.0.2 started.
复制代码
此时回车便可看到openwrt的登入界面,添加密码。2 }* f9 q9 @3 y; s. A2 `4 ?( n# I

  1. 8 n0 |! ?( e& E/ b7 X) l
  2. BusyBox v1.30.1 () built-in shell (ash)8 u% o0 a; Z" d: z

  3. % s; _& x: F3 B8 g7 \  J' T5 X: R: T
  4.   _______                     ________        __
    6 n0 A9 }$ e4 G
  5. |       |.-----.-----.-----.|  |  |  |.----.|  |_
    / t3 d+ d) D5 H% K" f* h3 J1 t, f  E
  6. |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
    9 @* l$ T/ X  u3 l+ A0 I3 c
  7. |_______||   __|_____|__|__||________||__|  |____|
    7 ?# ]- e! C6 U8 N5 W+ J
  8.           |__| W I R E L E S S   F R E E D O M6 S: {3 E/ q9 ^* _" B
  9. -----------------------------------------------------
    # e8 r. @2 }+ t' `# ^
  10. OpenWrt 19.07.1, r10911-c155900f66
    : ?( x7 s- o/ R: r( T
  11. -----------------------------------------------------
      z/ d! T- g4 R7 z0 V: n' o
  12. root@openwrt:/# passwd root+ `/ k7 m$ u) ?+ f' r) [& W
  13. Changing password for root- }# d* d6 Z2 @8 F1 e7 D, Z! M
  14. New password: 1 i8 b: u/ k# c+ M2 V
  15. Bad password: too weak6 v$ D7 r# _7 T; @$ O1 m
  16. Retype password: + w* U8 ]0 s/ a
  17. passwd: password for root changed by root) \- t4 d- w+ _/ \- A  T; L; M% r$ K
  18. root@openwrt:/# exit9 a2 P8 M" ~" m* B. r
  19. Please press Enter to activate this console.
复制代码
控制台方式进入openwrt之后,exit无效,没找到正常的退出方式,只能关闭窗口,此后就可以通过网页和ssh正常登录。) v( D. o# A) j% o  @. R
: K( E! F6 h3 e- m
7、自启动及进程守护' w, V# ?1 A* z3 J: L
    telnet登录光猫主系统,确认saf程序已备份,
+ E3 I" p9 r6 ~9 C2 F$ H1 ]. H$ [3 `$ \% }& M; }$ F, b
  1. root@F650A:~ # ls /usr/sbin/) K' K# m& n2 ~, X
  2. chroot       lsap         saf.bak      telnetd
    # U+ @6 G3 b' k6 A. r$ z! C
  3. root@F650A:~ # vi /usr/sbin/saf
复制代码
填入 (2021年5月更新:去除USB端口挂载判定,避免无挂载时LXC不能启动)
! A1 A$ S4 b! w. |# z  w% Y6 `
#!/bin/sh5 i/ Q) b, l: q* W# ^6 {' G& Q
# add user-defined startup scripts here, }; V4 }$ k& T) s
$ j" o& T/ Z: G; a6 W2 C
  df | grep mtdblock7: f! _0 I" p# i" u3 R( i! Y
  if [ $? -ne 0 ]* l. w) E! \) ^3 v/ J4 O9 }+ Q
    then. O# e. z* C: n4 D
      /bin/mount -n -t squashfs -o ro /dev/mtdblock7 /opt/upt/framework1
1 i9 P. Z4 a, Y  ?1 G% a: @/ [  fi
5 `8 E; v' s+ W: V3 ?0 u##
$ l* P5 c7 f' f& R
; Q8 R8 c  a. M0 w  w: g' P3 X1 g#  ps | grep ntfsmount | grep -v grep
1 P( ^, x8 |" X- R#  if [ $? -eq 0 ]
/ W  z) N" `# _" s#    then$ u$ C0 k* L0 K+ q; d* H) u
      /dbus/usr/bin/lxc-start -dn openwrt
6 B( {1 v4 A( `: z#  fi
$ `) W& j( E+ Q0 y6 ?4 @##
! N  r7 e& r& U+ Q3 K
或者在电脑编辑好内容,命名为saf,传入/usr/sbin/,'chmod +x' 添加执行权限,重启光猫。" C" i9 x3 p. a3 w

1 ^! }. y1 j- O& x2 T* Q; i8、后续问题) z5 ^( @$ I- T/ J# O$ J" h+ |, {
    目前的openwrt安装或更新程序会报错,缺少 libustream-openssl 、ca-bundle 、ca-certificates 和 libopenssl1.1,还需要修改dns,添加中文等/ G* y% F1 @+ ?+ N# ^( k% z
/ y1 p( M" L% V
  1. root@openwrt:~# opkg update
    ' j/ q2 a# U, w
  2. Downloading https://mirrors.cloud.tencent.com/lede/releases/19.07.1/targets/bcm53xx/generic/packages/Packages.gz# x: ~( ]# q, ?
  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.
    % P# `& \, }# C2 }: z( j& P
  4. *** Failed to download the package list from https://mirrors.cloud.tencent.com/lede/releases/19.07.1/targets/bcm53xx/generic/packages/Packages.gz
复制代码
这些安装包可以从腾讯的镜像站下载然后手动安装。  n# \* s; e9 K, W5 j+ b( X
  1. root@openwrt:~# cd /mnt/USB_disc1/( ^' a- \/ N; |: n+ r7 x
  2. root@openwrt:/mnt/USB_disc1# opkg install *.ipk
复制代码
修改dns# L% J3 B8 d" t+ ~$ C& D' A2 [
  1. root@openwrt:/mnt/USB_disc1# rm /etc/resolv.conf  U) k# V; _7 o9 T4 r
  2. root@openwrt:/mnt/USB_disc1# vi /etc/resolv.conf
复制代码
填入,保存
' i$ V: ?3 i. k, a$ K
nameserver      223.5.5.5* X! a0 J5 {* {1 R6 K
nameserver      8.8.8.8# o( }9 w; [. ^
nameserver      2001:da8::666

; T2 D* ?9 b4 E; q0 u$ g. i# g嫌过程繁琐的可以直接下载我配置好的镜像,从第5部分最后开始操作,将下载的openwrt-19.07.1-bcm53xx-lxc.bin和saf-lxc-start-openwrt放入光猫上的u盘,子系统默认root密码123456。8 I$ P/ A' C6 F# `4 i
  1. root@F650A:~ # dd if=/dev/mtd7 of=/mnt/USB_disc1/mtd7.bin bs=1M
    ! i. X* s2 z; X, _  \8 I) m
  2. root@F650A:~ # mtd write /mnt/USB_disc1/openwrt-19.07.1-bcm53xx-lxc.bin /dev/mtd7
    # B8 w5 I, a- p% e- E
  3. root@F650A:~ # mount /dev/mtdblock7 /opt/upt/framework1
    5 m$ A* s* C6 q
  4. root@F650A:~ # mkdir -p /usr/var/lib/lxc/openwrt7 N" F. `0 p3 I/ k( k$ V0 b4 C
  5. root@F650A:~ # cd /usr/var/lib/lxc/openwrt
    0 ^7 C6 N4 F7 `
  6. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/pre-start.sh pre-start.sh2 Z, ]3 b( U+ A# X
  7. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/config config
    & t! e3 k4 Y7 @! ^% V1 Z! X
  8. root@F650A:/usr/var/lib/lxc/openwrt # mkdir rootfs
    ' D8 l5 v* w5 ^
  9. root@F650A:/usr/var/lib/lxc/openwrt # mkdir /opt/upt/apps/openwrt-rootfs
    " d9 D& H) `# M4 m
  10. root@F650A:/usr/var/lib/lxc/openwrt # lxc-start -dn openwrt. G( F9 m+ n1 w2 a- W: S
  11. root@F650A:/usr/var/lib/lxc/openwrt # cd ~
    # I# p) a) Y9 K
  12. root@F650A:~ # mv /usr/sbin/saf /usr/sbin/saf.bak( }4 R+ @$ j5 }) X: j7 E' C
  13. root@F650A:~ # cp /mnt/USB_disc1/saf-lxc-start-openwrt /usr/sbin/saf
    " l: l: o, r0 T% C6 \5 G
  14. root@F650A:~ # chmod 0755 /usr/sbin/saf
复制代码
   虽然子系统的openwrt可以顺利运行,但经过我的测试,kmod类app大多无法正常工作。比如F650A内核不支持ext4文件系统,在子系统安装kmod-fs-ext4,尽管可以安装成功,但重启后提示 modprobe 启用ext4模块失败。
8 [# B! Z. r5 U% T# c' S        子系统的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管理页面,需要更改光猫主系统,此操作的定制空间更大,有机会的话在后面回复中整理出自定义光猫固件的思路。
6 A1 m% i; ]* Z* ~6 N3 {/ v. [6 I5 u- P3 @" 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刷进去的?
' y7 v5 b' ~9 D8 K6 F* d- h* K/ O, {/ b. d4 e中兴非15.0.1出问题是你没清理/opt/upt/apps//apps目录. r  o6 X: f7 R
几乎所有光猫为了节省空间?都会有部分lib和var目录重用主系统的文件,openwrt下e8clib和e8cvar可以看看。
* I9 q: x5 M  }+ b: _' x+ q# m# `/ h另外中兴编译的openwrt开始了uclibc的xlocale配置,这也是achaoge直接用omap源的APP无法运行的原因,我自己有手动开启xlocale后编译omap的openwrt放进去运行OK。, ]2 l" }3 X+ g- m* X
有兴趣可以一起研究玩。
 楼主| 发表于 2020-2-20 21:40:34 | 显示全部楼层
anysoft 发表于 2020-2-20 12:58
$ k3 D' d. A% J9 Z坐等lxc的教程,另外19openwrt是你自己编译的还是直接下载armv7的官方bin刷进去的?
" g/ U2 l+ x. @8 P% X( A中兴非15.0.1出问题是 ...
3 B  G$ Y( e& ]4 o9 i  q8 r% f

  R% q/ ]$ _: F1 ~: h( B1 ?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
  G% s. ]& C, `; g6 z; c, eopenwrt1907用的官方rootfs经https://github.com/mikma/lxd-openwrt修改而来;xlocale的问题我在编译主 ...
6 r9 h3 O. s' ~; D; I! R1 U
是的, 中兴使用的是buildroot-2015.8.1,这个strings 一下sendcmd 就可以看到  k5 [: _- W, P1 @
2 y+ W) J7 O# }
看了下操作步骤,其实如果内存足够,没必要关闭saf启动的天翼网关。
& e% O; j5 e+ j  e9 |! @  B# C可以让lxc容器启动两个op应该是可以的,F650A和华为hs8145V应该都是512MB内存,内存足够,openwrt可以放到apps分区文件夹下,不一定要写入mtd7再手动挂载。
% o! w2 y2 I% _! v+ G
3 p, i& q8 ]# d+ U& p3 K我的HS8145V启动后内存只占用了30%,足够了。) N9 m9 \3 t( z6 b! T
: n" L9 e: H0 N7 C
另外主系统下的usr/sbin目录下文件不是内存加载的rootfs对应的squash文件?这个更改应该不会回写到文件系统,重启应该就会消失?; P% m( X) t/ w1 I/ {) k/ o9 p
不晓得中兴和华为是不是一样的。可能中兴可以修改文件吧,华为的只能dd备份rootfs分区后自己解包修改打包后再dd写进去,会有砖的风险,砖了只能上编程器。. X0 I, ^% @& ^. U# V

+ P+ R& u8 Z; B至于端口问题可以在打包openwrt的时候先修改每个服务对应监听端口就不会冲突了。. S6 F$ r5 J3 r& z+ O$ l* u- s

本帖子中包含更多资源

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

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

本版积分规则

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

GMT+8, 2025-6-19 20:14 , Processed in 0.045155 second(s), 7 queries , Redis On.

Powered by Discuz! X3.5 Licensed

Copyright © 2001-2020, Tencent Cloud.

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