找回密码
 注册

QQ登录

只需一步,快速开始

查看: 80781|回复: 97

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

  [复制链接]
发表于 2020-2-17 02:14:04 | 显示全部楼层 |阅读模式
本帖最后由 songee 于 2022-4-27 21:04 编辑 . j4 y- |, @* m' w" r7 d; v
0 F0 i" H0 q" E4 l& d
家里装宽带,电信200M,送了个中兴F650A。自带的天翼3.0web界面看着不错可惜几乎没有可玩性,闲来无事研究一番。$ t7 \3 @5 {9 t
    借鉴论坛前辈achaoge的帖子:中兴 F450A/F650A 免 TTL 持久开 ssh顺利开启telnet,发现该光猫的运作机制是 主系统负责底层的硬件驱动、sendcmd管理系统(telnet、超密、ppp拨号、网络及WiFi、ftp等)、以httpd为基础的8080端口电信web管理界面,最后启动saf(lxc容器管理)程序。
8 \  x" g  Z) m* H! I    saf程序在华为和中兴的很多光猫上都存在,根据该程序在F650A中的功能,我认为其主要作用是自动管理lxc容器。开机有 ‘saf service 6 7 11’进程,意为将 mtd6 或 mtd7 作为saf子系统的firmware(rootfs)分区,mtd11 作为APPS数据overlay分区。至于是 mtd6 还是 mtd7,由 saf setactive 命令指定,默认 mtd6,如果子系统启动失败自动指定 mtd7;从 mtd7 启动失败可能导致整个 mtd11 分区被擦除,mtd11 分区同时也是主系统的overlay数据存放区,操作时需要特别注意!!! T) J& C+ A' M! S% d+ ^
  1. root@F650A:/usr/sbin # saf
    - B7 }/ W- y7 ~8 u' i  T
  2. Usage: saf service FWK_MTD_ID1 FWK_MTD_ID2 APPS_MTD_ID (eg. saf service 9 10 7)
    / n5 d5 a1 P& t5 i" d6 q) n, E; b2 J
  3. saf console0 B4 b0 B$ b, y
  4. saf info
    1 ~3 h6 S% {, ]) M
  5. saf version
    . N+ |2 N0 J0 O1 _+ C5 ~2 Z. w
  6. saf getfwkver# \8 i; `; N$ [; c7 u
  7. saf getbakfwkver0 B" n# D4 j4 Z9 ^. P8 E5 m. Y
  8. saf getactive% O4 q7 ?" }" h' V2 E! d8 ?
  9. saf setactive FWK_MTD_ID [AFTER_REBOOT] (eg. ./saf setactive 17 1)
复制代码
  1. root@F650A:~ # cat /proc/mtd8 r, Y. s4 s' C' H3 m5 b4 Q9 n  C, z
  2. dev:    size   erasesize  name
    1 f. t: c+ @" q2 `
  3. mtd0: 08000000 00020000 "whole flash"" _5 _- _+ n) a2 R6 p9 e
  4. mtd1: 00100000 00020000 "u-boot") Z$ w, t6 J" w  _" J8 x
  5. mtd2: 00080000 00020000 "others"3 A& s1 u: }8 S  `% U1 |+ \
  6. mtd3: 00100000 00020000 "parameter tags"4 r3 g# z# n! C: Y
  7. mtd4: 00100000 00020000 "wlan"
    : d6 S1 o  Z  V0 ^+ g: y  W& l& U
  8. mtd5: 00200000 00020000 "usercfg"
    ; d; m" L" N: P% C" ~
  9. mtd6: 00800000 00020000 "framework"
    ' s& D) B- `7 B
  10. mtd7: 00800000 00020000 "framework1"
    5 U& R( P4 g6 w0 q- X4 d
  11. mtd8: 00780000 00020000 "dbus"3 Z$ p- N6 Y. M+ y8 M
  12. mtd9: 01280000 00020000 "kernel1"
    2 A/ A# i2 _( B9 Z& i" N
  13. mtd10: 01280000 00020000 "kernel2"
    ; H- f( c* d) B- h; d7 [8 Q
  14. mtd11: 03e00000 00020000 "plugin_data"
    ' d2 J) S3 a  ?. _$ w
  15. mtd12: 01240000 00020000 "rootfs"
复制代码

& `8 Y" e3 Z8 N. p8 ~. Q/ |, j    saf程序管理子系统,是通过系统的lxc容器实现的,在/dbus/usr/bin/目录下有lxc相关程序,但并非标准的官方版,而是定制的,lxc.lxcpath即lxc容器存放位置设定为/usr/var/lib/lxc,暂时没有发现更改的方法(也没什么必要)。
root@F650A:~ # ls -l /dbus/usr/bin
- m  z8 V: n1 Mtotal 377
6 M$ q7 _$ J* o5 f, r) I: w-rwxr-xr-x    1 root     root         10143 Nov 15  2018 dbus-cleanup-sockets5 x" G- T0 u: k- u
-rwxr-xr-x    1 root     root         18867 Nov 15  2018 dbus-launch+ ?. w  \& @* G; y4 \- q" H
-rwxr-xr-x    1 root     root         22537 Nov 15  2018 dbus-monitor
- D( j1 o" A  N4 l$ U2 p8 E-rwxr-xr-x    1 root     root         11049 Nov 15  2018 dbus-run-session
( e+ `  S$ q; K; P-rwxr-xr-x    1 root     root         23431 Nov 15  2018 dbus-send
) Z2 D$ h- @+ M1 w8 ~( ]) r& L-rwxr-xr-x    1 root     root         19495 Nov 15  2018 dbus-test-tool- N( g/ x5 I* }3 p
-rwxr-xr-x    1 root     root         12257 Nov 15  2018 dbus-update-activation-environment. I1 U5 Q0 C9 D4 {( z
-rwxr-xr-x    1 root     root          8365 Nov 15  2018 dbus-uuidgen
& |  l+ a) @1 R* R-rwxr-xr-x    1 root     root         33112 Nov 15  2018 gdbus' s( B9 T# K8 m! T% U
-rwxrwxrwx    1 root     root         12332 Nov 15  2018 lxc-attach
7 ^. D/ E4 B, |% i-rwxrwxrwx    1 root     root         14241 Nov 15  2018 lxc-autostart
. Q( x+ _( @9 r8 i# V) I# C-rwxrwxrwx    1 root     root          9122 Nov 15  2018 lxc-cgroup% ?; h! K2 c3 @
-rwxrwxrwx    1 root     root          4414 Nov 15  2018 lxc-checkconfig  U5 Q$ }7 J6 R
-rwxrwxrwx    1 root     root         10175 Nov 15  2018 lxc-clone
% U3 {2 w! i  X$ U$ y-rwxrwxrwx    1 root     root          6181 Nov 15  2018 lxc-config$ {# C. w0 R8 B6 R6 [3 f5 I/ w# \
-rwxrwxrwx    1 root     root          8590 Nov 15  2018 lxc-console
: [+ b8 [% W1 |. U! a! s-rwxrwxrwx    1 root     root         14556 Nov 15  2018 lxc-create
" z7 {% `; ]& T1 J) O-rwxrwxrwx    1 root     root          8540 Nov 15  2018 lxc-destroy8 E8 j, ^8 n5 |, r
-rwxrwxrwx    1 root     root         10027 Nov 15  2018 lxc-execute: }0 W( T: F/ {, ]9 l
-rwxrwxrwx    1 root     root          8630 Nov 15  2018 lxc-freeze* ]/ x( e/ O/ }0 A. ?+ {  e
-rwxrwxrwx    1 root     root         18956 Nov 15  2018 lxc-info9 s; e: p5 s) y$ G3 R! S; H  U, f
-rwxrwxrwx    1 root     root          2834 Nov 15  2018 lxc-ls) }! A2 j. W, I* l- I
-rwxrwxrwx    1 root     root         11122 Nov 15  2018 lxc-monitor  S1 Y1 _8 U/ S" T/ K' w5 `0 ?
-rwxrwxrwx    1 root     root         12270 Nov 15  2018 lxc-snapshot1 E7 g* j) p. e1 g+ m' g
-rwxrwxrwx    1 root     root         15356 Nov 15  2018 lxc-start9 I" A* T* R3 W! L% I  W
-rwxrwxrwx    1 root     root         10055 Nov 15  2018 lxc-stop
5 C6 Z0 w+ A( G8 `. A2 p8 [* G-rwxrwxrwx    1 root     root          8634 Nov 15  2018 lxc-unfreeze4 N- \1 E. z1 v4 e& s
-rwxrwxrwx    1 root     root         12380 Nov 15  2018 lxc-unshare7 I& V9 v- o3 R
-rwxrwxrwx    1 root     root         13324 Nov 15  2018 lxc-usernsexec
  ~; d: H+ `, _" S/ n+ a-rwxrwxrwx    1 root     root          8561 Nov 15  2018 lxc-wait
  1. root@F650A:~ # lxc-config -l
      z. x3 A0 U" X
  2. lxc.default_config
    ' G) k1 e. M2 S
  3. lxc.lxcpath7 I$ m3 Q% O% l5 l4 I0 x; n. P! M
  4. lxc.bdev.lvm.vg+ e3 L- ?! _$ y- |; O) W; F0 d+ N
  5. lxc.bdev.lvm.thin_pool
    7 O- G" `* {. t# I& d
  6. lxc.bdev.zfs.root1 H! |6 I+ j' s( r& Z  v3 [
复制代码
  1. root@F650A:~ # lxc-config lxc.default_config
    8 O4 ^; a* ~; j* c
  2. /usr/etc/lxc/default.conf
    + b6 T  i( w) N% L6 F- H
复制代码
  1. root@F650A:~ # lxc-config lxc.lxcpath2 J+ I/ A/ Q6 g
  2. /usr/var/lib/lxc
复制代码
& I2 M( f6 N) p4 p6 T6 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方式开启新世界,操作步骤在本文回复中细谈。+ E6 X) }0 B. U# q: e, q8 s. H
    经过几番折腾,已将系统原有的openwrt中兴定制版saf子系统完全替换为官方openwrt19.07.1(lxc方式启动),不影响光猫拨号且可在线安装及更新非kmod类app,如ariang离线下载,samba文件共享,甚至各类科学上网工具(性能及安全原因不推荐)。
9 z' x8 ?" Q, t$ M% Q: p) W9 }
4 s, `/ P2 Q* J8 `* u/ G; g7 |: Q* f$ u3 K* ?! s4 s
% j, e2 `5 G5 s  P' G
$ {  X. U6 \5 r6 z5 D

/ |" d) n; n* P5 f6 z3 o9 K- g2 k. |. h8 g

7 u, h5 a' Y0 d0 H- h6 P

本帖子中包含更多资源

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

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

简化并更新OpenWRT22.03.0 RC1版本

本帖最后由 songee 于 2022-4-26 23:39 编辑
' d" G& |3 |( Q# f! \3 Z
/ f5 ~  e5 W5 L5 {% B+ A因二楼原帖过程过于繁琐,近期尝试了一种较为简单的办法。  Z. ^' a1 G! h1 W' a
4 ]# m" Q6 U8 b

0 b# I0 L) h9 c) S1、下载openwrt.org固件,我选的是openwrt-22.03.0-rc1-bcm53xx-generic-tenda_ac9-squashfs.trx,binwalk分析squashfs偏移量并用dd取出,unsquashfs提取rootfs,打包为rootfs2203rc1.tar.gz,传入光猫临时目录,如 /run/shm 。" c& A  M% q( d" z( ]

5 M& F* N% r) _' C2、将rootfs2203rc1.tar.gz提取至 (lxc-config lxc.lxcpath)/openwrt/rootfs 。# S5 D1 t' H( J9 ]+ y
  1. root@F650A:/usr/var/lib/lxc/openwrt/rootfs # tar -xzvf /run/shm/rootfs2203rc1.tar.gz -C ./
复制代码

, C0 @, E# Y, ^8 \' B/ f6 {
0 J1 r4 H, o% A' J0 k* M3、修改rootfs。openwrt的网络配置与主系统有冲突,需要清除。
) P% V7 J: w; s    3.1 移除 ./etc/board.d/ 目录下 01_leds 、02_network 、99-default_network 三个文件。
9 i. F6 H# p' l2 |" d    3.2 移除 ./etc/rc.d/ 目录下 K21wpad 、K85odhcpd 、K90network 、S19dnsmasq 、S19firewall 、S19wpad 、S20network 、S35odhcpd 、S96led。6 e. V. N+ b1 R4 \& L* [7 n
    3.3 移除 ./etc/modules.d/ 和 ./etc/modules-boot.d/ 及 ./lib/modules/5.10.111/目录下所有文件,openwrt的kernel modules与光猫内核不兼容。
. o+ g* O1 N) t; F+ l
, V' ]2 n1 o: a4 x9 ~' L! m" K    3.4 修改opkg源 ./etc/opkg/distfeeds.conf(可选)+ Z0 @0 H! N- Y/ l
  1. src/gz openwrt_core https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/targets/bcm53xx/generic/packages
    ) o( v6 o: @" Z/ H9 t# E% j
  2. src/gz openwrt_base https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/base
    4 m& |( m6 r/ H9 u
  3. src/gz openwrt_luci https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/luci
    3 W( j* z( x7 [: D2 k' N  J4 p
  4. src/gz openwrt_packages https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/packages
    ! \0 p$ W* D; z" O  `
  5. src/gz openwrt_routing https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/routing+ ], U, l' z# g+ Q- h: J
  6. src/gz openwrt_telephony https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/telephony( N& o. b  N! m" h- w, I3 i
复制代码
  3.5 修改 ./etc/inittab 实现启动项自启(参考https://github.com/mikma/lxd-ope ... r/files/etc/inittab
0 b8 p+ J% R& E  h( r! Q
  1. ::sysinit:/etc/init.d/rcS S boot3 O5 a: j# B$ d* U4 \+ o5 M
  2. ::shutdown:/etc/init.d/rcS K shutdown! o2 `4 C! I' d* u
  3. console::askfirst:/usr/libexec/login.sh
复制代码
  3.6 修改密码 ( root 密码 chinadsl
1 Q7 v5 H# G0 F* n$ {( s+ O/ _
  1. root@F650A:/usr/var/lib/lxc/openwrt/rootfs # chroot ./
    , J2 a$ D. S6 b/ @6 X6 X+ G
  2. 5 \0 W9 G! r* O5 D
  3. $ p& r7 O# @. k! o0 c
  4. BusyBox v1.35.0 (2022-04-20 10:37:37 UTC) built-in shell (ash)
    2 [# v: X; o7 h) F

  5. ) [6 N) R; g1 Y
  6. root@F650A:/ # passwd0 _: b! Q+ V5 U
  7. Changing password for root* Q5 u, e3 l& o
  8. New password:( @; Q7 Q, q5 j! }5 x
  9. Bad password: too weak8 N- Z8 q6 A; q
  10. Retype password:
    : k0 F1 P9 s2 v2 Y
  11. passwd: password for root changed by root
复制代码
  3.7 删除 ./etc/resolv.conf 软连接并新建./etc/resolv.conf,否则openwrt无法解析域名- O% _9 s2 j) ^9 U) R; J, ^
  1. nameserver 223.5.5.5
    3 Z2 y- E& J' O6 Y7 P" |" K
  2. nameserver 2001:da8::666
    6 O' _! L0 R. @, R* U
复制代码
1 V, M0 C1 R0 i

  a7 N' _% G3 `% O  l1 E4、修改lxc配置文件 /usr/var/lib/lxc/openwrt/config ,根据各自光猫环境修改测试,这个配置我的F650A可正常使用。
6 x; z& x7 n2 G
  1. lxc.arch = arm
    7 Y$ M1 \; b4 u) e+ \6 O4 d
  2. lxc.utsname = openwrt
    * ^8 X. N" P, b9 ?$ R
  3. #lxc.rootfs.mount = /usr/var/lib/lxc/openwrt/rootfs
    ' m9 U! J9 c/ ?7 k  Z1 o
  4. #lxc.rootfs.path = overlayfs:/opt/upt/framework1/rootfs:/opt/upt/apps/openwrt-rootfs
    ' r9 \. J3 U2 h# u8 g2 ]5 Z! O
  5. lxc.rootfs = /usr/var/lib/lxc/openwrt/rootfs
    $ o# p  Z8 w$ @  t2 ]. Q- Y  ]
  6. lxc.haltsignal = SIGUSR1
    # ?$ }* Q. x0 D  ^" m+ g+ w8 f
  7. lxc.tty = 1
    , e4 N4 T# u- d& m" \! F# N3 h7 H  _
  8. lxc.pts = 1& E; \: h9 A! U% g
  9. #lxc.hook.pre-start = /usr/var/lib/lxc/openwrt/pre-start.sh) {* d) W! O( `3 R+ |# K& a8 i" c
  10. lxc.aa_profile = lxc-container-default-with-nesting5 D; t' x9 O5 I  Q& U# z
  11. lxc.network.type = none# R! W8 m5 M  P4 s: Z) h/ C! U
  12. lxc.mount.auto = cgroup-full:rw! O  H3 r* e1 |0 v; n0 Z
  13. #lxc.mount.auto = proc sys cgroup1 ^: j8 V/ ], [+ l
  14. lxc.mount.entry = sysfs sys sysfs defaults 0 0: O) Q" ~1 d$ @
  15. lxc.mount.entry = proc proc proc defaults 0 0
复制代码

( [" z/ w% Q" G- ?7 U3 I  z) O9 \. \( W- y
5、启动,根据提示按enter进入控制台。! n; t+ O. D$ [" R; \. `4 \, w; [
  1. root@F650A:~ # lxc-start -n openwrt% [% p9 D) _% x( ^
  2. <6>init: Console is alive& \) v1 X/ I0 h
  3. <3>init: Failed to redirect stdin to /dev/null: No such file or directory0 `$ h& \8 [  N3 F
  4. <3>init: Failed to redirect stdout to /dev/null: No such file or directory- B& b$ l5 v& V) A! u# z
  5. <3>init: Failed to redirect stderr to /dev/null: No such file or directory! y; y+ e: v5 B( N
  6. <6>kmodloader: loading kernel modules from /etc/modules-boot.d/*: E6 [" j# D( @2 V9 B" S
  7. <6>kmodloader: done loading kernel modules from /etc/modules-boot.d/*, {4 C$ v( _3 z+ Z1 L3 c
  8. <6>init: - preinit -' A$ U: H; K) }3 o! `
  9. ls: /etc/board.d/*: No such file or directory
    $ J4 B' O8 a% u) T% }4 J
  10. Press the [f] key and hit [enter] to enter failsafe mode
    1 V2 X  ]# r( Z" C6 i
  11. Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level8 w( _: |8 D( i% D
  12. <3>mount_root: Could not open mtd device: /dev/mtd12
    % Z5 \( r* V  [9 X* \4 k
  13. <3>mount_root: reading rootfs failed
    ' I5 }* p: M3 I+ w7 a. _
  14. <5>mount_root: mounting /dev/root' w+ j5 @6 }( l# T
  15. urandom-seed: Something is wrong with /dev/urandom
    , C: [6 G' a( \( h
  16. <6>procd: - early -0 w: e# v" E) z$ C# v) r! t
  17. <6>procd: - ubus -
    9 s+ U3 _# K- e
  18. <6>procd: - init -
    7 c1 W) [2 W0 ]! Q  O
  19. Please press Enter to activate this console.
    ( o9 Z& u( W9 W# C
  20. <6>kmodloader: loading kernel modules from /etc/modules.d/*
    6 X' s- _" R* p/ A% f2 K& a# ~3 {
  21. <6>kmodloader: done loading kernel modules from /etc/modules.d/*
      K1 {% A5 J! P
  22. <6>urngd: v1.0.2 started.
    , o4 K9 B$ l2 a
  23. $ Z* O/ M* F, t' d' N. T5 @

  24. 2 [' p2 X: j6 U- q" G
  25. % x2 K! e8 `, ^4 N9 b; a
  26. BusyBox v1.35.0 (2022-04-20 10:37:37 UTC) built-in shell (ash)
    & \& p4 i6 k# i" x
  27. 5 `+ O$ y8 \8 Y
  28.   _______                     ________        __) ?8 C- `+ m5 C; y) z6 o, k. C
  29. |       |.-----.-----.-----.|  |  |  |.----.|  |_
    8 F8 R' U; R& Q" A2 g. A
  30. |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
    " f# o  A/ q% Y  N; E  @
  31. |_______||   __|_____|__|__||________||__|  |____|9 B2 |( r+ \9 n1 v/ @- M* L
  32.           |__| W I R E L E S S   F R E E D O M
    + U6 j) z) T! l4 H" }
  33. -----------------------------------------------------
      F5 ^4 q  X! q8 s! ~
  34. OpenWrt 22.03.0-rc1, r19302-df622768da: U8 M6 L7 L/ Y! H
  35. -----------------------------------------------------' L5 g1 F! Z" p1 J$ |
  36. root@openwrt:/#
复制代码

' ~6 v, }$ O% {0 s5 O( x* w
5 l/ B8 n% ~$ W* I: s
  1. root@openwrt:/# ps
    & w# y$ Y3 A! ^( L
  2.   PID USER       VSZ STAT COMMAND
    4 \$ J# |! S( g' g2 F8 y
  3.     1 root      1452 S    /sbin/procd
    5 w* h8 W' Z- R* I
  4.    58 ubus      1112 S    /sbin/ubusd. z. ~: Z/ Y4 F, T
  5.    59 root      1196 S    /bin/ash --login
    : [6 ]5 C& }" c9 G; t& O
  6.    93 root       908 S    /sbin/urngd
    ; s) O; \" Z7 k5 ~$ E
  7.   204 root      3736 S    /usr/sbin/uhttpd -f -h /www -r OpenWrt -x /cgi-bin -u /ubus -t 60 -T 309 ?0 d& I) u3 V
  8.   487 root      1952 S    /sbin/rpcd -s /var/run/ubus/ubus.sock -t 30( o" h  N# q/ H# F  K5 y  J
  9.   556 root       956 S    /usr/sbin/dropbear -F -P /var/run/dropbear.1.pid -p 22 -K 300 -T 3
    / H$ Z; T) |' t+ u' ?: |: P* P, T
  10. 1065 root      1200 R    ps" _) H" O. z- Q1 @
  11. root@openwrt:/#
复制代码
0 J/ N3 ]' ]7 g, n& V7 i( o

% e( j+ L4 U" y7 n7 R* ^
  1. root@openwrt:/# opkg update8 E7 C' M: b" [  B! ]
  2. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/targets/bcm53xx/generic/packages/Packages.gz
    8 z1 G+ P0 h# S. F* t' n
  3. Updated list of available packages in /var/opkg-lists/openwrt_core! X7 ~+ w5 g2 ~6 M  s( D7 p
  4. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/targets/bcm53xx/generic/packages/Packages.sig
    ( _, q9 z0 n$ M0 Q4 T: Q
  5. Signature check passed.) @/ |! e. K( Z# l* ^3 [9 g
  6. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/base/Packages.gz
    3 j' o7 I: |- w0 n
  7. Updated list of available packages in /var/opkg-lists/openwrt_base
    4 ~$ p# u+ w8 I' @0 D
  8. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/base/Packages.sig
    / N2 G/ M. O5 k- D: t' t( G
  9. Signature check passed.
    * }1 v" ]0 _$ ?- P: p& p% Y
  10. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/luci/Packages.gz
    & H) K& v/ s1 J, ^- G% F  |
  11. Updated list of available packages in /var/opkg-lists/openwrt_luci
    5 @0 g/ {. M! E, n8 d2 A
  12. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/luci/Packages.sig
    ) N; {# B5 d* E$ v) S+ B
  13. Signature check passed.
    ; w6 c9 y4 Z1 l
  14. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/packages/Packages.gz
    " g/ I# t/ K5 Q9 y& G1 n3 @
  15. Updated list of available packages in /var/opkg-lists/openwrt_packages) V" {+ R! Z! v! r
  16. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/packages/Packages.sig8 g# E: m6 _/ y6 U, l
  17. Signature check passed.
    ! t3 i- `, n! z0 [# |
  18. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/routing/Packages.gz1 N9 [6 F1 `6 x* S/ v% Y
  19. Updated list of available packages in /var/opkg-lists/openwrt_routing
    & y# U9 ~' b+ w1 \  j
  20. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/routing/Packages.sig; g8 j6 {& m# k1 e* k- n2 D
  21. Signature check passed.
    " x4 P. \2 l$ F& f6 X
  22. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/telephony/Packages.gz) V& s! F' j3 a9 m' H, s: j8 Y
  23. Updated list of available packages in /var/opkg-lists/openwrt_telephony
    ; m: Y' }! D- n: Y$ e# V
  24. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/telephony/Packages.sig- x) C( A  @6 U: T! H7 i( |$ e3 G
  25. Signature check passed.
    2 _/ d+ h! O8 [4 G7 H+ `/ g
  26. root@openwrt:/#
复制代码

- P2 P1 J1 e( ?% S+ E% w, i9 O
  J9 M( f- Q% h. ?% W( q8 ^此时临时的openwrt系统已建好,运行的服务有两个:http占用主系统的80和443端口,ssh占用22端口。7 d# C; b" ^) w4 ~. v

2 {* _- u/ H/ ^: `3 L9 \3 x4 t- e如果光猫有公网IP,请务必关闭ssh密码登录并使用密钥。5 X- w8 f: \8 n

6 E% g, L& R" y, J; c0 m4 {后期使用建议使用 lxc-start -dn openwrt 后台启动,使用 lxc-stop -kn openwrt 命令关闭。openwrt管理使用ssh密钥登录。
) }/ H% T' O! d, Y' O3 C5 Z需要固化openwrt到固件的,可以打包rootfs和config(需修改配置),mksquashfs制作成squashfs,用mtd写入saf分区,就不用担心恢复出厂设置了。, X* W. `) j+ l9 ?4 {; V9 m
随光猫启动可以参考二楼。
' n$ {) P& x/ Y2 m1 \# N7 S; z; N! i

本帖子中包含更多资源

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

×
 楼主| 发表于 2022-4-27 23:10:13 | 显示全部楼层
因光猫原系统的busybox功能不完整,也没有nano和dropbear,调试lxc可能会不方便,现分享出来。' \8 R9 O; z: Y% j+ L+ P
) t2 V& @# R1 }
  1. root@F650A:~ # /usr/bin/busybox
    # h+ K! B4 w' D6 u7 E
  2. BusyBox v1.23.2 (2020-06-16 16:53:26 CST) multi-call binary.) ?- @. J) R# R* ~" H( \$ ^5 Y
  3. BusyBox is copyrighted by many authors between 1998-2012.( O# H( e9 R' e7 E& u) p
  4. Licensed under GPLv2. See source distribution for detailed, `% S- f9 o5 l
  5. copyright notices.
    1 K) @3 U2 G" w+ J* l: m

  6. " u' W4 S+ f) R% C0 K( n2 u
  7. Usage: busybox [function [arguments]...]
    3 C( K+ L- L: l+ J/ X# G8 {
  8.    or: busybox --list[-full]
    2 j0 l7 A+ _+ n  S; ~& P
  9.    or: busybox --install [-s] [DIR]* Z, k* |9 ~) L4 K# E, e
  10.    or: function [arguments]...
    ; q# B5 k2 w2 _% n) u
  11. : }* \# x1 ~9 `$ H4 A1 P+ ]9 Q) u
  12.         BusyBox is a multi-call binary that combines many common Unix
    . G2 V# z3 P- Z+ P
  13.         utilities into a single executable.  Most people will create a
    / N8 P8 P  f' k! T: b) p4 ^' V
  14.         link to busybox for each function they wish to use and BusyBox
    ; u% r2 Z5 v8 p) P8 l
  15.         will act like whatever it was invoked as.
    0 Q8 q* H+ M1 q" E0 r) T
  16. 9 m8 i$ x# B2 f7 {9 H9 |
  17. Currently defined functions:1 F+ Q3 K4 @' v9 I+ u( S) Y- N* c0 z
  18.         [, [[, addgroup, adduser, ar, arp, arping, ash, awk, basename, blkid, brctl, bunzip2,5 t. c; R. i: d  X0 P+ I
  19.         bzcat, cat, catv, chattr, chgrp, chmod, chown, chroot, chrt, chvt, cksum, clear, cmp, cp,
    1 X0 Y, k. l" V3 J
  20.         cpio, crond, crontab, cut, date, dc, dd, deallocvt, delgroup, deluser, depmod, devmem, df,
    ( v8 S; ~+ z7 A, I  J0 i- n+ t6 j
  21.         diff, dirname, dmesg, dnsd, dnsdomainname, dos2unix, du, dumpkmap, echo, egrep, eject, env,8 M5 I! o3 X& |8 J1 n% l# i2 I
  22.         ether-wake, expr, false, fbset, fdflush, fdformat, fdisk, fgrep, find, flock, fold, free," d' e# u& A5 n, \0 f) j) \/ |2 o
  23.         freeramdisk, fsck, fstrim, fuser, getopt, getty, grep, gunzip, gzip, halt, hdparm, head,
    . {- k$ T0 M& b( M# @
  24.         hexdump, hostid, hostname, hwclock, id, ifconfig, ifdown, ifup, inetd, init, insmod,1 D$ j4 b: _% [6 U
  25.         install, ip, ipaddr, ipcrm, ipcs, iplink, iproute, iprule, iptunnel, kill, killall,; }  R6 A) w" _7 w, n; e$ _# Y, u) Z
  26.         killall5, klogd, last, less, linux32, linux64, linuxrc, ln, loadfont, loadkmap, logger,
    % c, u* I* h% H7 g: c
  27.         login, logname, losetup, ls, lsattr, lsmod, lsof, lspci, lsusb, lzcat, lzma, makedevs,1 R/ v6 h+ P. [* F
  28.         md5sum, mdev, mesg, microcom, mkdir, mke2fs, mkfifo, mkfs.ext2, mknod, mkswap, mktemp,+ _4 i# I  w- y/ N- L0 R( N
  29.         modinfo, modprobe, more, mount, mountpoint, mt, mv, nameif, nanddump, nandwrite, netstat,: h3 Q# n4 p; C# L4 n( g/ A
  30.         nice, nohup, nslookup, od, openvt, passwd, patch, pidof, ping, pipe_progress, pivot_root,
    * p2 Y- D- J) }
  31.         poweroff, printenv, printf, ps, pwd, rdate, readlink, readprofile, realpath, reboot,; L2 t: d* h' Y. _4 A/ M
  32.         renice, reset, resize, rm, rmdir, rmmod, route, run-parts, runlevel, sed, seq, setarch,
    5 C: J0 Z9 w$ W7 |' M3 C0 W; X/ D$ V1 m1 v
  33.         setconsole, setkeycodes, setlogcons, setserial, setsid, sh, sha1sum, sha256sum, sha3sum,
    1 s& N! k0 q$ k3 d9 l
  34.         sha512sum, sleep, sort, start-stop-daemon, strings, stty, su, sulogin, swapoff, swapon,% t$ r2 F! l5 S! o
  35.         switch_root, sync, sysctl, syslogd, tail, tar, tee, telnet, telnetd, test, tftp, time, top,6 P/ M7 U& m6 Q) {) P
  36.         touch, tr, traceroute, traceroute6, true, tty, ubiattach, ubidetach, ubimkvol, ubirmvol,
    9 n. v: j+ ?4 N, y% W
  37.         ubirsvol, ubiupdatevol, udhcpc, umount, uname, uniq, unix2dos, unlink, unlzma, unxz, unzip,
    # Y3 Y2 Z, q! L( B* v( \, I
  38.         uptime, usleep, uudecode, uuencode, vconfig, vi, vlock, watch, watchdog, wc, wget, which,
    1 j1 G  f# y, U0 B
  39.         who, whoami, xargs, xz, xzcat, yes, zcat
    3 B2 r& f: H1 N& N

  40. " Y' h. ~0 T* G, k8 p
复制代码
  1. root@F650A:~ # nano -h
    6 h; C0 N1 S1 l& x  C
  2. Usage: nano [OPTIONS] [[+LINE,COLUMN] FILE]...
    ' s0 e3 j* r- R

  3. : o) i4 v, u+ S. G
  4. Option          GNU long option         Meaning
    9 u7 ^( K+ s% H) H: ?! [4 `
  5. +LINE,COLUMN                           Start at line LINE, column COLUMN
    4 j0 _( t/ ]) p7 ^
  6. -D             --boldtext              Use bold instead of reverse video text. I+ |2 U( {" @. d) t- S6 L; A
  7. -K             --rebindkeypad          Fix numeric keypad key confusion problem- M3 Q: X* V4 K6 J$ k) |4 t: p+ `
  8. -L             --nonewlines            Don't add newlines to the ends of files
    . s' K$ O2 ?" Y
  9. -O             --morespace             Use one more line for editing$ X# V7 m* V& E1 Y' J$ l8 C
  10. -R             --restricted            Restricted mode, \0 r2 S7 L4 g4 y
  11. -T <#cols>     --tabsize=<#cols>       Set width of a tab to #cols columns
    1 S. \- z- H+ a& J3 z
  12. -V             --version               Print version information and exit
    5 y, E% K$ Q7 B
  13. -c             --const                 Constantly show cursor position  A, E( I: o* ?/ X" m/ k0 I
  14. -d             --rebinddelete          Fix Backspace/Delete confusion problem
    , z, q% f( N0 P8 k+ O: F1 o5 M
  15. -h             --help                  Show this help text; `7 {# H) j7 g  C
  16. -l             --nofollow              Don't follow symbolic links, overwrite
    & Y' |0 n6 |6 W4 y9 H5 M% K: G* ]$ E
  17. -n             --noread                Do not read the file (only write it)
    + t+ l: f4 V( O- {3 s" V9 ]
  18. -p             --preserve              Preserve XON (^Q) and XOFF (^S) keys$ e+ X, s/ a* O1 @. R& _7 D
  19. -t             --tempfile              Auto save on exit, don't prompt
    3 u1 k8 U& v7 e8 |" I4 _
  20. -v             --view                  View mode (read-only)
    & [" b; i5 y7 q2 e, x
  21. -x             --nohelp                Don't show the two help lines' p8 w3 a3 y4 f& a/ I/ S0 g; B
  22. -z             --suspend               Enable suspension$ j6 Z+ z0 ^! D$ n
  23. root@F650A:~ # nano -V9 W  \5 m% m3 g. U5 \! e
  24. GNU nano, version 2.4.2
    $ o" X) ?5 D- M; d, A* ?( K
  25. (C) 1999..2015 Free Software Foundation, Inc.- A" v4 k) I7 k$ l; a" ^
  26. Email: nano@nano-editor.org    Web: http://www.nano-editor.org/
    3 k: y' H' V$ g- E
  27. Compiled options: --enable-tiny --disable-utf87 Y' A$ j: s) z
复制代码
  1. root@F650A:~ # dropbear -h; y- S& H! W9 s4 F8 f$ m! z+ T/ @
  2. Dropbear server v2015.67 https://matt.ucc.asn.au/dropbear/dropbear.html! x( q1 U! w0 r+ ^. I
  3. Usage: dropbear [options]6 q) N5 Y1 |6 [$ n
  4. -b bannerfile   Display the contents of bannerfile before user login
    7 Y0 i% U  i6 l  ^2 B- }5 U
  5.                 (default: none)
    & V+ T# i. h, U4 N
  6. -r keyfile  Specify hostkeys (repeatable)
    ' \+ }) x! }. ?& i: t
  7.                 defaults:! D1 j2 h& _  A$ |
  8.                 dss /etc/dropbear/dropbear_dss_host_key
    ' w/ V8 n8 b! U# J) j/ U& h
  9.                 rsa /etc/dropbear/dropbear_rsa_host_key
    ' U6 p, U( M* L1 p, z
  10.                 ecdsa /etc/dropbear/dropbear_ecdsa_host_key( K+ ~2 o. T" h: S. D2 F, y
  11. -R              Create hostkeys as required" N7 ~* d4 k4 ]2 [* ~5 `! P
  12. -F              Don't fork into background
      x6 t" V$ T3 T: \* I
  13. -E              Log to stderr rather than syslog  k: T: l" S1 o) K6 O1 p
  14. -m              Don't display the motd on login# ]. o3 e7 f1 \2 t
  15. -w              Disallow root logins
    + {- ]- L7 H! j! q
  16. -s              Disable password logins, j: n" z: ~* ^2 M% U; j- E. S
  17. -g              Disable password logins for root
    $ q3 L2 u& I5 c1 t
  18. -B              Allow blank password logins
    # o" B+ q0 c; t: \  k, N1 b
  19. -j              Disable local port forwarding0 k; l2 f7 Y# M
  20. -k              Disable remote port forwarding
    + D3 \- _! p; W
  21. -a              Allow connections to forwarded ports from any host$ t; k! D: G( u
  22. -p [address:]port
    1 m( e4 |/ q: b- k' N1 p- C# G/ ?
  23.                 Listen on specified tcp port (and optionally address),. q7 G& b3 }  `# O7 F$ F7 R
  24.                 up to 10 can be specified/ w# x5 u+ k+ `9 j
  25.                 (default port is 22 if none specified)
    " b* X5 k- M+ H5 M  s5 F* t
  26. -P PidFile      Create pid file PidFile
    $ v& T% Q- t# u2 M' e# G! g/ u
  27.                 (default /var/run/dropbear.pid)) q0 p1 w6 m- O9 `) `. n  x! n
  28. -i              Start for inetd
    " I3 G" c+ M: x
  29. -W <receive_window_buffer> (default 24576, larger may be faster, max 1MB)8 m8 ~* h. }6 R) M
  30. -K <keepalive>  (0 is never, default 0, in seconds)
    - k$ R, Q4 b+ O7 _% ?4 N" b
  31. -I <idle_timeout>  (0 is never, default 0, in seconds)
    9 I7 Y1 J* F/ ~' l+ c
  32. -V    Version2 }' r" R1 `+ r; {2 `$ v
复制代码
0 y4 ]  b; z4 f" H# [. G9 M

5 y- d+ p$ P, r( P; E

本帖子中包含更多资源

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

×
发表于 2021-11-27 21:38:54 | 显示全部楼层
本帖最后由 btworm 于 2021-11-27 21:41 编辑 $ P4 Z* Z4 \+ d) b# b* q
songee 发表于 2021-11-27 04:15
2 M7 M3 f" a8 C$ y( j" d1.只要lxc相关命令可以正常运行,写好配置文件,选择符合CPU架构的rootfs,就可以把容器跑起来。+ j  U6 K/ I, W7 Q
2.我的 ...

1 ~' a& a1 P  r2 k0 j感谢指点!
) ~1 B6 o. v/ C+ |3 T: n$ e2 E4 y$ q! O& i9 U$ z* @# H1 F
关于第2点8 l* `* Q2 M( k" U4 }% M
华为光猫 / 只读,/etc,/usr,/lib这些目录也都依附于/, 所以都不可写, /opt目录不存在,当然也无法创建。0 m1 I1 O8 ]3 x4 y( T& W; I
5 L2 g: C( ^2 O
之前担心/dev/pts, /proc, /sys只读,是因为以前玩路由器时,有个chroot脚本使用过这些目录,刚又看了遍那个脚本,使用的是 "-o bind"参数,所以主机目录是否可写就无所谓了。在华为猫上跑lxc应该没问题了8 H2 _2 }7 ~% W0 |; L3 Y7 p
8 U# x+ `% n$ x9 n
另外想问问,光猫容器内的应用对端口的监听是:
8 A- _( C9 D& `( t3 e1.直接监听光猫的端口?8 L& e7 {0 K6 c8 Z) M
2.还是只能监听容器内的端口,并需要光猫iptables做端口转发给容器?
 楼主| 发表于 2020-2-22 18:37:10 | 显示全部楼层
anysoft 发表于 2020-2-22 17:50
) @7 |; Y" N2 i5 @1 c; MHS8145V HS8145V5  F650A 都是512MB+256MB 2.4G+5G方案# ~+ R5 s; [" [. I
价格都还好,特别F650A 因为会玩的人少价格特别便 ...

4 v5 e8 j! W0 T9 chs8145v技术成熟,更适合玩,而且其实f650a是512/128,nand flash少了一半,CPU一个尿性,价格差别不大的话,能hs8145v还是别选650。
0 x* k1 W. B- ?还有个大胆想法,lxc可以通过配置文件config修改子系统网络,从eth0桥接是不是就能在子系统多拨了,子系统专门离线和网络存储,不影响猫后面接的手机电脑上网,还是蛮有趣的
" J* ^) c7 e+ i2 b/ j8 i; h1 W3 i1 J- f1 H' W0 C/ K

& a3 l1 p% r. V2 z  Z, N1 c, ~! w, p( f5 z- v5 d
 楼主| 发表于 2020-2-17 02:19:26 | 显示全部楼层

二楼原帖,仅保留做参考

本帖最后由 songee 于 2022-4-27 21:17 编辑
9 y; k) h3 w: m0 S3 g1 L  ^( n+ }, d" U+ m- C
0 t/ x% j  I; p* j
(2020年原帖初步摸索,过程过于繁杂,不建议再按这部分思路操作)* X& n3 S$ R- m9 ]6 U
中兴、华为等带有saf模块的光猫,以官方版openwrt替换厂商定制版的思路总结一下,供大家参考。' u& V% |7 f( M
1、准备工具- d! y9 t2 f1 F7 V! H% b' v
    F650A主系统没有 mtd 、 dd 和 vi 等工具,而自带的saf子系统正好都有,子系统位于framework分区即mtd6,挂载于/opt/upt/framework,cp过来可以直接使用。
root@F650A:~ # cp /opt/upt/framework/saf/rootfs/sbin/mtd /usr/bin/
8 N' ]& S1 y$ g1 O8 Mroot@F650A:~ # cp /opt/upt/framework/saf/rootfs/lib/libubox.so /lib/
! @5 {0 B. E' a2 T  I6 groot@F650A:~ # cp /opt/upt/framework/saf/rootfs/bin/busybox /usr/bin/, s6 R; y  s# y- t" Q4 _' y0 p
root@F650A:~ # cd /usr/bin/, ^2 s! f+ V1 {# s
root@F650A:/usr/bin # ln -s busybox dd9 d) B' g# H; M8 W& W; B
root@F650A:/usr/bin # ln -s busybox vi

4 f: F  p$ K) ]" @2、改进lxd-openwrt生成代码。
* K7 [% V" m$ {. N    本节参考https://github.com/mikma/lxd-openwrt,系统推荐Ubuntu 18.04以上。目前该项目支持x86_64|i686|aarch64架构,而F650A的CPU型号 ZTE ZX279128 的架构是 ARMv7 Processor rev 1 (v7l) ,不属于以上三种,只能调整build.sh部分代码。ZX279128架构bcm53xx的相同,借用它的SDK。可以git clone 或者网页内 Download ZIP,我浏览器挂的有代理,网页下载之后解压,修改build.sh。修改后的build.sh与原文件build.sh.origin的diff如下
9 e1 B2 ]) {% N( H; O
*** build.sh                2020-02-19 01:50:10.972675562 -0100
& ?! p2 W* v) A, s--- build.sh.origin        2020-02-14 19:10:45.000000000 -0100
; T" c7 H& H$ i7 h***************
* q) ?% \% G2 E0 B& d*** 72,81 ****! {/ l; s. d$ q) |. I. O3 Q
                  subarch=64- u0 X8 t7 M4 |3 r# R/ \
                  arch_ipk=x86_64
7 E( {, N6 W# t* a6 [, A                  ;;! o% u9 a4 F1 |% s6 K* I
!         arm)
5 R: {' ^! b& }5 S7 J2 W/ N!                 arch=bcm53xx
. q2 S) `9 b( V5 r5 {0 k' H/ a!                 subarch=generic4 I( F4 F: w+ J& V3 v3 ]
!                 arch_ipk=arm_cortex-a9
- g" m" \5 D- M( s3 h! i1 ^                  ;;
5 Q  _3 ]: {; D( [" C0 l' H! p2 `. n3 Z          *)/ S. T9 @& s3 D  I
                  usage
+ h$ a% _; {  U( i4 p--- 72,81 ----
' r+ b7 S. l8 L6 y9 s( f& z                  subarch=64, X4 ]( t5 n  F/ u5 M
                  arch_ipk=x86_64
  B/ o3 F+ j" k5 {. ]# n                  ;;6 g" Z5 t! i6 V- \
!         aarch64)
# m! t2 y; x* D! p( U8 p!                 arch=armvirt1 p" `  A' G7 _8 q, K8 T# N
!                 subarch=64
! r! n4 d$ n8 ?8 c/ d2 f, m! s!                 arch_ipk=aarch64_generic
, p# w; c5 j; a: u  M                  ;;
6 ^( I3 o7 f; x3 Y+ |          *)
6 y6 K8 v9 Q  H- l2 @                  usage, u3 T' G, w3 f# ^
***************
0 {' k# f4 y' K0 k*** 87,97 ****
4 Q( O8 E/ m4 m- {8 e# w  if test $ver = snapshot; then0 A# p# b( ~  E
          openwrt_branch=snapshot
- u. {  B" c8 q' E          procd_url=https://github.com/openwrt/openwrt/trunk/package/system/procd
% p* a" P* {$ [8 i) Q3 A1 t!         openwrt_url=https://mirrors.cloud.tencent.com/lede/snapshots/targets/${arch}/${subarch}
- R" |9 E- z- |& a  else7 @8 G7 J3 i. a. [3 C! s' j( H
          openwrt_branch=${dist}-${branch_ver}
' Z! f# ?0 [: [  j# @0 ^7 ?  x8 V          procd_url=https://github.com/openwrt/openwrt/branches/${openwrt_branch}/package/system/procd7 ^6 V% D0 K  b
!         openwrt_url=https://mirrors.cloud.tencent.com/lede/releases/${ver}/targets/${arch}/${subarch}  \, Z* I; l8 K2 o
  fi- Q* I2 z9 u) g3 j/ Y
  
) [" o$ F8 T' G( t' w% \  procd_extra_ver=lxd-3/ r8 X: b( H( t# A4 H# n6 I
--- 87,97 ----& U6 z2 l+ S: V9 s% h! j3 U
  if test $ver = snapshot; then2 y+ u" u9 }% J5 E* r
          openwrt_branch=snapshot7 E5 R$ y( E2 ^; k. w0 ^
          procd_url=https://github.com/openwrt/openwrt/trunk/package/system/procd
4 v! f+ U5 E/ i2 F* y1 A$ C. y" ~0 |!         openwrt_url=https://downloads.openwrt.org/snapshots/targets/${arch}/${subarch}
  g) @- H+ S0 E! m* M( W6 Y  else; ^0 _: D$ r* y0 Q/ L" A
          openwrt_branch=${dist}-${branch_ver}: L7 q' x: ?# m9 R
          procd_url=https://github.com/openwrt/openwrt/branches/${openwrt_branch}/package/system/procd
. ?5 W# }' y7 ^' ^& i. z$ b" o!         openwrt_url=https://downloads.openwrt.org/releases/${ver}/targets/${arch}/${subarch}5 a# ~+ Q$ v4 E; O6 \
  fi
( G& m: S# m( t' m! P  
" r# x# Q' [, i- b5 `  procd_extra_ver=lxd-3; j- T7 |7 u' l% F+ [' X
***************5 b  D! \/ g  J: F1 D1 P
*** 112,125 ****
4 A* z) ?4 o# `7 W3 ]/ K" h  }
1 t8 S8 T4 N* C! D; p  ) F6 w+ P# i# U3 [# l
  download_rootfs() {
- r9 J5 a# S0 K$ h! C7 B! #        detect_url "rootfs\.tar"
5 b$ v, l8 u& ~7 O! M( E! #        local rootfs_url=$openwrt_url/$return4 b$ g" n3 {! Q  ^
  
/ s& R* W, a6 I9 x          # global $rootfs
2 |2 m( I- U0 Q6 |/ j!         rootfs=dl/openwrt-19.07.1-bcm53xx-generic-rootfs.tar.gz( K5 ^* [% i9 k, S- U
  4 y3 k( ~9 M7 O
! #        download $rootfs_url $rootfs $rootfs
9 X8 w2 T3 }. g3 O! #        check $rootfs $rootfs_url9 C0 c4 A% }- T) i2 ^
  }
" {& p. f+ o, t  
6 W0 O. K0 B& P  Q  download_sdk() {
) f+ ~4 o, z3 D2 ^/ [" y8 T--- 112,125 ----  _2 ]! [" d" [0 Q' V4 U
  }
/ ~3 ]1 D3 k: V* D( P3 A  
8 [) p( Y$ E& S) F; R  download_rootfs() {
- N# L: @" V' s$ a% S8 U!         detect_url "rootfs\.tar"8 Y& a; I/ h, D& G# ^7 H7 l" _
!         local rootfs_url=$openwrt_url/$return
$ e( G' A. `$ a' W5 S  V& ^  & Y' o6 b& |( j) Y7 c* ?
          # global $rootfs
. @' ]" d! h* |: A8 Y$ |!         rootfs=dl/$(basename $rootfs_url)
  n- K: a6 x: o! `$ ^( x9 j* `# l  
7 h8 e+ _. _# F!         download $rootfs_url $rootfs, P4 V3 d; ]8 p( U# U
!         check $rootfs $rootfs_url
* B8 A# U( K5 v9 l  }4 C( N+ _8 q0 J& f6 l1 v
  * d7 B( j6 L/ W; J+ `0 U% r
  download_sdk() {
! f/ a- Y; x, S! q2 E
3、从腾讯镜像下载openwrt-19.07.1-bcm53xx-tplink-archer-c9-v1-squashfs.bin,从固件中提取rootfs并预处理。! C3 s/ Z; T- k9 H4 }
  1. x@x-Surface-Pro-3:~/下载$ binwalk openwrt-19.07.1-bcm53xx-tplink-archer-c9-v1-squashfs.bin ; \& J- F# h( r  k
  2. % o! W% v7 x3 ]( l0 W
  3. DECIMAL       HEXADECIMAL     DESCRIPTION/ Q% ~" p: g, P2 f
  4. --------------------------------------------------------------------------------
    ) X- U4 J! n9 P( i' u# m6 Y3 ]0 o
  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) S, r2 L# d" C$ K- G: |+ v8 r+ E
  6. 8345          0x2099          LZMA compressed data, properties: 0x5D, dictionary size: 65536 bytes, uncompressed size: 1801662 bytes+ y6 Y, {2 `  A. I7 c6 P, }. j! G' k
  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' |- @, f& J9 O4 H0 i* i

  8. 3 R( {; z! h% ^; f
  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=18187490 J" x% v. V% ~  W# n3 ~
  10. 记录了1900548+0 的读入
    2 U: A7 @) x: D
  11. 记录了1900548+0 的写出$ N' W8 w9 `6 ~( i  W# E
  12. 1900548 bytes (1.9 MB, 1.8 MiB) copied, 5.16823 s, 368 kB/s; q$ E. z6 t+ l4 r1 x! [0 F
  13. x@x-Surface-Pro-3:~/下载$ binwalk rootfs-squashfs.bin $ E9 x! L! \8 U( P" Q; D6 U; j. K

  14. $ ]- ^5 i- S1 F  h* I
  15. DECIMAL       HEXADECIMAL     DESCRIPTION/ e, |# H, M! \: B7 V
  16. --------------------------------------------------------------------------------
    9 k! E1 i# ]! e+ e+ |& O
  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
    + m2 @& a9 t/ H# C9 e1 @, e
  18. # O/ J: U1 Q3 f) E
  19. x@x-Surface-Pro-3:~/下载$ unsquashfs rootfs-squashfs.bin 7 Q+ {+ t& u9 F1 M7 a7 ~
  20. Parallel unsquashfs: Using 4 processors
    $ b; ]! Z: P: ?* p# W. Q" X
  21. 1071 inodes (1066 blocks) to write
    $ B! S! M8 L! E& P6 l
  22. 6 T2 h8 j* o  L0 Z! f5 ]
  23. ) V  F3 [* Y0 Z* Q! r# H0 M( Z
  24. create_inode: could not create character device squashfs-root/dev/console, because you're not superuser!; O) R" M. y; y7 ^. f4 o+ g' y
  25. [====================================================================================================| ] 1065/1066  99%% N% j. G7 G  m% ?9 a$ M& N/ g% _2 _
  26. : z0 m5 Z3 r) y! e
  27. created 875 files
    $ e: D6 R0 S+ Q! F& c5 Y( r! S0 k
  28. created 103 directories
    - |1 F' `/ r) O! I% W# G: R3 k
  29. created 195 symlinks
    ( d3 X  m. C( r" f$ \& F7 n
  30. created 0 devices) _5 ?. z; B! C& x( z
  31. created 0 fifos
    % u/ o# [( Y9 ]- M3 U
  32. x@x-Surface-Pro-3:~/下载$ cd ./squashfs-root/
    5 u6 E. Y" F) y! T" v
  33. x@x-Surface-Pro-3:~/下载/squashfs-root$ gedit etc/opkg/distfeeds.conf
复制代码
将opkg软件源改为腾讯镜像
. M- {; L8 {+ H+ E
src/gz openwrt_core https://mirrors.cloud.tencent.co ... xx/generic/packages
  c( B7 j3 _) @. U0 u( Csrc/gz openwrt_kmods https://mirrors.cloud.tencent.co ... 92b7d7eca715b1ee0b8
1 Y* f" t" q: `2 o" Isrc/gz openwrt_base https://mirrors.cloud.tencent.co ... /arm_cortex-a9/base
' v3 @5 T1 b& \' Usrc/gz openwrt_luci https://mirrors.cloud.tencent.co ... /arm_cortex-a9/luci3 X) r8 Q- y1 [8 b" f
src/gz openwrt_packages https://mirrors.cloud.tencent.co ... _cortex-a9/packages: T/ Z8 B6 b& a! A4 r/ l+ d
src/gz openwrt_routing https://mirrors.cloud.tencent.co ... m_cortex-a9/routing
; Z+ z  [# f7 m' ~! s! usrc/gz openwrt_telephony https://mirrors.cloud.tencent.co ... cortex-a9/telephony
  1. x@x-Surface-Pro-3:~/下载/squashfs-root$ tar czf ../openwrt-19.07.1-bcm53xx-generic-rootfs.tar.gz ./# N, `$ e* R  v! q& A
  2. x@x-Surface-Pro-3:~/下载/squashfs-root$ cd ../. p' z; d3 @$ O
  3. x@x-Surface-Pro-3:~/下载$ mkdir lxd-openwrt-master/dl
    ; ?6 s8 P6 K9 O8 }7 H- |+ x
  4. x@x-Surface-Pro-3:~/下载$ mv openwrt-19.07.1-bcm53xx-generic-rootfs.tar.gz lxd-openwrt-master/dl/
复制代码
执行修改过的build.sh6 Z/ r8 d6 ]4 @/ G0 r
  1. x@x-Surface-Pro-3:~/下载$ cd lxd-openwrt-master/" d$ H% @2 \' x
  2. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ ./build.sh -a arm -v 19.07.1
    % Z" j1 }- u: f+ t( [6 n
  3. ......6 e! X$ _3 ^# s  z8 c
  4. Pack rootfs, ?8 J! I0 x- I4 P
  5. Tarball built: bin/openwrt-19.07.1-bcm53xx-generic-lxd.tar.gz/ b( \9 M3 v, T( Z, O
  6. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ mkdir ../openwrt-19.07.1-bcm53xx-generic-lxc
    . P4 Q3 R- }  b
  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 ~* H  x& p
  8. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ cd ../openwrt-19.07.1-bcm53xx-generic-lxc/' d  u  I: p) X8 A' d0 H
  9. x@x-Surface-Pro-3:~/下载/openwrt-19.07.1-bcm53xx-generic-lxc$ ls# d* e; o# C" }
  10. metadata.yaml  rootfs  templates% w% h7 l; [4 K
  11. x@x-Surface-Pro-3:~/下载/openwrt-19.07.1-bcm53xx-generic-lxc$
复制代码

+ |& u+ u; H5 m% I4、这时我们已经创建好lxc下可运行的openwrt19.07.1的rootfs,接下来处理lxc及rootfs的配置文件。2 v/ f" I0 t( u5 E( G$ |4 ]  N9 L  x+ _
进光猫复制自带子系统的两个文件,再通过U盘或ftp传到Ubuntu的openwrt-19.07.1-bcm53xx-generic-lxc目录下,
+ N9 T) v2 m( ~1 T1 B  G
  1. root@F650A:~ # cp /opt/upt/framework/saf/config /mnt/USB_disc1/
    2 l4 U% p, a/ b. M* K
  2. root@F650A:~ # cp /opt/upt/framework/pre-start.sh /mnt/USB_disc1/
复制代码
config为saf系统的配置文件,新系统下稍作修改,6 Y2 N  m6 W3 E! ?
lxc.arch = arm
! ]5 ~3 L4 m1 |, m( @/ W7 }lxc.utsname = openwrt
4 k3 c) ^$ b/ _0 Rlxc.rootfs.mount = /usr/var/lib/lxc/openwrt/rootfs
( {9 f: n- Q+ Blxc.rootfs.path = overlayfs:/opt/upt/framework1/rootfs:/opt/upt/apps/openwrt-rootfs - d8 \( J# @2 Q
# lxc.rootfs = /usr/var/lib/lxc/openwrt/rootfs - ]) `/ e7 f3 r9 _) X
lxc.haltsignal = SIGUSR11 `" t4 ?' ?8 Y" I2 K! Q
lxc.tty = 1- l0 V2 o$ v1 g3 X5 G
lxc.pts = 1
& D7 }6 J0 Z5 ]5 Xlxc.hook.pre-start = /usr/var/lib/lxc/openwrt/pre-start.sh) J5 K+ y$ W. R8 {+ I
lxc.aa_profile = lxc-container-default-with-nesting
: a, @5 {/ a  v% b$ e$ W# Wlxc.network.type = none
  T2 A9 `& E1 G& wlxc.mount.entry = sysfs sys sysfs defaults 0 0
0 ]9 n& W6 q6 C! f4 tlxc.mount.auto = cgroup-full:rw
5 M! \5 b! D+ \* E! m) Z' Z8 Ilxc.mount.entry = proc proc proc defaults 0 0
7 I3 e! K2 d2 f# T4 w% qlxc.mount.entry = /mnt mnt none rw,rbind 0 0
2 N+ |1 n" ~7 P% J" T( Ilxc.start.auto = 1

) Q8 e/ ]4 u5 `8 E9 S( p: Epre-start.sh处理模拟终端,为避免重复挂载devpts,添加一行卸载代码,
, b$ [. H5 P* A1 l: `+ v6 U& U
#!/bin/sh
0 W9 R# ^8 G3 ^6 V9 j! F$ rumount /dev/pts /dev/ptmx
$ _2 {6 i9 m/ `' e& o" u' G* tmount -t devpts -o newinstance -o ptmxmode=0666,nosuid devpts /dev/pts
$ o$ S) t. \7 x/ l* j9 x2 r8 U- Hmount -o bind /dev/pts/ptmx /dev/ptmx
* @, }& Q: Q% r9 V; U" x& w* w
再删除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镜像,
+ S& H$ s# ?9 |
  1. x@x-Surface-Pro-3:~/下载$ mksquashfs openwrt-19.07.1-bcm53xx-generic-lxc openwrt-19.07.1-bcm53xx-lxc.bin" k( i: \) [. c, ~
  2. Parallel mksquashfs: Using 4 processors
    " N8 O6 {& T/ D
  3. Creating 4.0 filesystem on openwrt-19.07.1-bcm53xx-lxc.bin, block size 131072.
    / B) ~6 H$ D5 x9 x) `
  4. [=======================================================================================================/] 881/881 100%/ I. e: c2 N- G$ C2 B

  5. 7 V6 _, S* {1 G, d
  6. Exportable Squashfs 4.0 filesystem, gzip compressed, data block size 1310721 \3 O) J6 z+ q' u
  7.         compressed data, compressed metadata, compressed fragments,
    + q2 c* i; f' X
  8.         compressed xattrs, compressed ids
    ; S$ r/ M% ?- M
  9.         duplicates are removed4 b8 ~8 Y1 z2 \
  10. Filesystem size 3163.90 Kbytes (3.09 Mbytes): H5 d( i: j# z' S! v" P
  11.         48.94% of uncompressed filesystem size (6464.54 Kbytes)
    $ I0 S. M7 f- g/ h$ W
  12. Inode table size 9693 bytes (9.47 Kbytes)
    % K. u' b: i5 p, n& \# ~9 m0 N
  13.         25.72% of uncompressed inode table size (37693 bytes)
    : `2 v4 X7 X* [5 g& j: _4 K. t
  14. Directory table size 11372 bytes (11.11 Kbytes)
      ^6 ?4 Q- k  B1 I$ q+ A8 ~( u6 D
  15.         47.17% of uncompressed directory table size (24108 bytes)1 ~5 O% O5 l0 p9 Y9 P# f1 p. ?
  16. Number of duplicate files found 136
    " H) i! C2 ~  K8 k) b2 m- @
  17. Number of inodes 1145
    * }6 |- K' G! J% V4 O
  18. Number of files 873
    ; a4 J9 ~* a% o! h% N2 b
  19. Number of fragments 399 ]* I- K. S2 W. g, o- v
  20. Number of symbolic links  171
    ! \; A/ w8 r* y8 Z7 q
  21. Number of device nodes 0
    " I5 w- F* ?; M: R8 f) u
  22. Number of fifo nodes 0
    " w# r0 l. M8 v" A& b8 O
  23. Number of socket nodes 0- e- W$ M3 e. y# z% b. O
  24. Number of directories 101
    4 d9 J; X) o7 R; e
  25. Number of ids (unique uids + gids) 1
    8 j. B" w2 L+ ^( \4 K
  26. Number of uids 1
    / |3 D$ K0 A; v7 V3 b; {- i
  27.         x (1000)
    1 z9 X; p) }. b- o% w/ t( L
  28. Number of gids 12 j( @* O/ M& C
  29.         x (1000)
    . L+ n1 J3 b: }4 @) F& F) L$ b
  30. x@x-Surface-Pro-3:~/下载$
复制代码

) {4 f, i3 n0 @1 ^1 P: p# l
6 O8 p  S  P9 C. c# C5、生成的openwrt-19.07.1-bcm53xx-lxc.bin传入光猫,'mtd' 写入mtd7分区。
( Q5 }$ C$ I6 }7 U! |4 c2 R. m刷之前先关掉saf,因saf有lxc-monitord进程守护,kill掉之后会自动运行,只好修改saf程序名,重启光猫。* U' z5 A# G3 ]" W( i  ]; z
  1. root@F650A:~ # mv /usr/sbin/saf /usr/sbin/saf.bak
    , g6 }* c4 c. J# v7 P
  2. root@F650A:~ # reboot
复制代码
重启后telnet登录,'ps' 确认进程列表没有saf,备份然后写入并挂载。
root@F650A:~ # ps% v& @  y- i% y7 N- V. h# ~
  PID USER     VSZ   RSS  STAT  CPU COMMAND4 S% ^9 n" U4 q' L5 G9 P/ S
    1 root     23160   600  S     <1>  init
) g5 _2 {8 k$ N    ......
+ h/ P+ X2 p# a' a' f( k3 @. G! ~root@F650A:~ # dd if=/dev/mtd7 of=/mnt/USB_disc1/mtd7.bin bs=1M
' H+ x" s. ~( @8 W: b8+0 records in8 b8 ^, _2 N* u6 K" H: m
8+0 records out8 g( n7 R7 A; h5 }  Y7 G0 ~
root@F650A:~ # mtd write /mnt/USB_disc1/openwrt-19.07.1-bcm53xx-lxc.bin /dev/mtd7, z3 u( h8 b7 w  c- P
Unlocking /dev/mtd7 ...9 W! l1 J% N1 F6 ]. H
) n; K& X: K1 F, a+ E) G; q5 P2 G
Writing from /mnt/USB_disc1/openwrt-19.07.1-bcm53xx-lxc.bin to /dev/mtd7 ...
! \. r" Y$ i6 m5 F% G; [root@F650A:~ # mount /dev/mtdblock7 /opt/upt/framework1

( O7 ~9 o+ j* s' h6、开启OpenWRT新世界
8 \6 y6 R1 u2 T' v    写入mtd7分区并挂载之后,开始首次启动的准备工作。F650A的lxc默认路径在/usr/var/lib/lxc(一楼有说明),按config文件创建相应文件及文件夹,2 ?& r1 n: T' M% ~  m# |
  x7 Y) n% L! W8 Z6 n9 e/ W, v
  1. root@F650A:~ # mkdir -p /usr/var/lib/lxc/openwrt( Y1 _( y5 u# J$ n
  2. root@F650A:~ # cd /usr/var/lib/lxc/openwrt
    7 E# Y  X$ O9 Q% _1 ~, j4 K
  3. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/pre-start.sh pre-start.sh
    * y8 u9 j: x. U# ]3 ]5 Y
  4. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/config config% V+ ]6 O) V7 m
  5. root@F650A:/usr/var/lib/lxc/openwrt # mkdir rootfs
      |5 E% t- c+ |$ @
  6. root@F650A:/usr/var/lib/lxc/openwrt # mkdir /opt/upt/apps/openwrt-rootfs
    ) z0 I  L- {- U, k
  7. root@F650A:/usr/var/lib/lxc/openwrt # lxc-start -dn openwrt& H3 a+ |; S( @4 j, l
  8. root@F650A:/usr/var/lib/lxc/openwrt # ps
复制代码
此时的进程列表应该可以看到/usr/sbin/uhttpd、dropbear等,或者可以尝试打开浏览器 http://光猫ip/或ssh登录,如果看到Authorization Required提示登录或ssh提示登录用户名密码,表明lxc已成功运行,但此时无密码状态无法网页和ssh登录,只能通过控制台方式添加密码后才能实现。关闭openwrt容器,'ps' 确认,前台启动。% _8 W$ }+ z5 @* H( g* Z
  1. root@F650A:/usr/var/lib/lxc/openwrt # lxc-stop -kn openwrt6 l2 A2 O& R- `: u+ \& ^
  2. root@F650A:/usr/var/lib/lxc/openwrt # ps
    2 ~2 b3 _; ]1 N: u; Z
  3. root@F650A:/usr/var/lib/lxc/openwrt # lxc-start -n openwrt
    ! s. t+ f9 l/ |" j8 p
  4. <6>init: Console is alive
    ' L0 n7 J7 ~$ C4 Q" L: Q; A& `* `3 A
  5. <6>kmodloader: loading kernel modules from /etc/modules-boot.d/*
    / v3 Y8 w5 X7 w( i$ g0 O
  6. <6>kmodloader: done loading kernel modules from /etc/modules-boot.d/*
    ' F" N1 l3 R  U+ P7 T/ H5 s" `
  7. <6>init: - preinit -
    + l( p7 N/ ^6 B& o/ E+ M& B
  8. WARNING: Variable 'network' does not exist or is not an array/object7 P& i% ~  W4 d$ H& O& z6 q' I
  9. WARNING: Variable 'lan' does not exist or is not an array/object+ A. W! w3 Z( L3 {0 Y( ~4 l
  10. Press the [f] key and hit [enter] to enter failsafe mode- A$ N0 N& r9 t9 n+ A* T5 @. _
  11. Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
    2 Q/ U6 S/ j. F3 q! m) A+ {
  12. <5>mount_root: mounting /dev/root
    # _1 C8 a: M2 G: R8 |- w6 y
  13. urandom-seed: Seeding with /etc/urandom.seed! H* _3 [' O* o& C: z# z
  14. <6>procd: - early -
    0 B+ p7 a8 c/ ]5 t0 |9 z
  15. <6>procd: - ubus -/ W+ Q: j' i' W# b/ E
  16. <6>procd: - init -
    . y- J6 w7 t* p' w
  17. Please press Enter to activate this console.
    ! |0 R3 r9 R+ m6 _9 Y, w
  18. <6>urngd: v1.0.2 started.
复制代码
此时回车便可看到openwrt的登入界面,添加密码。5 K/ {; }. [: ]- \2 f- ~
  1. ( X9 t4 U" @% l+ m
  2. BusyBox v1.30.1 () built-in shell (ash)
    ) h8 E0 s7 `* S3 l8 E

  3. - X% B# u* y( @0 `
  4.   _______                     ________        __; Q( t+ i9 Z; L) F# F
  5. |       |.-----.-----.-----.|  |  |  |.----.|  |_! @( Q% V6 |! G: x3 f1 U" T
  6. |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|) q' m2 z) c/ w8 e
  7. |_______||   __|_____|__|__||________||__|  |____|
    ! ]2 U, x  f& o- D: L4 c
  8.           |__| W I R E L E S S   F R E E D O M+ w5 E7 F& X  z4 J9 U, F
  9. -----------------------------------------------------
    ' F# @% ^* x8 n# H! b
  10. OpenWrt 19.07.1, r10911-c155900f66
    1 O4 e2 Z, \7 @6 u" W: ~
  11. -----------------------------------------------------' D! P1 x, F2 w' M/ D
  12. root@openwrt:/# passwd root3 M! I; A, \2 o0 h' D  I) T
  13. Changing password for root
    8 a) z; m" u4 r# L6 c- ]$ ^. O4 b
  14. New password: ' s! A2 z8 e( L5 t
  15. Bad password: too weak
    / r: n2 J# J4 a0 u
  16. Retype password:
    $ L- H4 X  s$ E; O* p5 E" p! o
  17. passwd: password for root changed by root
    & j  u8 J8 i" q; U8 B
  18. root@openwrt:/# exit" f. g0 K' P: X- z) M8 X
  19. Please press Enter to activate this console.
复制代码
控制台方式进入openwrt之后,exit无效,没找到正常的退出方式,只能关闭窗口,此后就可以通过网页和ssh正常登录。
! y2 g* |* }  E' o: w7 H) J/ ~2 b. }7 _& Y. V/ V3 G4 |; O
7、自启动及进程守护
$ F: F1 n6 T3 ?    telnet登录光猫主系统,确认saf程序已备份,
0 J2 O6 A5 V7 s; J0 |% c; M8 D5 E+ b# Q8 d9 a/ ~
  1. root@F650A:~ # ls /usr/sbin/5 N. |% l! @$ H7 U, W0 J
  2. chroot       lsap         saf.bak      telnetd
    * D7 H( e$ [) @
  3. root@F650A:~ # vi /usr/sbin/saf
复制代码
填入 (2021年5月更新:去除USB端口挂载判定,避免无挂载时LXC不能启动)
( Z) X8 q8 g/ a% t* A% t( e; c- s
#!/bin/sh
; x# ~5 P2 f  ]5 N9 F) C+ ]/ w# add user-defined startup scripts here2 S7 g& j# s' I. y5 K
+ j% i# e4 _8 B% n" l9 ?; R
  df | grep mtdblock7
, r( V. T" V5 @5 H! J  if [ $? -ne 0 ]6 \3 ]1 i1 C3 ~; d7 r
    then
* |: K6 F: F. n- U6 p- ?3 w      /bin/mount -n -t squashfs -o ro /dev/mtdblock7 /opt/upt/framework1
  t0 z! |: c6 J: q5 c& ?% G# c  `* Q2 ^  fi
' a, R- L7 v  `: z' m8 i% x### l  z7 P, a+ ?. Y9 d: L5 T
, b3 {3 k7 g0 d  b. O, `: I/ C0 \
#  ps | grep ntfsmount | grep -v grep
) Q- g9 \4 F! w#  if [ $? -eq 0 ]
. i$ F( {1 g& b# A; `" O3 J#    then/ L# [( ?9 M( G3 J; a4 U
      /dbus/usr/bin/lxc-start -dn openwrt
+ u  N# c$ D: l3 [+ E7 u# X2 e#  fi
6 T1 U3 b0 q7 |9 O/ \$ d##

; T/ X! V! {$ u. Z  j& d* H或者在电脑编辑好内容,命名为saf,传入/usr/sbin/,'chmod +x' 添加执行权限,重启光猫。
! X: j8 X5 H9 }/ Z/ F5 t8 b3 b+ V+ H- H
8、后续问题- ~9 s5 o! U6 p0 E) _' c
    目前的openwrt安装或更新程序会报错,缺少 libustream-openssl 、ca-bundle 、ca-certificates 和 libopenssl1.1,还需要修改dns,添加中文等) R7 O( i, v& J* A- ~3 O) p% \

) r* {1 p0 }" S4 Y0 |2 x1 H
  1. root@openwrt:~# opkg update
    * {/ s. a/ C- }* v7 p7 s  p
  2. Downloading https://mirrors.cloud.tencent.com/lede/releases/19.07.1/targets/bcm53xx/generic/packages/Packages.gz$ y9 G9 s' h; z# I. g0 g
  3. wget: SSL support not available, please install one of the libustream-.*[ssl|tls] packages as well as the ca-bundle and ca-certificates packages./ m- e: W1 ?8 O/ s9 S& ~
  4. *** Failed to download the package list from https://mirrors.cloud.tencent.com/lede/releases/19.07.1/targets/bcm53xx/generic/packages/Packages.gz
复制代码
这些安装包可以从腾讯的镜像站下载然后手动安装。
) D$ D% }; e5 a
  1. root@openwrt:~# cd /mnt/USB_disc1/
    ' \1 ]3 T! i6 U+ D
  2. root@openwrt:/mnt/USB_disc1# opkg install *.ipk
复制代码
修改dns# |' J0 u: I1 W* f! G$ |; y
  1. root@openwrt:/mnt/USB_disc1# rm /etc/resolv.conf( z; S! a! J# n. U6 `) [3 k  r
  2. root@openwrt:/mnt/USB_disc1# vi /etc/resolv.conf
复制代码
填入,保存
$ w% L$ K+ O$ Y0 x" x( o0 s) }
nameserver      223.5.5.57 P, q% A  K  \- {, v* p9 o
nameserver      8.8.8.8# b; e* ^6 `) W: W- U( @/ W
nameserver      2001:da8::666
) g: T2 l' W! F% l2 j  ]4 l' o
嫌过程繁琐的可以直接下载我配置好的镜像,从第5部分最后开始操作,将下载的openwrt-19.07.1-bcm53xx-lxc.bin和saf-lxc-start-openwrt放入光猫上的u盘,子系统默认root密码123456。+ _. ?3 t+ k0 h* h' g5 v
  1. root@F650A:~ # dd if=/dev/mtd7 of=/mnt/USB_disc1/mtd7.bin bs=1M  ^. r/ C6 `( W6 b' l; E1 F% g
  2. root@F650A:~ # mtd write /mnt/USB_disc1/openwrt-19.07.1-bcm53xx-lxc.bin /dev/mtd7
    / l# g# Y2 L1 J* ?& ?
  3. root@F650A:~ # mount /dev/mtdblock7 /opt/upt/framework18 _% S7 }. E. _
  4. root@F650A:~ # mkdir -p /usr/var/lib/lxc/openwrt
    : m& {" U3 r  Q, c
  5. root@F650A:~ # cd /usr/var/lib/lxc/openwrt$ I4 P( |, g' d
  6. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/pre-start.sh pre-start.sh
    & v  F( b% l* q+ H3 c1 e. g7 f
  7. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/config config. B) t; z5 w' I* }$ E$ b
  8. root@F650A:/usr/var/lib/lxc/openwrt # mkdir rootfs
    + \) Z! Z2 X% }* o0 e7 I  K
  9. root@F650A:/usr/var/lib/lxc/openwrt # mkdir /opt/upt/apps/openwrt-rootfs/ p  M2 ^6 o( W3 L5 i
  10. root@F650A:/usr/var/lib/lxc/openwrt # lxc-start -dn openwrt
    ( ^. L! ?0 L4 C' r
  11. root@F650A:/usr/var/lib/lxc/openwrt # cd ~ % R; \9 ?/ {8 u8 Q- I* \
  12. root@F650A:~ # mv /usr/sbin/saf /usr/sbin/saf.bak1 }; }8 C2 l2 R, s, o
  13. root@F650A:~ # cp /mnt/USB_disc1/saf-lxc-start-openwrt /usr/sbin/saf7 \% x/ b1 k# e9 `
  14. root@F650A:~ # chmod 0755 /usr/sbin/saf
复制代码
   虽然子系统的openwrt可以顺利运行,但经过我的测试,kmod类app大多无法正常工作。比如F650A内核不支持ext4文件系统,在子系统安装kmod-fs-ext4,尽管可以安装成功,但重启后提示 modprobe 启用ext4模块失败。% i/ z/ x% `* e* P" w; c
        子系统的uhttpd默认占用80和443端口、dropbear占用22端口,如果主系统有应用使用这些端口,会产生冲突,需修改rootfs/etc/config/下uhttpd和dropbear的端口设置。F650A的电信web管理系统尽管使用了8080端口,但web登录界面二者公用,当输入超密自动跳转至 :8080/start.ghtml,而使用光猫背面密码则跳转至80端口的luci,所以新的openwrt刷入后电信web管理系统将不可用,这意味着不能方便配置光猫网络,恢复出厂后无法重新拨号。为使子系统与主系统的web页面共存,即访问 http://光猫ip/ 时进入子系统luci页面,而访问 http://光猫ip:8080/ 时进入电信web管理页面,需要更改光猫主系统,此操作的定制空间更大,有机会的话在后面回复中整理出自定义光猫固件的思路。1 V0 m+ Q1 j1 y! b1 V" x3 M
# A! S9 ]7 L- |7 R. y

本帖子中包含更多资源

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

×
发表于 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 G! U7 @6 \/ X3 m- }* a& S
中兴非15.0.1出问题是你没清理/opt/upt/apps//apps目录
* b. f2 X' F4 H. c几乎所有光猫为了节省空间?都会有部分lib和var目录重用主系统的文件,openwrt下e8clib和e8cvar可以看看。
' u" g" f, \, x. G( z, ~另外中兴编译的openwrt开始了uclibc的xlocale配置,这也是achaoge直接用omap源的APP无法运行的原因,我自己有手动开启xlocale后编译omap的openwrt放进去运行OK。0 C+ h2 Q" v8 o9 z0 l# ~) X. E
有兴趣可以一起研究玩。
 楼主| 发表于 2020-2-20 21:40:34 | 显示全部楼层
anysoft 发表于 2020-2-20 12:58
. @6 n" t& [/ [( U5 j坐等lxc的教程,另外19openwrt是你自己编译的还是直接下载armv7的官方bin刷进去的?
/ ^0 y, ^7 D* B8 I6 b# U& l; U中兴非15.0.1出问题是 ...

: M8 Y" U; G/ F& f- C% m: _+ }
0 h7 X+ n' _$ j$ P8 w) j% R& Qopenwrt1907用的官方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 i& O, Z5 r. S/ g& K, e
openwrt1907用的官方rootfs经https://github.com/mikma/lxd-openwrt修改而来;xlocale的问题我在编译主 ...

" N& W1 Q# ?& Z7 b是的, 中兴使用的是buildroot-2015.8.1,这个strings 一下sendcmd 就可以看到% B1 S. Z% E6 ]; a

2 j- l: z/ y7 W( Y0 T+ ]0 x看了下操作步骤,其实如果内存足够,没必要关闭saf启动的天翼网关。
& L7 b- Y% X! @8 G- C1 _( u可以让lxc容器启动两个op应该是可以的,F650A和华为hs8145V应该都是512MB内存,内存足够,openwrt可以放到apps分区文件夹下,不一定要写入mtd7再手动挂载。2 U  S3 k3 A7 d0 [  T* Z3 \
# Y4 a2 O9 K; Z( n- ]. n( I1 Z
我的HS8145V启动后内存只占用了30%,足够了。
1 L) l$ s% }+ r* r+ P% V
2 m$ a; |0 b. n$ B7 i3 P( R3 Z另外主系统下的usr/sbin目录下文件不是内存加载的rootfs对应的squash文件?这个更改应该不会回写到文件系统,重启应该就会消失?4 z# k* W9 A  l) b" J9 o
不晓得中兴和华为是不是一样的。可能中兴可以修改文件吧,华为的只能dd备份rootfs分区后自己解包修改打包后再dd写进去,会有砖的风险,砖了只能上编程器。" p: Z0 _+ F# T  r

5 ~* `9 c$ B3 M( @6 w1 a4 L至于端口问题可以在打包openwrt的时候先修改每个服务对应监听端口就不会冲突了。
# O6 m2 h6 u# t% y, q* Q/ L

本帖子中包含更多资源

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

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

本版积分规则

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

GMT+8, 2025-5-5 09:15 , Processed in 0.043277 second(s), 7 queries , Redis On.

Powered by Discuz! X3.5 Licensed

Copyright © 2001-2020, Tencent Cloud.

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