找回密码
 注册

QQ登录

只需一步,快速开始

查看: 57473|回复: 93

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

  [复制链接]
发表于 2020-2-17 02:14:04 | 显示全部楼层 |阅读模式
本帖最后由 songee 于 2022-4-27 21:04 编辑
: N& x; ~7 w3 ~. Z$ ]6 o4 g8 W: u3 {
9 v# a' U7 \) _* D- i) H. E3 R家里装宽带,电信200M,送了个中兴F650A。自带的天翼3.0web界面看着不错可惜几乎没有可玩性,闲来无事研究一番。, ~! d/ a% ?9 ]3 g* p7 _
    借鉴论坛前辈achaoge的帖子:中兴 F450A/F650A 免 TTL 持久开 ssh顺利开启telnet,发现该光猫的运作机制是 主系统负责底层的硬件驱动、sendcmd管理系统(telnet、超密、ppp拨号、网络及WiFi、ftp等)、以httpd为基础的8080端口电信web管理界面,最后启动saf(lxc容器管理)程序。
7 Z: y3 j0 W' R% y    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数据存放区,操作时需要特别注意!!
' y9 ~  y! m, Q. f
  1. root@F650A:/usr/sbin # saf# R& {* C3 A2 T: ^
  2. Usage: saf service FWK_MTD_ID1 FWK_MTD_ID2 APPS_MTD_ID (eg. saf service 9 10 7)' {" @- c, \  Z
  3. saf console# p3 |  n. k# A" s+ V  \. t
  4. saf info
    + \' B# w# P, D. C! r' u; {
  5. saf version9 e" Y. e4 e0 }# w3 v+ X- C
  6. saf getfwkver1 P  G3 P# b- ]$ X9 D; l* l
  7. saf getbakfwkver
    ! c( e/ s( q5 F+ F/ l7 q  E7 @
  8. saf getactive
    / A; v. B+ q' w- \
  9. saf setactive FWK_MTD_ID [AFTER_REBOOT] (eg. ./saf setactive 17 1)
复制代码
  1. root@F650A:~ # cat /proc/mtd6 {, ?, o. F' p3 G0 W0 Y5 T( {  Y3 m. U& J
  2. dev:    size   erasesize  name  \  c; X0 J: G7 d: Y" t5 l
  3. mtd0: 08000000 00020000 "whole flash"% _- K# d! Q; B$ G' [5 n) x
  4. mtd1: 00100000 00020000 "u-boot"" o9 v% S  R. K( P7 q( Y
  5. mtd2: 00080000 00020000 "others"
    0 \5 t5 z/ \0 U7 k
  6. mtd3: 00100000 00020000 "parameter tags"1 ^$ y2 F. B3 [+ }! u
  7. mtd4: 00100000 00020000 "wlan"$ i! h/ z/ c; U4 E# g, v% |
  8. mtd5: 00200000 00020000 "usercfg"
    7 d5 h/ j! ~: X9 j4 G
  9. mtd6: 00800000 00020000 "framework"$ J* A1 t4 w! o
  10. mtd7: 00800000 00020000 "framework1"
    / d7 |" a3 _3 q! `
  11. mtd8: 00780000 00020000 "dbus"6 w! ^1 c. C4 U. W7 ^, t
  12. mtd9: 01280000 00020000 "kernel1"
    ! O7 ~4 E& U, @* g7 ~! m
  13. mtd10: 01280000 00020000 "kernel2"* C, T: d5 M2 r* n- {( d
  14. mtd11: 03e00000 00020000 "plugin_data"
    ) |; c6 H! ^1 b" P$ B2 O8 n
  15. mtd12: 01240000 00020000 "rootfs"
复制代码

1 i9 s. O1 n# L! Z1 A    saf程序管理子系统,是通过系统的lxc容器实现的,在/dbus/usr/bin/目录下有lxc相关程序,但并非标准的官方版,而是定制的,lxc.lxcpath即lxc容器存放位置设定为/usr/var/lib/lxc,暂时没有发现更改的方法(也没什么必要)。
root@F650A:~ # ls -l /dbus/usr/bin" \" J. D$ u8 Q3 w3 C( ]( J7 ]$ T+ I
total 377
: _" \+ @, r$ q1 l3 k-rwxr-xr-x    1 root     root         10143 Nov 15  2018 dbus-cleanup-sockets
7 f: e6 O. @, z4 x6 T/ a5 _-rwxr-xr-x    1 root     root         18867 Nov 15  2018 dbus-launch
" s5 @& d, j! u+ W0 ^-rwxr-xr-x    1 root     root         22537 Nov 15  2018 dbus-monitor
. Y1 c" Q8 z1 W' {% t" m-rwxr-xr-x    1 root     root         11049 Nov 15  2018 dbus-run-session
9 M2 M9 g! B, o: y5 s-rwxr-xr-x    1 root     root         23431 Nov 15  2018 dbus-send2 o% c1 b% l5 h7 V$ f% l
-rwxr-xr-x    1 root     root         19495 Nov 15  2018 dbus-test-tool
5 E) d2 Y; ]: g-rwxr-xr-x    1 root     root         12257 Nov 15  2018 dbus-update-activation-environment( u" X. r! m  K( p5 C! s
-rwxr-xr-x    1 root     root          8365 Nov 15  2018 dbus-uuidgen0 Y. N3 q& \2 W0 U6 Y
-rwxr-xr-x    1 root     root         33112 Nov 15  2018 gdbus8 Q: O4 Y5 u) h$ o
-rwxrwxrwx    1 root     root         12332 Nov 15  2018 lxc-attach7 }) o; q6 n+ P6 F. a
-rwxrwxrwx    1 root     root         14241 Nov 15  2018 lxc-autostart1 S) K; R7 `0 [2 L' O
-rwxrwxrwx    1 root     root          9122 Nov 15  2018 lxc-cgroup
# f" c& D* g' L; L! R-rwxrwxrwx    1 root     root          4414 Nov 15  2018 lxc-checkconfig7 u- z. b1 m; K. T5 m" c( l
-rwxrwxrwx    1 root     root         10175 Nov 15  2018 lxc-clone6 ~. B6 S4 h1 I3 z* p' A% I
-rwxrwxrwx    1 root     root          6181 Nov 15  2018 lxc-config1 g3 F. o! \$ m6 k4 d% S
-rwxrwxrwx    1 root     root          8590 Nov 15  2018 lxc-console
: K1 h4 [/ g* h-rwxrwxrwx    1 root     root         14556 Nov 15  2018 lxc-create
6 m2 ]5 O9 T& a! S-rwxrwxrwx    1 root     root          8540 Nov 15  2018 lxc-destroy
$ x3 n' Q! \4 H/ W) n-rwxrwxrwx    1 root     root         10027 Nov 15  2018 lxc-execute
/ Q+ |. ^& {* G7 Z* ]-rwxrwxrwx    1 root     root          8630 Nov 15  2018 lxc-freeze6 ~( M* `+ `& x% d" v
-rwxrwxrwx    1 root     root         18956 Nov 15  2018 lxc-info
& M3 n7 K9 P% L1 O4 _) j% e-rwxrwxrwx    1 root     root          2834 Nov 15  2018 lxc-ls/ X$ ^( X9 r# @8 j: T9 f* P: c8 p$ ]
-rwxrwxrwx    1 root     root         11122 Nov 15  2018 lxc-monitor
7 o; v. H3 d. y. H, W+ A0 I-rwxrwxrwx    1 root     root         12270 Nov 15  2018 lxc-snapshot
& j. j: x+ C+ K0 [+ A0 F1 Y-rwxrwxrwx    1 root     root         15356 Nov 15  2018 lxc-start- b& ^4 i& ^) v. F
-rwxrwxrwx    1 root     root         10055 Nov 15  2018 lxc-stop4 O) }, x, R( i( }) _' n- S
-rwxrwxrwx    1 root     root          8634 Nov 15  2018 lxc-unfreeze
3 ~9 O$ A2 t% O( Y1 u-rwxrwxrwx    1 root     root         12380 Nov 15  2018 lxc-unshare
: x! J! {8 d6 U6 b, i-rwxrwxrwx    1 root     root         13324 Nov 15  2018 lxc-usernsexec* d/ {1 }$ g" b$ S$ k
-rwxrwxrwx    1 root     root          8561 Nov 15  2018 lxc-wait
  1. root@F650A:~ # lxc-config -l
    ; e8 O% @2 _/ S" e* S1 L
  2. lxc.default_config$ z1 u' U* v: N
  3. lxc.lxcpath; ^. l5 s* a' M) m5 D( I7 E1 X% `
  4. lxc.bdev.lvm.vg- `+ ]6 M; t) @9 K' R# z( x
  5. lxc.bdev.lvm.thin_pool2 d5 s$ n/ [- A; `' z9 ]
  6. lxc.bdev.zfs.root* W5 W- P7 p9 F+ o! h
复制代码
  1. root@F650A:~ # lxc-config lxc.default_config) f$ F3 n' t% B  u9 e3 ~( p' P0 G
  2. /usr/etc/lxc/default.conf+ K6 i6 Q0 @; {; ?
复制代码
  1. root@F650A:~ # lxc-config lxc.lxcpath( P" P/ d+ [; |- B8 l' }
  2. /usr/var/lib/lxc
复制代码
7 J( _& Q% C0 f# n5 @
    了解系统运作机制之后,我最初打算借用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方式开启新世界,操作步骤在本文回复中细谈。( D9 L3 ~9 q0 X/ `9 Y( T! A( ]
    经过几番折腾,已将系统原有的openwrt中兴定制版saf子系统完全替换为官方openwrt19.07.1(lxc方式启动),不影响光猫拨号且可在线安装及更新非kmod类app,如ariang离线下载,samba文件共享,甚至各类科学上网工具(性能及安全原因不推荐)。
. m1 `$ t, h) |# _% b' v2 b* j" K# z! h

6 c( x2 D$ H7 ^/ j  `' T6 G9 J0 m

- Z2 l; O# i8 h7 K; a
5 v0 l* F6 T2 G
2 A' V: P+ O/ S% `, z) p! {3 R* M& V' d# g1 x. T" p

本帖子中包含更多资源

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

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

简化并更新OpenWRT22.03.0 RC1版本

本帖最后由 songee 于 2022-4-26 23:39 编辑
4 u, x! T% b* m- W/ a% f
- i( N2 `& {2 U- _5 M因二楼原帖过程过于繁琐,近期尝试了一种较为简单的办法。, T/ z) {4 c7 P- z# O0 d/ {
. }  D; o: L( y
6 @/ ?8 P3 t) D/ E
1、下载openwrt.org固件,我选的是openwrt-22.03.0-rc1-bcm53xx-generic-tenda_ac9-squashfs.trx,binwalk分析squashfs偏移量并用dd取出,unsquashfs提取rootfs,打包为rootfs2203rc1.tar.gz,传入光猫临时目录,如 /run/shm 。& M* F$ x) ]2 X+ H; [
2 |0 F' }( b/ Y" @! R
2、将rootfs2203rc1.tar.gz提取至 (lxc-config lxc.lxcpath)/openwrt/rootfs 。8 E; o7 Y+ m8 ]# B. \! n' n
  1. root@F650A:/usr/var/lib/lxc/openwrt/rootfs # tar -xzvf /run/shm/rootfs2203rc1.tar.gz -C ./
复制代码

9 z* o" S- t+ X3 a7 [. X0 j# g: q' K0 `" i
3、修改rootfs。openwrt的网络配置与主系统有冲突,需要清除。1 E9 R! {9 \8 x! b' Y$ o
    3.1 移除 ./etc/board.d/ 目录下 01_leds 、02_network 、99-default_network 三个文件。2 o+ Z4 i# {8 c# l) W+ a8 w1 e
    3.2 移除 ./etc/rc.d/ 目录下 K21wpad 、K85odhcpd 、K90network 、S19dnsmasq 、S19firewall 、S19wpad 、S20network 、S35odhcpd 、S96led。% I, o+ [! O9 R& H% d( m
    3.3 移除 ./etc/modules.d/ 和 ./etc/modules-boot.d/ 及 ./lib/modules/5.10.111/目录下所有文件,openwrt的kernel modules与光猫内核不兼容。. G8 r: Q* Q0 D' f  z9 z$ o; t

4 g2 {; m/ q# ^3 c: X    3.4 修改opkg源 ./etc/opkg/distfeeds.conf(可选)/ {* {. |" h7 [- H2 ?% F6 X8 e
  1. src/gz openwrt_core https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/targets/bcm53xx/generic/packages1 N" G/ a' s4 Y; k& A6 v) t$ r1 M
  2. src/gz openwrt_base https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/base) r  {2 s" r9 j, h' g
  3. src/gz openwrt_luci https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/luci9 y, d4 a# s( W1 B% ^
  4. src/gz openwrt_packages https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/packages$ ?0 n# i2 n: e
  5. src/gz openwrt_routing https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/routing
    # Q: M' n) R# q3 w9 A
  6. src/gz openwrt_telephony https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/telephony% I7 {0 B" d2 @% X' w
复制代码
  3.5 修改 ./etc/inittab 实现启动项自启(参考https://github.com/mikma/lxd-ope ... r/files/etc/inittab
/ e& J* `4 w, J- ~9 z1 ^+ L# J& Z
  1. ::sysinit:/etc/init.d/rcS S boot% `6 A% h0 z, e! g* Q. Q' w, C5 H
  2. ::shutdown:/etc/init.d/rcS K shutdown
    - t5 Z" `4 w4 h1 d0 g+ c
  3. console::askfirst:/usr/libexec/login.sh
复制代码
  3.6 修改密码 ( root 密码 chinadsl
. q7 d+ b3 i5 N0 f" _# \7 f- e& {8 X
  1. root@F650A:/usr/var/lib/lxc/openwrt/rootfs # chroot ./
    8 t2 O& x) W1 [# V

  2. 3 w  _$ b8 R, H

  3. 4 X9 a* X+ h( x  Y
  4. BusyBox v1.35.0 (2022-04-20 10:37:37 UTC) built-in shell (ash)
    9 ^# u* Q, z. @- `# j
  5. - \7 Q" k2 r. l2 `& E/ b
  6. root@F650A:/ # passwd
    . _. f0 J. p2 b$ K' \; X* [
  7. Changing password for root
    . u* m; u6 o- M
  8. New password:$ `% C# P" _- x& o9 u' g4 x
  9. Bad password: too weak
    $ x& s7 g1 z& V3 K2 l3 }6 w& a
  10. Retype password:
    3 s7 M  @" a; H) w( a
  11. passwd: password for root changed by root
复制代码
  3.7 删除 ./etc/resolv.conf 软连接并新建./etc/resolv.conf,否则openwrt无法解析域名  ^( E+ K! w2 V: b# C
  1. nameserver 223.5.5.5
    , H" @- J, A& l' k
  2. nameserver 2001:da8::6662 {6 R% x- |8 z; a7 @& C1 p
复制代码
& o9 r- j+ e/ A) _* z, L! {0 e
3 U! M1 ]: }' b' ~* m
4、修改lxc配置文件 /usr/var/lib/lxc/openwrt/config ,根据各自光猫环境修改测试,这个配置我的F650A可正常使用。
  I3 w! }# s% n- Y/ g8 v; U4 j
  1. lxc.arch = arm! ?! H! E# G' Z* q  s
  2. lxc.utsname = openwrt0 ^9 A: M! X% P5 N6 `6 A+ M
  3. #lxc.rootfs.mount = /usr/var/lib/lxc/openwrt/rootfs
    2 Z5 r9 |, z- {! K  u
  4. #lxc.rootfs.path = overlayfs:/opt/upt/framework1/rootfs:/opt/upt/apps/openwrt-rootfs: W* U% S" |+ q$ _/ K& X
  5. lxc.rootfs = /usr/var/lib/lxc/openwrt/rootfs
    & ]5 {3 ?; m; f' _
  6. lxc.haltsignal = SIGUSR1. W6 w( @1 @# |, Z# e% v, q* ~% F
  7. lxc.tty = 1
    + ~  d: J3 I- F6 `4 ^# M; _& l
  8. lxc.pts = 1
    , ~8 q' Q* m) N2 o5 D, B
  9. #lxc.hook.pre-start = /usr/var/lib/lxc/openwrt/pre-start.sh
    / }6 J# e5 A, d  X
  10. lxc.aa_profile = lxc-container-default-with-nesting2 B: }( e1 l) J" |3 W/ w
  11. lxc.network.type = none
    & I7 s9 \0 f6 ?+ G
  12. lxc.mount.auto = cgroup-full:rw
    / I' ]4 b: G7 g- S
  13. #lxc.mount.auto = proc sys cgroup
    5 l. S. X' r% ?# n
  14. lxc.mount.entry = sysfs sys sysfs defaults 0 0
    $ |" ?  C9 t2 N2 ?1 q0 p9 t/ ^
  15. lxc.mount.entry = proc proc proc defaults 0 0
复制代码

. C% s1 |  e! P3 m" D! Q5 t# Z* V! L5 U3 e' m
5、启动,根据提示按enter进入控制台。  s! i2 M/ H. K0 L! U' C0 u
  1. root@F650A:~ # lxc-start -n openwrt5 o" y* v6 t0 X$ ^
  2. <6>init: Console is alive! m$ n  C, Z) O/ F( i( s* @: V. N  x7 A
  3. <3>init: Failed to redirect stdin to /dev/null: No such file or directory# i: D  K5 p7 h) n! p1 r' r2 h
  4. <3>init: Failed to redirect stdout to /dev/null: No such file or directory
    - A( o# V  m- C! E
  5. <3>init: Failed to redirect stderr to /dev/null: No such file or directory
    & Z$ M8 B+ ~6 F. A+ v% T
  6. <6>kmodloader: loading kernel modules from /etc/modules-boot.d/*
    ! M1 G2 S" T5 S% ~5 N
  7. <6>kmodloader: done loading kernel modules from /etc/modules-boot.d/*
    3 K8 f% a% j, U- F4 x$ \
  8. <6>init: - preinit -
    ) L6 G# {. z, u8 T0 ~
  9. ls: /etc/board.d/*: No such file or directory
    ) t2 C* h2 w# r. u3 f! }% C" K. B6 k
  10. Press the [f] key and hit [enter] to enter failsafe mode4 l* g3 O* j- V. y  l& E- ^
  11. Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
    1 I( v3 |- l8 B. D
  12. <3>mount_root: Could not open mtd device: /dev/mtd12
    7 K; x% H! Q  E" v( l$ [; h
  13. <3>mount_root: reading rootfs failed7 B7 Y! x1 U/ k9 i+ x7 W: V
  14. <5>mount_root: mounting /dev/root
    1 S$ S) k3 m* ?1 e) g  K
  15. urandom-seed: Something is wrong with /dev/urandom
    / f1 I- D* L1 m5 k2 I
  16. <6>procd: - early -
    ' g, n3 f) A) q6 `
  17. <6>procd: - ubus -
    7 L# K# r( V/ \9 p! P0 m# _; ^
  18. <6>procd: - init -
    5 C8 H- T7 `$ b9 t7 e: e8 _; L+ ?
  19. Please press Enter to activate this console.) D' D- x) f0 A- W2 A7 x
  20. <6>kmodloader: loading kernel modules from /etc/modules.d/*
    2 D/ w- j$ c2 v/ Z4 q
  21. <6>kmodloader: done loading kernel modules from /etc/modules.d/*$ n& H* s1 Q- s$ i( L, v5 L; W
  22. <6>urngd: v1.0.2 started.
      E% X9 @5 j; v  B% R- O5 W
  23. ! c5 d9 A* A$ \6 x0 G3 j, l/ |
  24. 7 }% e0 H6 x, h+ \

  25. & G: f8 @7 n( j+ [& W
  26. BusyBox v1.35.0 (2022-04-20 10:37:37 UTC) built-in shell (ash)
    ; a0 R8 G2 {4 P: S" c
  27. ' ~+ k, g8 N$ K% W  `+ t0 x- q
  28.   _______                     ________        __
    7 m, B: Z& U, j" D( K/ Z
  29. |       |.-----.-----.-----.|  |  |  |.----.|  |_
    6 e1 H, H2 U6 l: ^3 D
  30. |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
    , P7 C; Z( i; U6 l2 M6 n
  31. |_______||   __|_____|__|__||________||__|  |____|
    . g2 f9 b% i' U
  32.           |__| W I R E L E S S   F R E E D O M- U/ k. p, y7 ~9 W7 x2 z
  33. -----------------------------------------------------
    $ j" S9 E( j0 }( \6 v  ?
  34. OpenWrt 22.03.0-rc1, r19302-df622768da
    6 w* z0 [; \' w+ {4 N+ N  A5 R
  35. -----------------------------------------------------
    ) }7 l) c1 Q* }4 F5 B
  36. root@openwrt:/#
复制代码
0 T( \2 \6 y7 U" Z6 R

# F8 M0 s  ^1 D3 m! s  N
  1. root@openwrt:/# ps. C! O0 e' t+ h- E
  2.   PID USER       VSZ STAT COMMAND
    ( n+ [' L6 A: D. F
  3.     1 root      1452 S    /sbin/procd- v# m$ a# ~7 h  g0 y
  4.    58 ubus      1112 S    /sbin/ubusd) j4 z* V9 n) s% k' w. H' g4 \
  5.    59 root      1196 S    /bin/ash --login
    , s- ]. ~% H8 n; F. Q; l6 j# ~8 T
  6.    93 root       908 S    /sbin/urngd
    ; M7 x* P, M. e
  7.   204 root      3736 S    /usr/sbin/uhttpd -f -h /www -r OpenWrt -x /cgi-bin -u /ubus -t 60 -T 30
    / r+ G8 g* T3 ^1 A0 x* m0 d
  8.   487 root      1952 S    /sbin/rpcd -s /var/run/ubus/ubus.sock -t 30% P, J3 T9 H' Q) W
  9.   556 root       956 S    /usr/sbin/dropbear -F -P /var/run/dropbear.1.pid -p 22 -K 300 -T 3
    4 x: {% s, N3 c9 l1 u
  10. 1065 root      1200 R    ps
    4 k+ C. t3 l2 @" ]7 f# K. a& |# V
  11. root@openwrt:/#
复制代码
9 m2 B( s( n+ @+ M
1 T0 q" x8 L; l
  1. root@openwrt:/# opkg update
      Q# r2 X, k7 G  B/ V; u' n
  2. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/targets/bcm53xx/generic/packages/Packages.gz% u. |' e6 `2 s: m7 a0 F3 k
  3. Updated list of available packages in /var/opkg-lists/openwrt_core" @$ U0 O- U* \
  4. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/targets/bcm53xx/generic/packages/Packages.sig
    . }7 r( D& O! z0 r
  5. Signature check passed., Y8 t% Z7 x/ c2 q5 |7 }3 N; K
  6. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/base/Packages.gz2 L2 G: J1 v4 o) v3 z( z; l' {, K
  7. Updated list of available packages in /var/opkg-lists/openwrt_base
    4 s1 v1 ^: {* q+ E5 l6 m
  8. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/base/Packages.sig: N2 y8 O* X) D! S6 \5 i9 M
  9. Signature check passed.
    6 u6 ^. D2 J8 z
  10. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/luci/Packages.gz
    9 p3 q% y, [5 g5 I0 P) p! h
  11. Updated list of available packages in /var/opkg-lists/openwrt_luci
    ; T6 t0 f( K) `; a# P0 h  {. Z: ]- ^
  12. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/luci/Packages.sig; e- N2 P+ F. @' L# E
  13. Signature check passed.
    2 T- B$ X9 s9 e8 |% V
  14. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/packages/Packages.gz
    " Y; _4 r9 S/ J! C/ j# f
  15. Updated list of available packages in /var/opkg-lists/openwrt_packages* }9 O1 r% U9 x/ z( p, m( F
  16. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/packages/Packages.sig3 O, z# q7 F& m  ~
  17. Signature check passed.
    * ^& I* S) _& i+ a) i. i$ n
  18. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/routing/Packages.gz- {$ n+ g! Y, b+ l2 C1 E) ]
  19. Updated list of available packages in /var/opkg-lists/openwrt_routing
    / N9 ^( m$ h# t: ?& o% C
  20. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/routing/Packages.sig
      b" x( C# A8 w4 L! \
  21. Signature check passed.; R2 e- G9 e9 M2 r
  22. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/telephony/Packages.gz
    # J& [+ @0 {! |# Q2 }' Z  o
  23. Updated list of available packages in /var/opkg-lists/openwrt_telephony. P% X: b0 g: J3 v! M# U( I
  24. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/telephony/Packages.sig/ X' {' i7 g, N; E/ B+ f
  25. Signature check passed.
    $ J6 d* t: a0 C4 i
  26. root@openwrt:/#
复制代码
! a* G/ s- F- P* N2 D" u, a; ?# T
/ K3 j0 p3 w+ m, }. D
此时临时的openwrt系统已建好,运行的服务有两个:http占用主系统的80和443端口,ssh占用22端口。
4 b' d$ M( K1 ]9 F3 ~( z( F% M5 a' v) I+ F& v' p4 n
如果光猫有公网IP,请务必关闭ssh密码登录并使用密钥。
3 U' D% H- ^8 ~  R) [) [; U
/ q' ]/ S9 `0 I9 n, K+ c后期使用建议使用 lxc-start -dn openwrt 后台启动,使用 lxc-stop -kn openwrt 命令关闭。openwrt管理使用ssh密钥登录。
+ r) x. z/ w6 B5 B" `需要固化openwrt到固件的,可以打包rootfs和config(需修改配置),mksquashfs制作成squashfs,用mtd写入saf分区,就不用担心恢复出厂设置了。
+ s0 E6 x7 F+ V% J+ s随光猫启动可以参考二楼。
1 Y) l$ j) J! ?6 g$ y0 b- V
3 M0 e! t% O( u+ e

本帖子中包含更多资源

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

×
 楼主| 发表于 2022-4-27 23:10:13 | 显示全部楼层
因光猫原系统的busybox功能不完整,也没有nano和dropbear,调试lxc可能会不方便,现分享出来。' S% T: U* X; S, A# d+ D! W

& N7 y* X& O5 U( R1 |# R# `
  1. root@F650A:~ # /usr/bin/busybox
    ) I6 q  c0 N0 L3 O1 E1 d
  2. BusyBox v1.23.2 (2020-06-16 16:53:26 CST) multi-call binary.$ l9 b% H: q9 s! T; x  y0 @
  3. BusyBox is copyrighted by many authors between 1998-2012.
      ^4 m- Z8 I4 _. L& O
  4. Licensed under GPLv2. See source distribution for detailed. U! r% V8 \2 s! I8 }  G
  5. copyright notices.8 Y2 `. P" s, O4 J

  6. & g% |9 [% U8 j1 y# \/ a% _5 T
  7. Usage: busybox [function [arguments]...]
    . ~3 w6 I: t& l  K# X
  8.    or: busybox --list[-full]+ y/ W) B# |) r% C
  9.    or: busybox --install [-s] [DIR]
    4 u# K7 f/ l4 w6 D/ @* |
  10.    or: function [arguments]...
    5 a/ S  s5 F5 o

  11. + M; {- m4 ?9 P2 G
  12.         BusyBox is a multi-call binary that combines many common Unix
    & l2 n3 p! \, k, ^# x
  13.         utilities into a single executable.  Most people will create a
    ' d3 q- R! B" q- H* z0 V+ q
  14.         link to busybox for each function they wish to use and BusyBox
    8 g8 \: U8 ~. c" f1 z/ P4 X9 k+ G7 [
  15.         will act like whatever it was invoked as.' E( F, S% O: b( E7 a* q3 a

  16. ) A  ?) s* B$ @! c! P
  17. Currently defined functions:
    + z& p0 A' \# Q- O9 A3 ^
  18.         [, [[, addgroup, adduser, ar, arp, arping, ash, awk, basename, blkid, brctl, bunzip2,' O$ n+ x9 A9 v# F( t
  19.         bzcat, cat, catv, chattr, chgrp, chmod, chown, chroot, chrt, chvt, cksum, clear, cmp, cp,: q0 k5 A- p9 k4 P( @
  20.         cpio, crond, crontab, cut, date, dc, dd, deallocvt, delgroup, deluser, depmod, devmem, df,
    0 G  u& Y3 n* A; P3 O
  21.         diff, dirname, dmesg, dnsd, dnsdomainname, dos2unix, du, dumpkmap, echo, egrep, eject, env,7 i4 q' a; ^* ?' b
  22.         ether-wake, expr, false, fbset, fdflush, fdformat, fdisk, fgrep, find, flock, fold, free,
    ' e+ I2 e$ i% [$ F- i! x. Q- E; i
  23.         freeramdisk, fsck, fstrim, fuser, getopt, getty, grep, gunzip, gzip, halt, hdparm, head,/ K3 n" B8 \7 r2 b( b* l
  24.         hexdump, hostid, hostname, hwclock, id, ifconfig, ifdown, ifup, inetd, init, insmod,
    % d: H+ }$ L% q0 q- H
  25.         install, ip, ipaddr, ipcrm, ipcs, iplink, iproute, iprule, iptunnel, kill, killall,
    , ]- j; O0 m1 |# G
  26.         killall5, klogd, last, less, linux32, linux64, linuxrc, ln, loadfont, loadkmap, logger,6 S1 b! E& M" Q6 e
  27.         login, logname, losetup, ls, lsattr, lsmod, lsof, lspci, lsusb, lzcat, lzma, makedevs,5 g; K' N' {1 h! k9 U# a
  28.         md5sum, mdev, mesg, microcom, mkdir, mke2fs, mkfifo, mkfs.ext2, mknod, mkswap, mktemp,# l) E: b! P3 x# C! t
  29.         modinfo, modprobe, more, mount, mountpoint, mt, mv, nameif, nanddump, nandwrite, netstat,; _  c% V" C* w0 i$ n5 l
  30.         nice, nohup, nslookup, od, openvt, passwd, patch, pidof, ping, pipe_progress, pivot_root,* ^' t2 Z3 I: L6 K8 g
  31.         poweroff, printenv, printf, ps, pwd, rdate, readlink, readprofile, realpath, reboot,
    " T" ?7 t8 j. [* X2 `
  32.         renice, reset, resize, rm, rmdir, rmmod, route, run-parts, runlevel, sed, seq, setarch,* i( n  h( d: {3 c
  33.         setconsole, setkeycodes, setlogcons, setserial, setsid, sh, sha1sum, sha256sum, sha3sum,
    ! w7 U3 F* d7 J& q$ u
  34.         sha512sum, sleep, sort, start-stop-daemon, strings, stty, su, sulogin, swapoff, swapon,% B; Q# B: w% v, q2 \. s; p( o' a
  35.         switch_root, sync, sysctl, syslogd, tail, tar, tee, telnet, telnetd, test, tftp, time, top,2 i) ^" q. W! ?6 }. X
  36.         touch, tr, traceroute, traceroute6, true, tty, ubiattach, ubidetach, ubimkvol, ubirmvol,
      \; [( ~7 x2 D8 ]7 d5 Y  V
  37.         ubirsvol, ubiupdatevol, udhcpc, umount, uname, uniq, unix2dos, unlink, unlzma, unxz, unzip,! q2 O$ n/ b6 ~( R# N
  38.         uptime, usleep, uudecode, uuencode, vconfig, vi, vlock, watch, watchdog, wc, wget, which,
    ' F: Z2 w8 x9 O4 A& k$ J) b
  39.         who, whoami, xargs, xz, xzcat, yes, zcat$ t7 ~( n8 [5 S! {
  40. 1 s# d% v8 B- C! A8 c5 P( i8 F
复制代码
  1. root@F650A:~ # nano -h3 O0 F) o4 \5 v* f
  2. Usage: nano [OPTIONS] [[+LINE,COLUMN] FILE]...: F8 B6 a4 m9 V" ?- L
  3. 3 T# a4 S- p! R. _
  4. Option          GNU long option         Meaning$ q2 z: f4 E/ P" d2 K" t8 f
  5. +LINE,COLUMN                           Start at line LINE, column COLUMN! b4 W, I% g5 t9 F5 v0 D8 F
  6. -D             --boldtext              Use bold instead of reverse video text: a' c3 e$ _( O  `8 C" q6 l
  7. -K             --rebindkeypad          Fix numeric keypad key confusion problem" e# T: d. C  S0 l! E8 p
  8. -L             --nonewlines            Don't add newlines to the ends of files) l8 n/ X% t7 b" R1 u7 ]
  9. -O             --morespace             Use one more line for editing
    ; c1 t" \( s! S5 \8 a9 l. `
  10. -R             --restricted            Restricted mode
    $ q0 T) s5 y& |+ [2 |5 h( o
  11. -T <#cols>     --tabsize=<#cols>       Set width of a tab to #cols columns! M& O- q0 v# Q- M) d; s( Q( U. P
  12. -V             --version               Print version information and exit
    9 }+ h4 \- R. n1 y
  13. -c             --const                 Constantly show cursor position
      v8 F. N7 ]1 X/ l# i
  14. -d             --rebinddelete          Fix Backspace/Delete confusion problem1 Q- t! W0 o3 w
  15. -h             --help                  Show this help text
    / q( D; [7 D: E3 K( V
  16. -l             --nofollow              Don't follow symbolic links, overwrite: d1 a) ^; f* E( N
  17. -n             --noread                Do not read the file (only write it)+ p0 g0 s+ n$ B. A" U) v1 A4 t
  18. -p             --preserve              Preserve XON (^Q) and XOFF (^S) keys
    ' U, c3 `8 ?- t1 ^  z8 k: C
  19. -t             --tempfile              Auto save on exit, don't prompt. Z# y5 W* P5 d2 N0 B1 B  T* @1 }
  20. -v             --view                  View mode (read-only)
    , ?' a  d9 K/ L- |$ i. o
  21. -x             --nohelp                Don't show the two help lines
    . F# C* ?4 h, L; G) m2 L
  22. -z             --suspend               Enable suspension
    / A: I) B$ h5 `/ c7 ?: |
  23. root@F650A:~ # nano -V" ^$ `) _9 s5 G! r# m
  24. GNU nano, version 2.4.2; m0 j; {, T% i5 j
  25. (C) 1999..2015 Free Software Foundation, Inc.
    3 l, T" S5 ?0 {. [
  26. Email: nano@nano-editor.org    Web: http://www.nano-editor.org/
    3 ~: ^: B0 a2 `7 V
  27. Compiled options: --enable-tiny --disable-utf8: u/ X- L4 }& e6 n5 d
复制代码
  1. root@F650A:~ # dropbear -h9 j, N# c8 ]3 w6 N* t$ p, {+ K+ p
  2. Dropbear server v2015.67 https://matt.ucc.asn.au/dropbear/dropbear.html! R) F' S4 b1 ~. }
  3. Usage: dropbear [options]
    . q# Y7 p- D) n* W$ b
  4. -b bannerfile   Display the contents of bannerfile before user login
    ' S3 j2 V8 o. k( @, o
  5.                 (default: none)
    - U2 Q+ n8 b4 v# G
  6. -r keyfile  Specify hostkeys (repeatable)
    8 e8 Y- x8 Q# w) H2 ]
  7.                 defaults:! T5 B0 ^; _+ D# f* M7 Z5 c
  8.                 dss /etc/dropbear/dropbear_dss_host_key
    * I5 v' ]# K; r3 B* Z) x" r2 z6 E( |
  9.                 rsa /etc/dropbear/dropbear_rsa_host_key7 \2 n1 M& f% w5 E7 F9 d6 z$ O2 d
  10.                 ecdsa /etc/dropbear/dropbear_ecdsa_host_key& a* ]% l1 h5 A- W
  11. -R              Create hostkeys as required) |/ v. w' Q' W5 k) F
  12. -F              Don't fork into background
    % ?9 C$ a6 p0 r8 X, z* M& s- ]
  13. -E              Log to stderr rather than syslog; B+ T: V8 l. L: y
  14. -m              Don't display the motd on login
    7 x5 O$ G- J1 q6 \9 Z7 _, S
  15. -w              Disallow root logins7 Q$ N3 O5 l/ q3 Y4 Q5 b
  16. -s              Disable password logins
    % v; X/ e& Q9 m' M
  17. -g              Disable password logins for root
    2 B; ^2 ]/ N7 k- M: `
  18. -B              Allow blank password logins
    9 V6 n& E- b4 y7 Y- `5 ]2 @' h
  19. -j              Disable local port forwarding/ c) a: o* N: N! U5 Z6 r' h0 J
  20. -k              Disable remote port forwarding3 C; z3 n3 ?. u" T0 g
  21. -a              Allow connections to forwarded ports from any host- P1 S' ]+ @- O! D( g
  22. -p [address:]port
    2 S; Z% k% n6 ]3 w
  23.                 Listen on specified tcp port (and optionally address),
    - t% x. P5 C. @5 \
  24.                 up to 10 can be specified
    " O2 T5 O6 J& z
  25.                 (default port is 22 if none specified)6 g+ W$ u6 Z: l& u$ c7 t
  26. -P PidFile      Create pid file PidFile0 N0 T2 d  I( d/ W  A
  27.                 (default /var/run/dropbear.pid)3 ^+ r: m) r7 r, {, x  z( \8 e$ Y+ p6 I: R
  28. -i              Start for inetd/ d7 i# I8 o$ l; Y6 m5 o' F
  29. -W <receive_window_buffer> (default 24576, larger may be faster, max 1MB)
    ! b5 i) d, ?: M
  30. -K <keepalive>  (0 is never, default 0, in seconds)
    6 {  [/ [, u+ Y
  31. -I <idle_timeout>  (0 is never, default 0, in seconds)
    + O7 Y0 l. ]2 q; p
  32. -V    Version1 a3 R0 v  S6 c+ U/ G
复制代码

* y2 Y; ?9 w- U
! u5 N7 e! [" }3 {" V/ t. s7 s6 v

本帖子中包含更多资源

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

×
发表于 2021-11-27 21:38:54 | 显示全部楼层
本帖最后由 btworm 于 2021-11-27 21:41 编辑 3 d& b) Z# |: \* p
songee 发表于 2021-11-27 04:15
4 o; s* k1 x/ E! D+ f# d* m5 c1.只要lxc相关命令可以正常运行,写好配置文件,选择符合CPU架构的rootfs,就可以把容器跑起来。
) S7 P5 ]3 K8 |8 R9 v2.我的 ...

9 f5 b  [5 \5 j9 A4 f感谢指点!
# a* \1 b$ s9 V" Y
* E  f! B! |4 M关于第2点
/ y3 ^4 A& Z3 t* ]6 c; G) ?% w5 H华为光猫 / 只读,/etc,/usr,/lib这些目录也都依附于/, 所以都不可写, /opt目录不存在,当然也无法创建。
0 a% I: P9 A" d3 k) S, G6 k8 Y2 _* d) }6 k3 G! \
之前担心/dev/pts, /proc, /sys只读,是因为以前玩路由器时,有个chroot脚本使用过这些目录,刚又看了遍那个脚本,使用的是 "-o bind"参数,所以主机目录是否可写就无所谓了。在华为猫上跑lxc应该没问题了, y! Y) O1 z' B2 V* U3 O

1 y1 a( r  L# r/ k; Z- p% ?另外想问问,光猫容器内的应用对端口的监听是:! n" h- L; a6 {& y& B( j, Q
1.直接监听光猫的端口?) O) t# d1 p3 }4 }7 h
2.还是只能监听容器内的端口,并需要光猫iptables做端口转发给容器?

点评

有问题,根本找不到可以启自己进程的入口,只能利用已有的容器  详情 回复 发表于 2022-1-29 22:18
标准的容器支持多种接口类型,例如桥接或者NAT,但是有些光猫的lxc被厂家修改过。像我的这台F650A,我没有找到配置接口的方法,在config里的接口设置是“none”,实际效果是容器完全使用了宿主机的全部网络接口,所  详情 回复 发表于 2021-12-27 23:16
 楼主| 发表于 2020-2-22 18:37:10 | 显示全部楼层
anysoft 发表于 2020-2-22 17:50* n5 t7 g" _( U. O; ?9 l
HS8145V HS8145V5  F650A 都是512MB+256MB 2.4G+5G方案
& v; C$ r# M% \  u: v5 c5 f价格都还好,特别F650A 因为会玩的人少价格特别便 ...

  z  y) _, }! R. s( O; U: Zhs8145v技术成熟,更适合玩,而且其实f650a是512/128,nand flash少了一半,CPU一个尿性,价格差别不大的话,能hs8145v还是别选650。
; I4 c% l9 [6 f8 ]还有个大胆想法,lxc可以通过配置文件config修改子系统网络,从eth0桥接是不是就能在子系统多拨了,子系统专门离线和网络存储,不影响猫后面接的手机电脑上网,还是蛮有趣的4 i2 N0 @, A/ @" _! v# h

: P7 ?6 P# ?8 c; W% L
/ j7 u5 \' V* V, e& |
3 O; X  b/ z# T6 u0 A, M

点评

想加个好友交流的,回复被站长直接删了.....Q 2 7 5 0 3 5 3 0 0  详情 回复 发表于 2020-2-25 10:25
 楼主| 发表于 2020-2-17 02:19:26 | 显示全部楼层

二楼原帖,仅保留做参考

本帖最后由 songee 于 2022-4-27 21:17 编辑 8 S% {, b% |, z. l4 I# ^$ y+ E% C
8 _  p3 E+ ]# X$ I0 A( R- [9 h
) _" X' B" B9 L9 D! r
(2020年原帖初步摸索,过程过于繁杂,不建议再按这部分思路操作)
( {  c+ m% s& p- |( I中兴、华为等带有saf模块的光猫,以官方版openwrt替换厂商定制版的思路总结一下,供大家参考。7 B. D. Z8 U, P) [# D/ U$ {6 D
1、准备工具
0 f" \6 v0 S' T- k; s7 y    F650A主系统没有 mtd 、 dd 和 vi 等工具,而自带的saf子系统正好都有,子系统位于framework分区即mtd6,挂载于/opt/upt/framework,cp过来可以直接使用。
root@F650A:~ # cp /opt/upt/framework/saf/rootfs/sbin/mtd /usr/bin/
0 [4 x0 a* D+ ^- `$ Broot@F650A:~ # cp /opt/upt/framework/saf/rootfs/lib/libubox.so /lib/
- A' s4 ?' S' p3 d* nroot@F650A:~ # cp /opt/upt/framework/saf/rootfs/bin/busybox /usr/bin/4 A( d- Y) e4 Z" C  [
root@F650A:~ # cd /usr/bin/5 W* o: P4 Q+ [' \1 o
root@F650A:/usr/bin # ln -s busybox dd$ A7 F' W5 X+ v: Z( L9 u  ]
root@F650A:/usr/bin # ln -s busybox vi
! Z1 x* H8 A- X' o" Y
2、改进lxd-openwrt生成代码。- }  y, f$ o6 U% l
    本节参考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如下8 R  ?' A' e: P$ H  L+ m
*** build.sh                2020-02-19 01:50:10.972675562 -0100- r. P8 F1 H' x( Q) S1 T$ \2 r
--- build.sh.origin        2020-02-14 19:10:45.000000000 -0100
; p4 c: h# B5 G***************4 j. t' W( N" Z8 q
*** 72,81 ****8 f6 |. [3 D2 P/ h- L( W
                  subarch=64% P# k2 o2 z# M, c
                  arch_ipk=x86_64
. P$ P5 C  Y2 d' V9 c$ D7 J                  ;;
! ?6 J, r. V( X!         arm)
" l2 n0 w  C) r0 N!                 arch=bcm53xx; u: L8 y6 G6 A3 ?1 c4 h
!                 subarch=generic
) f$ n& Q2 `1 |: h6 m!                 arch_ipk=arm_cortex-a9% V! J5 @3 {% ?
                  ;;
2 s& e, P" [8 s( A) L          *)% K- f' b0 _, z' E7 I2 N( F- z
                  usage
9 d, n6 |, l" K" R--- 72,81 ----
7 h+ N1 L! E. t) K( n0 K                  subarch=640 B# D# T* y% U/ a' n1 @1 g
                  arch_ipk=x86_64
" i. |4 J4 T& O: [                  ;;0 L( o4 X/ R/ Q1 n
!         aarch64)0 J1 A0 a% p  P2 A% f5 G; c
!                 arch=armvirt
* E: z6 I, K. ]!                 subarch=64
* m- D  i  ]8 v5 ?% c/ q) h. P!                 arch_ipk=aarch64_generic
# N: @2 l% [, R                  ;;
. E8 p; J7 q/ g: L6 b, b          *): q* {) S( B: F
                  usage
% b6 n& P7 s! ^2 `3 \/ e1 ]* Q+ D***************
) E2 }; ^' L( ]7 A6 v*** 87,97 ****& ^" J8 m+ O, g. ?0 S3 ?: u
  if test $ver = snapshot; then
3 `4 ]3 a2 x# D! m8 T8 _" x          openwrt_branch=snapshot
4 G1 N) i4 R3 D& a          procd_url=https://github.com/openwrt/openwrt/trunk/package/system/procd1 \. J+ K  O. d' q3 N
!         openwrt_url=https://mirrors.cloud.tencent.com/lede/snapshots/targets/${arch}/${subarch}2 L9 t$ j7 F6 \1 c0 N2 r4 y8 L
  else1 j6 B1 I; \; h# ]( }$ }) t: x3 o) w
          openwrt_branch=${dist}-${branch_ver}, f" D$ q/ T0 c4 G
          procd_url=https://github.com/openwrt/openwrt/branches/${openwrt_branch}/package/system/procd
! @1 C' ~& u; w) y!         openwrt_url=https://mirrors.cloud.tencent.com/lede/releases/${ver}/targets/${arch}/${subarch}
( ~2 _  v& x7 y' A8 S5 h7 W5 B  fi- C4 ^/ C! e% k7 J$ ~
  
. D% W7 n8 p1 r! A  procd_extra_ver=lxd-3
: n) J" Y6 L5 n$ {--- 87,97 ----
9 E1 L/ ?4 @/ a  if test $ver = snapshot; then
3 w! f: `. g7 G8 \  i          openwrt_branch=snapshot' K) G/ i# _0 X' \1 j
          procd_url=https://github.com/openwrt/openwrt/trunk/package/system/procd* p; i$ }% d8 h# V* _2 b0 X6 F
!         openwrt_url=https://downloads.openwrt.org/snapshots/targets/${arch}/${subarch}% g9 |) b8 P% V: y
  else
+ F- x" D8 i0 p7 y+ j4 w          openwrt_branch=${dist}-${branch_ver}; C# g$ \, x- [+ S
          procd_url=https://github.com/openwrt/openwrt/branches/${openwrt_branch}/package/system/procd# D4 e1 R8 j, c5 t- F$ x# e: r
!         openwrt_url=https://downloads.openwrt.org/releases/${ver}/targets/${arch}/${subarch}
+ x% N% ]6 i" |9 h& P  fi
* ]% {9 n' q8 U7 q  
; A) T" B) ?- \. H  procd_extra_ver=lxd-3
( n9 D) N. e, h; M  a: ]% q***************7 ]! m+ N+ W6 Q* R  v  n% W
*** 112,125 ****" u- d! z2 @* B! A! X3 O; c
  }
8 \# B& n6 C, ~' W4 e  
5 Q. F2 v( w7 k0 |0 Q- Q  download_rootfs() {' \/ j" N0 y* @1 L, g; Y
! #        detect_url "rootfs\.tar"
. w, Z* u# V( @' w5 j! #        local rootfs_url=$openwrt_url/$return2 ]% c+ W1 b( Q8 }
  
5 c) C# C9 _1 n6 @) B* D3 G          # global $rootfs5 g) T1 b# M% H  o1 t2 p0 i
!         rootfs=dl/openwrt-19.07.1-bcm53xx-generic-rootfs.tar.gz4 f! K- m8 S# o& m. w
  ; X$ d% W0 A' Q+ d7 T; G# z) M
! #        download $rootfs_url $rootfs $rootfs
; p9 T) k- z! F' [! #        check $rootfs $rootfs_url; h% D1 S1 f" g# B% u8 Q9 b' y$ _/ p
  }
9 h" p, S& Y0 \! Q9 {( H3 A# I, n  
+ k* B- Y# K! b2 X0 D  download_sdk() {
8 x5 D- |2 z" _: ~8 Z; k--- 112,125 ----3 q$ A; J8 k6 D
  }
% a! s: }; c6 D3 h* ~  
/ Q- t( N/ s8 S; z. i0 Z' p  download_rootfs() {
9 W( F5 P$ G+ f+ e!         detect_url "rootfs\.tar"
4 z% A: {3 s4 J; N/ v!         local rootfs_url=$openwrt_url/$return
5 Q: C. s' I6 ~- ^  9 @( d" ~! k2 `8 A0 }; A5 N6 q- ~  ]4 {
          # global $rootfs3 Q. B3 r* N' D
!         rootfs=dl/$(basename $rootfs_url)
; ^8 J1 i. L# k6 d6 D" j  ( z) `7 [8 y1 b% V% }
!         download $rootfs_url $rootfs
2 r  c( a' O9 ]! d3 l! R!         check $rootfs $rootfs_url
; e, I0 c6 H- m" W+ H  H) J5 _  }
' u: f4 \% J3 ^  
# A1 u) f( G  {4 U/ Y; }4 `4 R* R  download_sdk() {
* D) m* @1 N4 G5 o' Z& N) [
3、从腾讯镜像下载openwrt-19.07.1-bcm53xx-tplink-archer-c9-v1-squashfs.bin,从固件中提取rootfs并预处理。5 {. v4 ~6 V* b7 s! B
  1. x@x-Surface-Pro-3:~/下载$ binwalk openwrt-19.07.1-bcm53xx-tplink-archer-c9-v1-squashfs.bin ' ^( j! p. N0 \. H

  2. . V% p" e% x. w' |7 z6 s
  3. DECIMAL       HEXADECIMAL     DESCRIPTION# c- b8 l4 A9 Q  V, T6 L1 v3 s( T
  4. --------------------------------------------------------------------------------; c+ Y$ \/ D/ r9 q
  5. 8317          0x207D          TRX firmware header, little endian, image size: 1810432 bytes, CRC32: 0xBCD36218, flags: 0x0, version: 1, header size: 28 bytes, loader offset: 0x1C, linux kernel offset: 0x0, rootfs offset: 0x00 ]0 H& S7 u5 L+ q
  6. 8345          0x2099          LZMA compressed data, properties: 0x5D, dictionary size: 65536 bytes, uncompressed size: 1801662 bytes3 v2 K, ]$ W6 P$ |
  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* Z; C* D% ]+ C: r+ w
  8. * Z& p( a0 `8 b+ k0 F; R& E6 s9 Q
  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/ S; v. W) X2 f2 X
  10. 记录了1900548+0 的读入, e7 h# {7 E$ P) |" j
  11. 记录了1900548+0 的写出
    ' p5 e3 S: d6 r- t) L" n
  12. 1900548 bytes (1.9 MB, 1.8 MiB) copied, 5.16823 s, 368 kB/s) {7 O# \) n( U- q  D. G( b6 g8 a
  13. x@x-Surface-Pro-3:~/下载$ binwalk rootfs-squashfs.bin / K/ k' |- i! X4 q
  14. ! T& o8 P" l2 `1 P2 _' n* l2 q0 a
  15. DECIMAL       HEXADECIMAL     DESCRIPTION, H* l: s. p8 E; S; e( @
  16. --------------------------------------------------------------------------------
    + _# q- N: x  ^! R# o3 \# ]
  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
      B/ H' y& m7 j& P( o$ n, Z$ f

  18. ' |1 |0 V' Z8 o8 D& a
  19. x@x-Surface-Pro-3:~/下载$ unsquashfs rootfs-squashfs.bin * F% A) @" F0 ]; Q7 k
  20. Parallel unsquashfs: Using 4 processors
    8 u8 ]! G- M6 E. _
  21. 1071 inodes (1066 blocks) to write
      F7 k- b( j% i* U' c3 c4 F5 x4 J: ~
  22. 9 d3 }( c6 X1 X% b# p% |
  23. / k" p" v$ C2 |" J0 q
  24. create_inode: could not create character device squashfs-root/dev/console, because you're not superuser!+ o. Y# E1 V! M. V, q! l
  25. [====================================================================================================| ] 1065/1066  99%
    8 B' b0 r+ C3 |

  26. ' ^3 `+ @: d$ Q1 ]7 N  g
  27. created 875 files8 _3 g+ P4 S/ |
  28. created 103 directories
    4 q& K1 h  m# @( f$ Z  e' Z4 V
  29. created 195 symlinks
    5 k7 H3 {% D* L  t7 R
  30. created 0 devices
    & G& R6 t  ~7 B+ w5 ~
  31. created 0 fifos
    , a& E7 q' `2 {  M# L4 \' |
  32. x@x-Surface-Pro-3:~/下载$ cd ./squashfs-root/
    & O" j, @3 O5 w# C: |$ e  [
  33. x@x-Surface-Pro-3:~/下载/squashfs-root$ gedit etc/opkg/distfeeds.conf
复制代码
将opkg软件源改为腾讯镜像
& U# h( z7 \" A  w, \
src/gz openwrt_core https://mirrors.cloud.tencent.co ... xx/generic/packages
8 R( M# S7 S& X3 t+ C( u1 Jsrc/gz openwrt_kmods https://mirrors.cloud.tencent.co ... 92b7d7eca715b1ee0b8
4 z0 Z( p. k, N$ y' B& ssrc/gz openwrt_base https://mirrors.cloud.tencent.co ... /arm_cortex-a9/base
/ w* x* e1 j9 M/ `. b' k$ Vsrc/gz openwrt_luci https://mirrors.cloud.tencent.co ... /arm_cortex-a9/luci8 d& I! n7 h: T! T3 j" {
src/gz openwrt_packages https://mirrors.cloud.tencent.co ... _cortex-a9/packages
$ L- I8 x3 F6 psrc/gz openwrt_routing https://mirrors.cloud.tencent.co ... m_cortex-a9/routing5 V' H  J0 W+ b7 ~6 y/ ?
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 ./
      b3 o8 o, l# t3 o5 k& X
  2. x@x-Surface-Pro-3:~/下载/squashfs-root$ cd ../
    9 _3 L( w7 R5 H3 I
  3. x@x-Surface-Pro-3:~/下载$ mkdir lxd-openwrt-master/dl0 {9 D& H9 ~  ]- Z3 F0 o
  4. x@x-Surface-Pro-3:~/下载$ mv openwrt-19.07.1-bcm53xx-generic-rootfs.tar.gz lxd-openwrt-master/dl/
复制代码
执行修改过的build.sh9 q) Q" v# u# t9 K/ _% W' T
  1. x@x-Surface-Pro-3:~/下载$ cd lxd-openwrt-master/
    : G1 S) ?: N! \3 U, C0 S
  2. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ ./build.sh -a arm -v 19.07.1
    ( q1 m9 g  e9 d0 O4 c4 }
  3. ......: P7 K6 d) Y" U1 f
  4. Pack rootfs7 K- D6 z+ F  M
  5. Tarball built: bin/openwrt-19.07.1-bcm53xx-generic-lxd.tar.gz  A& K1 o7 ?( W) i0 G, T/ D
  6. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ mkdir ../openwrt-19.07.1-bcm53xx-generic-lxc2 Z. m' o' t3 R- y! V
  7. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ tar zxf bin/openwrt-19.07.1-bcm53xx-generic-lxd.tar.gz -C ../openwrt-19.07.1-bcm53xx-generic-lxc
    3 N. J4 e3 x0 }" l6 T- h: @) ^8 x9 J
  8. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ cd ../openwrt-19.07.1-bcm53xx-generic-lxc/! m  |% {9 m+ [& \
  9. x@x-Surface-Pro-3:~/下载/openwrt-19.07.1-bcm53xx-generic-lxc$ ls! t+ b% u- Q+ [: X8 c
  10. metadata.yaml  rootfs  templates
    , E" {8 Q5 @0 L
  11. x@x-Surface-Pro-3:~/下载/openwrt-19.07.1-bcm53xx-generic-lxc$
复制代码

' B- q  r1 o$ C$ u& T& e4、这时我们已经创建好lxc下可运行的openwrt19.07.1的rootfs,接下来处理lxc及rootfs的配置文件。, k2 X2 p$ ^/ q$ A0 f
进光猫复制自带子系统的两个文件,再通过U盘或ftp传到Ubuntu的openwrt-19.07.1-bcm53xx-generic-lxc目录下,
" t; H- ~% V' r" T4 f/ M) ~0 {
  1. root@F650A:~ # cp /opt/upt/framework/saf/config /mnt/USB_disc1/4 F- Q" a% Y7 j, ?
  2. root@F650A:~ # cp /opt/upt/framework/pre-start.sh /mnt/USB_disc1/
复制代码
config为saf系统的配置文件,新系统下稍作修改,
9 i3 d: U* V9 t! p
lxc.arch = arm( D) q  p/ I7 R# @6 H2 \
lxc.utsname = openwrt) \6 z7 X+ d" ]0 h, T) h: T
lxc.rootfs.mount = /usr/var/lib/lxc/openwrt/rootfs7 o( v' v; ~# [& @# v+ i  y
lxc.rootfs.path = overlayfs:/opt/upt/framework1/rootfs:/opt/upt/apps/openwrt-rootfs
9 X& r0 q; I9 M- U* K1 }; g# lxc.rootfs = /usr/var/lib/lxc/openwrt/rootfs
: w: r, T/ C1 |! W7 x& Dlxc.haltsignal = SIGUSR12 p# O3 z" t: j4 V) Q; b
lxc.tty = 1
; `/ ^) `) B/ Q+ d( ]3 alxc.pts = 12 e* b: ]; q' x5 U: d3 \
lxc.hook.pre-start = /usr/var/lib/lxc/openwrt/pre-start.sh  D* L. G: J2 _# w3 I7 u4 v
lxc.aa_profile = lxc-container-default-with-nesting& r' w9 q; e1 V
lxc.network.type = none3 O' i* q' x  |0 o. @
lxc.mount.entry = sysfs sys sysfs defaults 0 08 q- C. H9 K3 K% w5 [8 g% w! P; E
lxc.mount.auto = cgroup-full:rw
1 t! j6 ^5 U- d4 w  s8 v  D2 K- w% _7 ilxc.mount.entry = proc proc proc defaults 0 0  B) N" s5 u! F* a; k4 [
lxc.mount.entry = /mnt mnt none rw,rbind 0 04 W$ P, I. a7 u$ P0 f
lxc.start.auto = 1
, }# X5 Q0 S$ X8 v) a
pre-start.sh处理模拟终端,为避免重复挂载devpts,添加一行卸载代码,8 n3 j+ q0 [; ~& G; }/ f
#!/bin/sh
( a, D! r7 O. F3 {4 cumount /dev/pts /dev/ptmx
. y3 u6 w" M! e: J( }: T* Qmount -t devpts -o newinstance -o ptmxmode=0666,nosuid devpts /dev/pts
8 c$ I; Q# Q* |5 H/ c) \. {mount -o bind /dev/pts/ptmx /dev/ptmx
* ~* i: P2 R6 c' x, L) @% K, E
再删除rootfs/etc目录下网络和防火墙相关启动及配置文件如uci-defaults/09_fix_crc、uci-defaults/12_network-generate-ula、uci-defaults/70_fill-dhcp-checksum、uci-defaults/odhcpd.defaults、board.d/01_leds、board.d/02_network、board.d/99-default_network、config/dhcp、config/firewall、rc.d/K10gpio_switch、rc.d/K85odhcpd、rc.d/K90network、rc.d/S19dnsmasq、rc.d/S19firewall、rc.d/S20network、rc.d/S35odhcpd、rc.d/S94gpio_switch、modules.d/、modules-boot.d/、ppp/、sysctl.d/ 等,创建squashfs镜像,
2 w( A; U( L" o, _6 z4 [
  1. x@x-Surface-Pro-3:~/下载$ mksquashfs openwrt-19.07.1-bcm53xx-generic-lxc openwrt-19.07.1-bcm53xx-lxc.bin0 d3 s% A- A  J5 m( F; _
  2. Parallel mksquashfs: Using 4 processors
    ) F5 B+ l( s4 E3 _+ l  ?9 C2 S
  3. Creating 4.0 filesystem on openwrt-19.07.1-bcm53xx-lxc.bin, block size 131072.
    7 Z  y- ?, q7 }- V' u
  4. [=======================================================================================================/] 881/881 100%5 }9 d  I$ W" Y0 S% q  U+ ^8 D
  5. ; T4 g4 M" U7 K" i6 q6 X
  6. Exportable Squashfs 4.0 filesystem, gzip compressed, data block size 131072" d  T; |9 X& }% A9 ^' D3 K* W% V3 h" J( @
  7.         compressed data, compressed metadata, compressed fragments,
    8 s7 U6 E8 g8 ?3 J
  8.         compressed xattrs, compressed ids7 ]  M' `7 U4 \) X1 B* R/ T3 l
  9.         duplicates are removed/ v$ M, i3 X) _8 o! {
  10. Filesystem size 3163.90 Kbytes (3.09 Mbytes)* H; f, C; M2 |( s
  11.         48.94% of uncompressed filesystem size (6464.54 Kbytes)
    ' s; l$ }! X9 V0 S7 @
  12. Inode table size 9693 bytes (9.47 Kbytes)
    ) @9 x3 ]  a/ O% N/ c+ ?5 f8 ^. Z
  13.         25.72% of uncompressed inode table size (37693 bytes)
      m2 c( _4 d7 v
  14. Directory table size 11372 bytes (11.11 Kbytes)+ i. Z; n0 p. N. U
  15.         47.17% of uncompressed directory table size (24108 bytes)/ @9 b9 l- ^6 |2 Y& }
  16. Number of duplicate files found 136- b# r# }! ?7 _# c& A( R
  17. Number of inodes 11452 ~# ~" d: ]4 d, {- H* ^  L& _# j
  18. Number of files 873
      ~% M. W( U) l" X/ `7 L/ B, M
  19. Number of fragments 390 |" ]) ~  u+ a% G: ^9 B
  20. Number of symbolic links  171; ]) n) ~5 p3 G
  21. Number of device nodes 0% ?/ V9 Z, d  p- s0 T! Q/ \7 p
  22. Number of fifo nodes 0- Y( I  {: p( l3 m$ W: @4 T; v
  23. Number of socket nodes 02 b4 K9 ^2 v4 a
  24. Number of directories 101# ]; A8 C5 f4 L! }* [- x9 ^$ Q0 W1 A7 t3 t
  25. Number of ids (unique uids + gids) 15 W  j& `6 J0 {0 R5 M1 y
  26. Number of uids 1* `) g! n: z: [9 {& l
  27.         x (1000)
    6 ^, F6 n3 i4 b  C' S" @+ n; T/ j
  28. Number of gids 1
    9 m+ }3 ^( T( m) u' g. R
  29.         x (1000)
    % I6 e* v2 y- y5 C( i) A! F) _
  30. x@x-Surface-Pro-3:~/下载$
复制代码

, d& G8 s( v, ^, H" F$ [* n/ d% S5 x4 \. {/ d8 K( f
5、生成的openwrt-19.07.1-bcm53xx-lxc.bin传入光猫,'mtd' 写入mtd7分区。
$ S8 t& ]+ n# F  n! }刷之前先关掉saf,因saf有lxc-monitord进程守护,kill掉之后会自动运行,只好修改saf程序名,重启光猫。
% d1 j, T. B. n/ P$ b
  1. root@F650A:~ # mv /usr/sbin/saf /usr/sbin/saf.bak5 k: b4 f7 E: z
  2. root@F650A:~ # reboot
复制代码
重启后telnet登录,'ps' 确认进程列表没有saf,备份然后写入并挂载。
root@F650A:~ # ps
/ [, c, F3 _* R0 ^6 c# _2 }7 ~  PID USER     VSZ   RSS  STAT  CPU COMMAND
1 T/ R! |  g) b9 c3 n" I    1 root     23160   600  S     <1>  init3 [' q7 k, `6 u. a) t
    ......3 Y% i0 O. N/ l: j& @! [5 d; d8 C
root@F650A:~ # dd if=/dev/mtd7 of=/mnt/USB_disc1/mtd7.bin bs=1M/ C7 i% b9 j7 z6 J1 ^& s- C
8+0 records in% H. I+ v& F7 r0 A( r$ J
8+0 records out
* D  {7 t4 [# l5 {7 Yroot@F650A:~ # mtd write /mnt/USB_disc1/openwrt-19.07.1-bcm53xx-lxc.bin /dev/mtd7# O& X& c  w* q$ G! T
Unlocking /dev/mtd7 ...
% M! m6 g: X$ e4 t& X* z! n3 Z  }9 Z
" h* x! O4 T$ D7 l- r, X+ fWriting from /mnt/USB_disc1/openwrt-19.07.1-bcm53xx-lxc.bin to /dev/mtd7 ...) y6 S. ]2 K( b
root@F650A:~ # mount /dev/mtdblock7 /opt/upt/framework1
; Z- b5 y0 h4 \( ~
6、开启OpenWRT新世界% a  B- {, U; m5 K% E5 M( A
    写入mtd7分区并挂载之后,开始首次启动的准备工作。F650A的lxc默认路径在/usr/var/lib/lxc(一楼有说明),按config文件创建相应文件及文件夹,
- D5 T$ C- F# z' d3 U/ v; b9 k5 n/ G; Y" n2 o. ^
  1. root@F650A:~ # mkdir -p /usr/var/lib/lxc/openwrt( Y1 N$ a: t. ^& o! ^
  2. root@F650A:~ # cd /usr/var/lib/lxc/openwrt
    ( T3 ?  W& o+ ^
  3. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/pre-start.sh pre-start.sh2 T/ D' Q: X1 v
  4. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/config config/ o! z3 l1 P, C8 E( e
  5. root@F650A:/usr/var/lib/lxc/openwrt # mkdir rootfs2 M2 V( L) U+ P7 X' S) |8 }
  6. root@F650A:/usr/var/lib/lxc/openwrt # mkdir /opt/upt/apps/openwrt-rootfs% c6 _4 V& a+ U- v' |4 b% x
  7. root@F650A:/usr/var/lib/lxc/openwrt # lxc-start -dn openwrt
    6 v$ V5 ?' E& |9 W5 h) I
  8. root@F650A:/usr/var/lib/lxc/openwrt # ps
复制代码
此时的进程列表应该可以看到/usr/sbin/uhttpd、dropbear等,或者可以尝试打开浏览器 http://光猫ip/或ssh登录,如果看到Authorization Required提示登录或ssh提示登录用户名密码,表明lxc已成功运行,但此时无密码状态无法网页和ssh登录,只能通过控制台方式添加密码后才能实现。关闭openwrt容器,'ps' 确认,前台启动。' g$ r% e/ d: }, U5 q3 _# N
  1. root@F650A:/usr/var/lib/lxc/openwrt # lxc-stop -kn openwrt
    0 h4 |, f. q$ }+ w
  2. root@F650A:/usr/var/lib/lxc/openwrt # ps0 z# T; f: [/ z
  3. root@F650A:/usr/var/lib/lxc/openwrt # lxc-start -n openwrt
    ( w! Q9 T2 V& B" V+ U
  4. <6>init: Console is alive
    " U" b: e. D( b
  5. <6>kmodloader: loading kernel modules from /etc/modules-boot.d/*! d5 n8 E* Y7 z( @/ b: m! `. q
  6. <6>kmodloader: done loading kernel modules from /etc/modules-boot.d/*
    0 G7 e! J% V/ {6 c( ]
  7. <6>init: - preinit -! |; h) ?; K% t; A( F
  8. WARNING: Variable 'network' does not exist or is not an array/object" o$ [; l1 S/ A  M' B" `% J+ S7 c
  9. WARNING: Variable 'lan' does not exist or is not an array/object, \. f+ u$ ~: p$ u7 e
  10. Press the [f] key and hit [enter] to enter failsafe mode
    - {9 ]( n7 ~; B7 w1 }' J
  11. Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
    4 f2 ]8 v* P# g5 `7 \
  12. <5>mount_root: mounting /dev/root# @7 B8 B# R3 r9 Y1 _% a
  13. urandom-seed: Seeding with /etc/urandom.seed/ w2 j& v4 w8 B! C
  14. <6>procd: - early -
    ( K* O4 _- d4 N/ q  [
  15. <6>procd: - ubus -
    * @! {+ x) l% i6 {9 c* [0 ?
  16. <6>procd: - init -8 D9 X0 d5 o2 @% U, ?* D
  17. Please press Enter to activate this console.
      O5 l! b% b' {: C0 y
  18. <6>urngd: v1.0.2 started.
复制代码
此时回车便可看到openwrt的登入界面,添加密码。/ t+ ]4 Y: [/ K; c2 w1 H8 z

  1. 7 _! }, G- Z, N2 r1 u
  2. BusyBox v1.30.1 () built-in shell (ash)% ^$ |7 x; j' @" n

  3. . q" s8 m) N; }2 e+ }
  4.   _______                     ________        __# u" O& T( ^( x5 x: H: M8 b
  5. |       |.-----.-----.-----.|  |  |  |.----.|  |_
    6 t. H. I+ f! l4 c9 I% O: v+ }8 e1 \
  6. |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|; _6 A/ o2 E7 S$ B4 Q+ T) e: c
  7. |_______||   __|_____|__|__||________||__|  |____|
    + Y8 j0 x; n* I; x& t' M
  8.           |__| W I R E L E S S   F R E E D O M
    # c* A- M1 l5 _2 I/ _& L
  9. -----------------------------------------------------. }3 D9 ^' [3 u# ^% Y
  10. OpenWrt 19.07.1, r10911-c155900f66
    ! d# f3 g7 |* I4 N: L: f3 h% b
  11. -----------------------------------------------------; B6 f, k/ s3 h% }: g; a
  12. root@openwrt:/# passwd root3 ~, D' B3 v4 D) a
  13. Changing password for root
    8 D  _0 A  a7 S* ?
  14. New password:
    * c. ^; c  n4 k6 p" v* k5 i
  15. Bad password: too weak
    " I4 C# O8 S" t" X" Q
  16. Retype password:
    7 n1 X( @+ b2 f& b- Y+ q3 i
  17. passwd: password for root changed by root' r% l8 p4 z% n0 n
  18. root@openwrt:/# exit
    5 E5 q" n( O- u+ j) o( p
  19. Please press Enter to activate this console.
复制代码
控制台方式进入openwrt之后,exit无效,没找到正常的退出方式,只能关闭窗口,此后就可以通过网页和ssh正常登录。
0 P1 [2 y+ b. G/ D6 K$ L* j5 ~% W: C" w0 i
7、自启动及进程守护
; K, v6 B; \5 K- I5 i    telnet登录光猫主系统,确认saf程序已备份,
9 E& `8 G& K1 N3 g3 Y  b5 w7 k! B. k% k! T! y/ |4 |1 ^
  1. root@F650A:~ # ls /usr/sbin/( k4 a* O5 z2 G3 N- |
  2. chroot       lsap         saf.bak      telnetd5 v2 x+ ~2 {- q- V& c- u- t3 n7 T
  3. root@F650A:~ # vi /usr/sbin/saf
复制代码
填入 (2021年5月更新:去除USB端口挂载判定,避免无挂载时LXC不能启动)
5 h9 o6 P9 S$ A# {9 }  G
#!/bin/sh
* K, S- {5 l8 k7 M# add user-defined startup scripts here
! ]$ B+ x  C1 @8 i- c; f7 }, l
* H2 b/ E" l5 |3 x" ]1 B3 u  df | grep mtdblock7( G2 N1 T+ r& a: `
  if [ $? -ne 0 ]
# w! ^$ J; F, L; \9 s    then# N6 j3 i: b+ _
      /bin/mount -n -t squashfs -o ro /dev/mtdblock7 /opt/upt/framework1
  G# w* U" h( K* T) [  fi
+ ~8 I4 K6 ~$ ]##6 v8 H( x  {, d" j: Q/ p

& Y7 t. ~. D" i1 V# f& k: ]  `#  ps | grep ntfsmount | grep -v grep
8 O2 K. y. A  o9 L: M#  if [ $? -eq 0 ]
8 a- F7 [9 B7 u" @  p- F#    then
! U* I5 w( g# u      /dbus/usr/bin/lxc-start -dn openwrt
) K. {7 }9 o9 f/ d( _: C#  fi
% t: C1 n# Z2 n' K# S4 {##
; ^" U$ Q/ w2 l7 b% N, U* z) U
或者在电脑编辑好内容,命名为saf,传入/usr/sbin/,'chmod +x' 添加执行权限,重启光猫。
9 V* ^1 C1 v/ ^3 g$ \8 }  ]
! r! X& e0 f, }) S: f, p8、后续问题& y6 z( k8 _; Z
    目前的openwrt安装或更新程序会报错,缺少 libustream-openssl 、ca-bundle 、ca-certificates 和 libopenssl1.1,还需要修改dns,添加中文等3 a5 y: y* @5 q* E9 R

1 f: T# c& }; i: J' }  D, x- U0 [
  1. root@openwrt:~# opkg update
    4 F' C' D+ p7 {: {3 a' W
  2. Downloading https://mirrors.cloud.tencent.com/lede/releases/19.07.1/targets/bcm53xx/generic/packages/Packages.gz" @! D/ h+ A0 k) h. \& z5 I4 N
  3. wget: SSL support not available, please install one of the libustream-.*[ssl|tls] packages as well as the ca-bundle and ca-certificates packages.
    ; E1 k" x3 Y2 _5 S! R$ M! N
  4. *** Failed to download the package list from https://mirrors.cloud.tencent.com/lede/releases/19.07.1/targets/bcm53xx/generic/packages/Packages.gz
复制代码
这些安装包可以从腾讯的镜像站下载然后手动安装。
% P* g  m3 D% f1 P0 S  g0 ?
  1. root@openwrt:~# cd /mnt/USB_disc1/
    $ Z# r# H2 P! m- h6 ~; V) G
  2. root@openwrt:/mnt/USB_disc1# opkg install *.ipk
复制代码
修改dns
0 U1 a* q, `1 f0 l* S+ u; b
  1. root@openwrt:/mnt/USB_disc1# rm /etc/resolv.conf8 k+ A& G) H) a
  2. root@openwrt:/mnt/USB_disc1# vi /etc/resolv.conf
复制代码
填入,保存2 ?3 d0 }/ `6 p, V# L
nameserver      223.5.5.5- j9 b7 Z- g. b7 ^: @9 k/ Q
nameserver      8.8.8.81 S8 P) h, c. Y% K5 q
nameserver      2001:da8::666
) [+ S8 m8 k& M
嫌过程繁琐的可以直接下载我配置好的镜像,从第5部分最后开始操作,将下载的openwrt-19.07.1-bcm53xx-lxc.bin和saf-lxc-start-openwrt放入光猫上的u盘,子系统默认root密码123456。
# m' Q  w/ M# `0 D3 B! v, O
  1. root@F650A:~ # dd if=/dev/mtd7 of=/mnt/USB_disc1/mtd7.bin bs=1M6 z% z1 g: a6 l
  2. root@F650A:~ # mtd write /mnt/USB_disc1/openwrt-19.07.1-bcm53xx-lxc.bin /dev/mtd7. }2 q  Q% |0 R$ n1 W  L1 t: A4 t+ ?
  3. root@F650A:~ # mount /dev/mtdblock7 /opt/upt/framework16 d- F  j6 o) }: |* E/ m0 C
  4. root@F650A:~ # mkdir -p /usr/var/lib/lxc/openwrt- d$ N, y% V, S
  5. root@F650A:~ # cd /usr/var/lib/lxc/openwrt
    ' r  }' q2 {5 ~% R
  6. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/pre-start.sh pre-start.sh& r. t+ I3 V. Z6 z# \
  7. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/config config
    / W% l4 b0 h' t) `, s/ X
  8. root@F650A:/usr/var/lib/lxc/openwrt # mkdir rootfs' y% d, }: G  m7 v7 Z& C( ?
  9. root@F650A:/usr/var/lib/lxc/openwrt # mkdir /opt/upt/apps/openwrt-rootfs6 O( z7 G3 o8 L6 b% d0 {8 w
  10. root@F650A:/usr/var/lib/lxc/openwrt # lxc-start -dn openwrt
    2 ~& x' j6 _6 T- ^1 O+ C- I* [
  11. root@F650A:/usr/var/lib/lxc/openwrt # cd ~
    : s& D1 Q3 w0 B4 r
  12. root@F650A:~ # mv /usr/sbin/saf /usr/sbin/saf.bak
    7 E) J- e& m  ^  j; \
  13. root@F650A:~ # cp /mnt/USB_disc1/saf-lxc-start-openwrt /usr/sbin/saf
    9 d+ @. E# g& s  l
  14. root@F650A:~ # chmod 0755 /usr/sbin/saf
复制代码
   虽然子系统的openwrt可以顺利运行,但经过我的测试,kmod类app大多无法正常工作。比如F650A内核不支持ext4文件系统,在子系统安装kmod-fs-ext4,尽管可以安装成功,但重启后提示 modprobe 启用ext4模块失败。
! Q  |5 X- R0 R3 w( b7 \3 d        子系统的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管理页面,需要更改光猫主系统,此操作的定制空间更大,有机会的话在后面回复中整理出自定义光猫固件的思路。: H5 u6 T8 {* o' Y7 n

1 I& ?+ }! r7 J# l* M' A" {

本帖子中包含更多资源

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

×
发表于 2020-2-17 23:36:12 | 显示全部楼层
期待大神的教程
发表于 2020-2-18 20:19:40 | 显示全部楼层
谢谢分享,期待大神的教程
发表于 2020-2-18 21:28:08 | 显示全部楼层
滿滿的乾貨,還具有很好的分享精神,贊一個!!
发表于 2020-2-20 12:58:43 | 显示全部楼层
坐等lxc的教程,另外19openwrt是你自己编译的还是直接下载armv7的官方bin刷进去的?3 v) E0 e3 w1 Q$ {) j
中兴非15.0.1出问题是你没清理/opt/upt/apps//apps目录! X, h# C/ l$ \" R8 e3 j# e" M1 a: M
几乎所有光猫为了节省空间?都会有部分lib和var目录重用主系统的文件,openwrt下e8clib和e8cvar可以看看。8 J" G8 G/ p0 d7 j7 L. f  D8 N
另外中兴编译的openwrt开始了uclibc的xlocale配置,这也是achaoge直接用omap源的APP无法运行的原因,我自己有手动开启xlocale后编译omap的openwrt放进去运行OK。( `2 R* G6 b! V; @: u
有兴趣可以一起研究玩。
 楼主| 发表于 2020-2-20 21:40:34 | 显示全部楼层
anysoft 发表于 2020-2-20 12:58
$ ^) V6 h- X; M5 C  p: Q坐等lxc的教程,另外19openwrt是你自己编译的还是直接下载armv7的官方bin刷进去的?
* t9 F* K+ o4 l( g* I中兴非15.0.1出问题是 ...
, b8 v. F) m" v/ |) T) x# Q

* ^2 t3 @+ @" @$ n6 Z  {% ropenwrt1907用的官方rootfs经https://github.com/mikma/lxd-openwrt修改而来;xlocale的问题我在编译主系统的busybox时也发现了,官方用的应该是buildroot2015.08.1,如果有dtb和驱动甚至可以自己写个固件了。
发表于 2020-2-21 14:42:33 | 显示全部楼层
songee 发表于 2020-2-20 21:40
6 u; k4 T& Y* k( q% uopenwrt1907用的官方rootfs经https://github.com/mikma/lxd-openwrt修改而来;xlocale的问题我在编译主 ...

! U7 g" q3 C; _是的, 中兴使用的是buildroot-2015.8.1,这个strings 一下sendcmd 就可以看到
& f! j4 F5 k& T6 c  }( x5 n
' J( w$ y# ]. P( s+ {$ {看了下操作步骤,其实如果内存足够,没必要关闭saf启动的天翼网关。2 S! N! Z  r+ t' `: _
可以让lxc容器启动两个op应该是可以的,F650A和华为hs8145V应该都是512MB内存,内存足够,openwrt可以放到apps分区文件夹下,不一定要写入mtd7再手动挂载。
% x6 E2 v3 C7 @! W9 q1 h( @* m" t
3 b( w! a( N! x8 I我的HS8145V启动后内存只占用了30%,足够了。3 Q- z* s% M# o' z3 N

4 ^* R! F7 ~/ k) C+ C& T另外主系统下的usr/sbin目录下文件不是内存加载的rootfs对应的squash文件?这个更改应该不会回写到文件系统,重启应该就会消失?+ ^) A9 w- @% z* b* D7 T2 U  h
不晓得中兴和华为是不是一样的。可能中兴可以修改文件吧,华为的只能dd备份rootfs分区后自己解包修改打包后再dd写进去,会有砖的风险,砖了只能上编程器。
* S% z; L$ B+ R3 @4 i- z' I1 H) @; Y7 U! d( y& O% O8 a
至于端口问题可以在打包openwrt的时候先修改每个服务对应监听端口就不会冲突了。
+ a9 x4 E* f5 Y5 S

本帖子中包含更多资源

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

×

点评

通过修改端口与saf共存确实可行,只是内存和CPU在开ariang离线下载、文件共享等重负载下会更吃力。 在测试lxc的时候我也是把rootfs直接放在了/usr/var/lib/lxc目录下,但会占用20%左右的ubi分区(mtd11,分区大小62M  详情 回复 发表于 2020-2-21 22:31
*滑块验证:
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|宽带技术网 |网站地图

粤公网安备 44152102000001号

GMT+8, 2024-5-11 01:40 , Processed in 0.045233 second(s), 8 queries , Redis On.

Powered by Discuz! X3.5 Licensed

Copyright © 2001-2020, Tencent Cloud.

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