找回密码
 注册

QQ登录

只需一步,快速开始

查看: 50848|回复: 93

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

  [复制链接]
发表于 2020-2-17 02:14:04 | 显示全部楼层 |阅读模式
本帖最后由 songee 于 2022-4-27 21:04 编辑
4 x3 Z" t  p% {2 U' B2 I
: G& [0 C( t: j; n% M家里装宽带,电信200M,送了个中兴F650A。自带的天翼3.0web界面看着不错可惜几乎没有可玩性,闲来无事研究一番。' ?9 B6 w6 G$ O0 J7 U
    借鉴论坛前辈achaoge的帖子:中兴 F450A/F650A 免 TTL 持久开 ssh顺利开启telnet,发现该光猫的运作机制是 主系统负责底层的硬件驱动、sendcmd管理系统(telnet、超密、ppp拨号、网络及WiFi、ftp等)、以httpd为基础的8080端口电信web管理界面,最后启动saf(lxc容器管理)程序。
- g& `- m7 G+ [4 p6 [, T    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数据存放区,操作时需要特别注意!!
- Z0 _& \# o7 d* X  U
  1. root@F650A:/usr/sbin # saf
    & r& h) u+ Q1 u6 d+ A: C
  2. Usage: saf service FWK_MTD_ID1 FWK_MTD_ID2 APPS_MTD_ID (eg. saf service 9 10 7)
    # l1 r9 t$ b& H8 a( Q
  3. saf console
    4 ?' |' j6 k4 }4 ^( N
  4. saf info$ ?9 {, j/ E% u
  5. saf version6 m" z+ P' Z! w4 M4 F) X2 c) W
  6. saf getfwkver
    8 M3 g9 f0 y. d
  7. saf getbakfwkver% \6 F1 K/ C5 c$ S4 o" J* o
  8. saf getactive. c3 o, n8 F+ v! L" {) Q# [8 F3 I- X
  9. saf setactive FWK_MTD_ID [AFTER_REBOOT] (eg. ./saf setactive 17 1)
复制代码
  1. root@F650A:~ # cat /proc/mtd, f6 J! k9 a! n2 o
  2. dev:    size   erasesize  name
    ) }+ T4 a: Z! o+ E/ p& K' ^
  3. mtd0: 08000000 00020000 "whole flash"
    7 C" P3 g9 b" _
  4. mtd1: 00100000 00020000 "u-boot"
    . Y' L# v+ }8 G: c2 t
  5. mtd2: 00080000 00020000 "others"
    : W4 p+ V" c1 k3 P7 ~- N
  6. mtd3: 00100000 00020000 "parameter tags"
    8 Y& ]* x& `7 X- a
  7. mtd4: 00100000 00020000 "wlan"9 \2 }  w. s  @- L  g
  8. mtd5: 00200000 00020000 "usercfg". v% [5 d. `$ ], {) i" M' j
  9. mtd6: 00800000 00020000 "framework"% k5 V0 @1 y8 d% W
  10. mtd7: 00800000 00020000 "framework1"( H: v, D7 _# s8 w1 l8 M6 N6 N8 u
  11. mtd8: 00780000 00020000 "dbus"
    # H( k% @& j. \* h" H# s
  12. mtd9: 01280000 00020000 "kernel1"0 y9 ]) l8 [' l: l8 y
  13. mtd10: 01280000 00020000 "kernel2"3 u' C8 a$ ?4 t
  14. mtd11: 03e00000 00020000 "plugin_data"6 x! K& m6 U6 u) S1 D
  15. mtd12: 01240000 00020000 "rootfs"
复制代码

0 {# }( J! Q. @8 W" Y1 d6 n$ l    saf程序管理子系统,是通过系统的lxc容器实现的,在/dbus/usr/bin/目录下有lxc相关程序,但并非标准的官方版,而是定制的,lxc.lxcpath即lxc容器存放位置设定为/usr/var/lib/lxc,暂时没有发现更改的方法(也没什么必要)。
root@F650A:~ # ls -l /dbus/usr/bin7 _; B- E+ {! j
total 377
) Q5 p0 V* ]  ?- N) v6 K-rwxr-xr-x    1 root     root         10143 Nov 15  2018 dbus-cleanup-sockets  T( o- u3 Z& ]& N; H; q
-rwxr-xr-x    1 root     root         18867 Nov 15  2018 dbus-launch6 @! X- ?$ M; s$ Q: q( E
-rwxr-xr-x    1 root     root         22537 Nov 15  2018 dbus-monitor' M, e& Q* }2 |( R0 K' O
-rwxr-xr-x    1 root     root         11049 Nov 15  2018 dbus-run-session1 W  x) d5 F' u# {# L
-rwxr-xr-x    1 root     root         23431 Nov 15  2018 dbus-send
5 f  p. |+ z0 ?: i' I5 L-rwxr-xr-x    1 root     root         19495 Nov 15  2018 dbus-test-tool
6 D8 H! e% [7 R: Z) A: q' H# g-rwxr-xr-x    1 root     root         12257 Nov 15  2018 dbus-update-activation-environment# W$ v, u7 {" o( ?  L4 y
-rwxr-xr-x    1 root     root          8365 Nov 15  2018 dbus-uuidgen! |1 g7 _+ A) p% K( s$ C9 G  b
-rwxr-xr-x    1 root     root         33112 Nov 15  2018 gdbus' w; m/ n9 N& A# j/ h5 s. D& l! `3 B. V
-rwxrwxrwx    1 root     root         12332 Nov 15  2018 lxc-attach
  {. G, I/ S0 w7 x. P-rwxrwxrwx    1 root     root         14241 Nov 15  2018 lxc-autostart# Q- k& v, j& Z! r6 h# V
-rwxrwxrwx    1 root     root          9122 Nov 15  2018 lxc-cgroup3 J$ H8 ^1 ]; _
-rwxrwxrwx    1 root     root          4414 Nov 15  2018 lxc-checkconfig
! b. l% R# G  I; k$ [-rwxrwxrwx    1 root     root         10175 Nov 15  2018 lxc-clone
2 w1 D; {/ `9 o-rwxrwxrwx    1 root     root          6181 Nov 15  2018 lxc-config. ~0 N+ b. P6 X, E* p3 i( _
-rwxrwxrwx    1 root     root          8590 Nov 15  2018 lxc-console7 U4 C2 `, a$ _: N6 K
-rwxrwxrwx    1 root     root         14556 Nov 15  2018 lxc-create
6 b: K/ r5 T; E8 G# x2 i" s-rwxrwxrwx    1 root     root          8540 Nov 15  2018 lxc-destroy! K8 H. I) e/ i
-rwxrwxrwx    1 root     root         10027 Nov 15  2018 lxc-execute7 E5 V+ C# s6 |3 c: I0 S
-rwxrwxrwx    1 root     root          8630 Nov 15  2018 lxc-freeze
' x7 [$ ~2 ?! }4 m-rwxrwxrwx    1 root     root         18956 Nov 15  2018 lxc-info' O+ F+ c9 h3 `) N  f1 Z1 z; A% L
-rwxrwxrwx    1 root     root          2834 Nov 15  2018 lxc-ls0 M* [% i: o1 q/ g4 Q& Y/ d
-rwxrwxrwx    1 root     root         11122 Nov 15  2018 lxc-monitor& A  |; u& P  E0 C2 a( V: O6 Q
-rwxrwxrwx    1 root     root         12270 Nov 15  2018 lxc-snapshot
  X3 a& ^* ^! Y- J& A-rwxrwxrwx    1 root     root         15356 Nov 15  2018 lxc-start
  M/ L+ _1 @$ S! w4 Q8 e: @( @2 }9 \-rwxrwxrwx    1 root     root         10055 Nov 15  2018 lxc-stop
" P% _/ \1 M+ M' \/ k-rwxrwxrwx    1 root     root          8634 Nov 15  2018 lxc-unfreeze
0 f4 l9 Q/ L  y3 Y& |-rwxrwxrwx    1 root     root         12380 Nov 15  2018 lxc-unshare
- t9 W% D* @( y. s-rwxrwxrwx    1 root     root         13324 Nov 15  2018 lxc-usernsexec) O' {5 S! O! o% `3 G
-rwxrwxrwx    1 root     root          8561 Nov 15  2018 lxc-wait
  1. root@F650A:~ # lxc-config -l  F$ \' J4 _0 |
  2. lxc.default_config: j% {9 r. P8 u0 }
  3. lxc.lxcpath( Y0 {" ^, [8 i& m
  4. lxc.bdev.lvm.vg
    , p* |3 a# E7 k% z6 v0 u. f) D0 F
  5. lxc.bdev.lvm.thin_pool1 j; }9 \- z2 B5 r4 l6 o
  6. lxc.bdev.zfs.root
    # e) C! x5 K. q1 ^! W6 O+ i
复制代码
  1. root@F650A:~ # lxc-config lxc.default_config
    * o- B+ C$ k0 O2 g* s  n' e
  2. /usr/etc/lxc/default.conf  H3 [: f+ [7 d# c" K
复制代码
  1. root@F650A:~ # lxc-config lxc.lxcpath) F  L* b2 V  e; a1 t5 h
  2. /usr/var/lib/lxc
复制代码

- h1 j2 J& n- q- `2 b/ r( h3 z    了解系统运作机制之后,我最初打算借用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方式开启新世界,操作步骤在本文回复中细谈。
% w3 Z: X, m2 f5 _6 A( Y    经过几番折腾,已将系统原有的openwrt中兴定制版saf子系统完全替换为官方openwrt19.07.1(lxc方式启动),不影响光猫拨号且可在线安装及更新非kmod类app,如ariang离线下载,samba文件共享,甚至各类科学上网工具(性能及安全原因不推荐)。
) G# C1 @# a/ |6 F/ M# z! ~
3 J  F' T' H$ Q$ T1 O
" ]/ c" x& H( Q# @! \7 Y# ~) P1 n' K9 C9 ~0 r
& Y' @5 l0 W# L+ j
! h; T- C0 h4 Z5 _0 n

; J  t' _/ J1 g: L; F6 O- @2 J7 i: }+ u

本帖子中包含更多资源

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

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

简化并更新OpenWRT22.03.0 RC1版本

本帖最后由 songee 于 2022-4-26 23:39 编辑
( C( j# Z0 a: g8 X1 C5 E2 U5 |# G' k* `1 S9 R
因二楼原帖过程过于繁琐,近期尝试了一种较为简单的办法。
5 J  J1 R1 D. U7 _% e1 n4 d8 y* [- k& P4 A/ ~

- N% k) \3 m. v2 y1、下载openwrt.org固件,我选的是openwrt-22.03.0-rc1-bcm53xx-generic-tenda_ac9-squashfs.trx,binwalk分析squashfs偏移量并用dd取出,unsquashfs提取rootfs,打包为rootfs2203rc1.tar.gz,传入光猫临时目录,如 /run/shm 。! f! P4 \2 j% e* P0 D' d

. Q" h  J8 z" U2、将rootfs2203rc1.tar.gz提取至 (lxc-config lxc.lxcpath)/openwrt/rootfs 。2 b1 [2 k$ m4 m0 l8 L. m
  1. root@F650A:/usr/var/lib/lxc/openwrt/rootfs # tar -xzvf /run/shm/rootfs2203rc1.tar.gz -C ./
复制代码

% M( s! R- Z* H9 [0 t5 Q0 @% E  K& M& v( B
3、修改rootfs。openwrt的网络配置与主系统有冲突,需要清除。
% e. X- J) [! A  y    3.1 移除 ./etc/board.d/ 目录下 01_leds 、02_network 、99-default_network 三个文件。
4 }8 j$ N* o: t    3.2 移除 ./etc/rc.d/ 目录下 K21wpad 、K85odhcpd 、K90network 、S19dnsmasq 、S19firewall 、S19wpad 、S20network 、S35odhcpd 、S96led。
9 c7 v: G+ n6 G1 q% `4 w8 y    3.3 移除 ./etc/modules.d/ 和 ./etc/modules-boot.d/ 及 ./lib/modules/5.10.111/目录下所有文件,openwrt的kernel modules与光猫内核不兼容。# l$ V2 }8 w+ k& C7 ]2 S0 ]( u2 h
- g" z3 b4 @% m$ K/ B0 Y
    3.4 修改opkg源 ./etc/opkg/distfeeds.conf(可选)
: c7 A" Y! s' B) A3 o4 r% L3 h
  1. src/gz openwrt_core https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/targets/bcm53xx/generic/packages
    ! R& O4 R+ u7 i( ?) b3 O( b
  2. src/gz openwrt_base https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/base6 \! s) M% G! p" S8 u. m
  3. src/gz openwrt_luci https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/luci
    . W+ G. Y1 }0 ^2 \0 {$ ]5 a5 [
  4. src/gz openwrt_packages https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/packages# u8 _% e( v1 C( P
  5. src/gz openwrt_routing https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/routing
    & q; S& s. t! O( h+ G2 m
  6. src/gz openwrt_telephony https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/telephony* T/ m# r* f, ]! D# d$ S3 U7 D
复制代码
  3.5 修改 ./etc/inittab 实现启动项自启(参考https://github.com/mikma/lxd-ope ... r/files/etc/inittab
* O8 i- G) l. u: ~* ?. N+ B
  1. ::sysinit:/etc/init.d/rcS S boot
    ( C/ n5 P( z5 d# r7 O& p
  2. ::shutdown:/etc/init.d/rcS K shutdown
    2 ^) ^  W( ~' H  Z8 P& Q
  3. console::askfirst:/usr/libexec/login.sh
复制代码
  3.6 修改密码 ( root 密码 chinadsl
% Q# [. H: Z- T) x/ i( S9 X
  1. root@F650A:/usr/var/lib/lxc/openwrt/rootfs # chroot ./
    ) l2 T8 C5 \. ^4 i3 J* g

  2. : j9 a% F7 ^: I
  3. 8 y, J  |: g" }$ }7 y3 V4 X; }& i
  4. BusyBox v1.35.0 (2022-04-20 10:37:37 UTC) built-in shell (ash)
    7 Z+ W, ?* h* `- Q' U: j7 B

  5. % W0 W5 @, Z" X9 V
  6. root@F650A:/ # passwd/ C4 F; U) R1 t! s, O4 f
  7. Changing password for root2 P9 [1 i. g/ y/ d. J
  8. New password:5 t( F& `+ i5 i8 `; M
  9. Bad password: too weak
      S# t  }1 ~" ?- G9 t' C
  10. Retype password:) \! [% @0 A# i' c3 a
  11. passwd: password for root changed by root
复制代码
  3.7 删除 ./etc/resolv.conf 软连接并新建./etc/resolv.conf,否则openwrt无法解析域名
* m, X9 ~' J$ ~5 }' }
  1. nameserver 223.5.5.5( m2 H/ {% X- ?1 k
  2. nameserver 2001:da8::666
    $ \7 V5 c3 m. h4 N
复制代码

7 Q) x4 t6 O2 U( b: Z8 J
' i$ Y0 t9 A- E$ G4 Y1 D( m4、修改lxc配置文件 /usr/var/lib/lxc/openwrt/config ,根据各自光猫环境修改测试,这个配置我的F650A可正常使用。: U  b# H% `. r/ H3 R7 ?# f  \$ N
  1. lxc.arch = arm
    / @* m7 x/ e" U: Q9 j5 j
  2. lxc.utsname = openwrt
    0 `( p+ E# F& _% Q! V, W
  3. #lxc.rootfs.mount = /usr/var/lib/lxc/openwrt/rootfs
    # a5 \' @2 n, s. V- h; I
  4. #lxc.rootfs.path = overlayfs:/opt/upt/framework1/rootfs:/opt/upt/apps/openwrt-rootfs
    / ?2 B6 @. \7 d7 f2 m% W
  5. lxc.rootfs = /usr/var/lib/lxc/openwrt/rootfs
    ( N# @# O' W6 K' Q. }/ ^6 c
  6. lxc.haltsignal = SIGUSR1
    % `! v$ x* W7 b) t' f! \0 f
  7. lxc.tty = 1
    " J; h( L2 X+ r0 ?# Z' y
  8. lxc.pts = 1
    . K$ {; B& P9 x6 H3 a% \* p1 \
  9. #lxc.hook.pre-start = /usr/var/lib/lxc/openwrt/pre-start.sh, N  o7 O! V' L& U
  10. lxc.aa_profile = lxc-container-default-with-nesting
    0 T* k/ |; q' c
  11. lxc.network.type = none% }  B, q1 p! j/ a& a
  12. lxc.mount.auto = cgroup-full:rw/ u( S( \3 G) ^$ K
  13. #lxc.mount.auto = proc sys cgroup
    ' l5 f. b. K# j& Q+ z  S  J
  14. lxc.mount.entry = sysfs sys sysfs defaults 0 02 \0 X3 Z2 |5 X6 |; L
  15. lxc.mount.entry = proc proc proc defaults 0 0
复制代码

+ T% s! j$ O7 w( Y+ p' O0 i6 T2 T$ }/ Y) }; X3 A" t* p
5、启动,根据提示按enter进入控制台。* k/ {2 u* `" o8 ]
  1. root@F650A:~ # lxc-start -n openwrt  O6 |/ R5 v- s1 e
  2. <6>init: Console is alive4 ^( J5 M* A1 S  j. U
  3. <3>init: Failed to redirect stdin to /dev/null: No such file or directory5 X# O7 s  ~: ?3 {/ ^0 S
  4. <3>init: Failed to redirect stdout to /dev/null: No such file or directory! v' L8 a. O9 A4 m5 [0 h3 f
  5. <3>init: Failed to redirect stderr to /dev/null: No such file or directory' z4 `8 s  I6 ?2 d/ I9 Y9 q7 R, @
  6. <6>kmodloader: loading kernel modules from /etc/modules-boot.d/*
    ; x. {: v: s% R
  7. <6>kmodloader: done loading kernel modules from /etc/modules-boot.d/*" f% L& v1 b3 J) x+ {! v; H
  8. <6>init: - preinit -& U) `# |5 C9 |2 T7 p5 q
  9. ls: /etc/board.d/*: No such file or directory& \6 l" k" [( D
  10. Press the [f] key and hit [enter] to enter failsafe mode! P( \0 u4 v2 ^& i; N: U9 e
  11. Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
    0 M1 U* _% w' O/ u
  12. <3>mount_root: Could not open mtd device: /dev/mtd12
    ) n7 ^% a. {: U: j
  13. <3>mount_root: reading rootfs failed
    6 s% A6 u# N# b/ Z
  14. <5>mount_root: mounting /dev/root( G; J! O' W: D; B3 H  f
  15. urandom-seed: Something is wrong with /dev/urandom
    . N) i; U) s9 t  N' b/ C
  16. <6>procd: - early -2 ^# v3 g/ _: p6 [$ I+ D* M3 X* f
  17. <6>procd: - ubus -
    0 n/ W+ J) k( h9 Y% h5 K% |
  18. <6>procd: - init -5 h$ J/ y1 Q( c4 M$ f
  19. Please press Enter to activate this console.
    9 s: p/ ?1 \* F9 |3 L
  20. <6>kmodloader: loading kernel modules from /etc/modules.d/*
    + @! {; E% W( L9 |- S/ a$ z, j
  21. <6>kmodloader: done loading kernel modules from /etc/modules.d/*
    1 C# [- S+ V, b0 P3 n
  22. <6>urngd: v1.0.2 started.
    ; H# K8 n" p4 e  t9 {. J

  23. . ~9 C- D( r5 ~

  24. * E+ M& w; Y0 Y, H4 J0 k
  25. 4 D8 a$ w6 }! c3 t; b! ^# A7 n
  26. BusyBox v1.35.0 (2022-04-20 10:37:37 UTC) built-in shell (ash)! O/ r# |. ]7 ]+ W+ I( w8 v

  27. ! P& y9 f4 o) C( ]9 q0 X
  28.   _______                     ________        __
    # m, [- V# r$ B/ p
  29. |       |.-----.-----.-----.|  |  |  |.----.|  |_
    . U3 C* ~4 Q' `1 J
  30. |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
    ) g7 n$ T) m. U
  31. |_______||   __|_____|__|__||________||__|  |____|4 c+ E) E) ?. [7 Y* x! ^  U
  32.           |__| W I R E L E S S   F R E E D O M- c4 k" q6 D( k: ?1 Z
  33. -----------------------------------------------------
    7 H8 i7 \* u1 v1 Z
  34. OpenWrt 22.03.0-rc1, r19302-df622768da, l: u6 _5 d$ {6 ]5 U* G
  35. -----------------------------------------------------# B# U5 S  Y7 W8 z4 q% y! x, A
  36. root@openwrt:/#
复制代码

& p5 P3 m! ^6 N! H9 U$ ~4 t2 H! ]+ W3 J  D; S7 |1 y5 C# x8 q( \
  1. root@openwrt:/# ps
    4 z! G: f1 ^2 h: q  K* Q, \$ C8 o
  2.   PID USER       VSZ STAT COMMAND* A( f5 @# I: P$ N4 v+ b# O
  3.     1 root      1452 S    /sbin/procd
    ; M/ H4 A. v+ w& W! ^
  4.    58 ubus      1112 S    /sbin/ubusd
    # S9 c4 ~) M0 w; x4 a9 `
  5.    59 root      1196 S    /bin/ash --login
    % K/ F9 W2 A$ a6 a
  6.    93 root       908 S    /sbin/urngd
    / G8 ~! \& R# y6 _5 f: e: y* q
  7.   204 root      3736 S    /usr/sbin/uhttpd -f -h /www -r OpenWrt -x /cgi-bin -u /ubus -t 60 -T 30
    8 u% e9 K5 _9 E. ~
  8.   487 root      1952 S    /sbin/rpcd -s /var/run/ubus/ubus.sock -t 309 z: A! ?$ F# T. C, Z
  9.   556 root       956 S    /usr/sbin/dropbear -F -P /var/run/dropbear.1.pid -p 22 -K 300 -T 3  ]" D8 o1 H& K6 G  H) F  a
  10. 1065 root      1200 R    ps
    4 t  F  }6 l, t; C
  11. root@openwrt:/#
复制代码

/ P, J7 L7 Z6 y, \. ]4 \$ M# ]* n; }, R6 n5 a
  1. root@openwrt:/# opkg update( e1 S: K+ I5 |# f
  2. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/targets/bcm53xx/generic/packages/Packages.gz6 B1 b& s4 U! D  v; g
  3. Updated list of available packages in /var/opkg-lists/openwrt_core
    3 h. N5 Z. q0 R* }6 T  ]" ~
  4. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/targets/bcm53xx/generic/packages/Packages.sig( t! ^( D7 V! H
  5. Signature check passed.
    * H) ^6 o  K1 N, I2 N- c. J
  6. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/base/Packages.gz
    : E; j( Z7 Z% y$ ?2 W8 i0 ?' n6 a
  7. Updated list of available packages in /var/opkg-lists/openwrt_base
    ( O& {. t$ B6 T4 ]
  8. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/base/Packages.sig6 b. l- L5 Z1 ^- S+ h2 z. x  D
  9. Signature check passed.
    - r5 s* @, u7 k! t# B5 u
  10. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/luci/Packages.gz
    / D$ F+ @5 V  N3 ?# B- V
  11. Updated list of available packages in /var/opkg-lists/openwrt_luci
    . w7 [3 M: q6 o5 r' [% b$ r
  12. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/luci/Packages.sig' i% {2 a, S& I/ z
  13. Signature check passed.4 v& l: v  J8 G" _# L% [0 R4 ^
  14. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/packages/Packages.gz! w, ]4 n* B8 {) \" G* I3 _
  15. Updated list of available packages in /var/opkg-lists/openwrt_packages
    3 w* C2 M+ |' H8 x# m% L
  16. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/packages/Packages.sig4 u4 x* l. N4 c7 y6 L# w  Q- m1 A
  17. Signature check passed.
    ! A! q9 t" G. Z
  18. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/routing/Packages.gz
    . E- u- r5 @* w
  19. Updated list of available packages in /var/opkg-lists/openwrt_routing
    4 o9 n3 A, V6 F' w# M
  20. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/routing/Packages.sig1 r. s, \, Z$ x5 A- r
  21. Signature check passed.
    3 b2 ]& q' J+ R* c7 w- Q& t
  22. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/telephony/Packages.gz5 r# t! [+ J; [" t& N2 O
  23. Updated list of available packages in /var/opkg-lists/openwrt_telephony* Z5 I' {' M) o; t7 e7 W8 b3 G* S
  24. Downloading https://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/22.03.0-rc1/packages/arm_cortex-a9/telephony/Packages.sig
    * ]$ }( h& c9 V# O& ?5 y9 k
  25. Signature check passed.
    ! t/ ?: n6 V+ c: |7 }0 r
  26. root@openwrt:/#
复制代码

! s4 Y2 D- q8 F
& I3 K- f+ V0 u此时临时的openwrt系统已建好,运行的服务有两个:http占用主系统的80和443端口,ssh占用22端口。
2 p: h0 ^8 o8 u; C7 ?0 g, I; ?8 |7 d* i3 C0 D; z3 E
如果光猫有公网IP,请务必关闭ssh密码登录并使用密钥。
% Y. p/ \" i' ^0 f
" ^6 [* d7 w& B+ U9 P后期使用建议使用 lxc-start -dn openwrt 后台启动,使用 lxc-stop -kn openwrt 命令关闭。openwrt管理使用ssh密钥登录。% s- L6 n8 g( y4 b3 U1 x$ l
需要固化openwrt到固件的,可以打包rootfs和config(需修改配置),mksquashfs制作成squashfs,用mtd写入saf分区,就不用担心恢复出厂设置了。
7 I& Y! N4 g* g随光猫启动可以参考二楼。
; S( }2 e, |5 ~' c$ t: r( P
& g4 W4 m% z* a

本帖子中包含更多资源

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

×
 楼主| 发表于 2022-4-27 23:10:13 | 显示全部楼层
因光猫原系统的busybox功能不完整,也没有nano和dropbear,调试lxc可能会不方便,现分享出来。
5 [( X9 @& m/ ^5 O
9 @& L2 g/ y: k9 _% L1 x
  1. root@F650A:~ # /usr/bin/busybox" ]# l( [' J: n7 |2 b( J, [
  2. BusyBox v1.23.2 (2020-06-16 16:53:26 CST) multi-call binary.
    1 Y) H; c+ O, e$ C5 ?3 w9 b4 A
  3. BusyBox is copyrighted by many authors between 1998-2012.
    6 i  {& Q6 E$ @3 N7 T  T: V
  4. Licensed under GPLv2. See source distribution for detailed
    " A7 m0 p6 A3 `1 i0 t+ b
  5. copyright notices.2 c6 X+ m1 {- k5 A9 F& J  D. j
  6. 5 i% `1 ?) j$ A& v
  7. Usage: busybox [function [arguments]...]7 l! n2 H/ D2 Q: m
  8.    or: busybox --list[-full]+ N# P7 Y# t$ H3 t" N! G
  9.    or: busybox --install [-s] [DIR]; v6 C& ~9 t& e8 l
  10.    or: function [arguments]...7 S1 o$ S# V- a2 L, b  R4 Y- C

  11. ) B4 V; p, b4 C/ t
  12.         BusyBox is a multi-call binary that combines many common Unix* W4 c3 `- r* `4 p
  13.         utilities into a single executable.  Most people will create a
    ! K! p; {8 V6 N
  14.         link to busybox for each function they wish to use and BusyBox0 c4 h0 r- f4 l, P
  15.         will act like whatever it was invoked as." g) f/ }5 Q' `* G& J
  16. * G9 K( x4 ^, Q1 \4 u+ T5 u/ E2 y
  17. Currently defined functions:# P& F' U- u( |9 w
  18.         [, [[, addgroup, adduser, ar, arp, arping, ash, awk, basename, blkid, brctl, bunzip2," L# n. V' y' P  T
  19.         bzcat, cat, catv, chattr, chgrp, chmod, chown, chroot, chrt, chvt, cksum, clear, cmp, cp,$ o6 K3 S- E2 j4 v
  20.         cpio, crond, crontab, cut, date, dc, dd, deallocvt, delgroup, deluser, depmod, devmem, df,9 b8 t- w, [0 m! m% J2 x
  21.         diff, dirname, dmesg, dnsd, dnsdomainname, dos2unix, du, dumpkmap, echo, egrep, eject, env,
    + a) {. x5 r7 _. M- E: U
  22.         ether-wake, expr, false, fbset, fdflush, fdformat, fdisk, fgrep, find, flock, fold, free,
    9 E; h7 M3 Z  N: J/ ]
  23.         freeramdisk, fsck, fstrim, fuser, getopt, getty, grep, gunzip, gzip, halt, hdparm, head,7 G- ?$ J! w; J) `5 x
  24.         hexdump, hostid, hostname, hwclock, id, ifconfig, ifdown, ifup, inetd, init, insmod,
    % D& r, K" _( y+ H3 @  L1 a: L
  25.         install, ip, ipaddr, ipcrm, ipcs, iplink, iproute, iprule, iptunnel, kill, killall,) L! ~; f. q! v- J5 F0 Q
  26.         killall5, klogd, last, less, linux32, linux64, linuxrc, ln, loadfont, loadkmap, logger,
    % q2 ?  h3 R3 C
  27.         login, logname, losetup, ls, lsattr, lsmod, lsof, lspci, lsusb, lzcat, lzma, makedevs,6 t, a( ]% |) p/ V# e
  28.         md5sum, mdev, mesg, microcom, mkdir, mke2fs, mkfifo, mkfs.ext2, mknod, mkswap, mktemp,
    8 M0 k8 S( E2 G3 Z9 |
  29.         modinfo, modprobe, more, mount, mountpoint, mt, mv, nameif, nanddump, nandwrite, netstat,) R1 {3 N7 D* `" i& M8 E
  30.         nice, nohup, nslookup, od, openvt, passwd, patch, pidof, ping, pipe_progress, pivot_root,
    8 l8 L8 t5 b6 J; f' e
  31.         poweroff, printenv, printf, ps, pwd, rdate, readlink, readprofile, realpath, reboot,
    " X3 G2 X2 T6 X& ?
  32.         renice, reset, resize, rm, rmdir, rmmod, route, run-parts, runlevel, sed, seq, setarch,
    7 K  {: }; _. v& J; ^- ?+ i* P
  33.         setconsole, setkeycodes, setlogcons, setserial, setsid, sh, sha1sum, sha256sum, sha3sum,
    9 y) L8 r; d% W2 |! p, U; w1 K0 v
  34.         sha512sum, sleep, sort, start-stop-daemon, strings, stty, su, sulogin, swapoff, swapon,
    ' ^! }4 v& }' [$ r4 @
  35.         switch_root, sync, sysctl, syslogd, tail, tar, tee, telnet, telnetd, test, tftp, time, top,- J( C4 ~6 s/ ~0 m" y3 F) A7 ^
  36.         touch, tr, traceroute, traceroute6, true, tty, ubiattach, ubidetach, ubimkvol, ubirmvol,. q3 \6 c$ m1 W
  37.         ubirsvol, ubiupdatevol, udhcpc, umount, uname, uniq, unix2dos, unlink, unlzma, unxz, unzip,3 _, e/ k- f! m; @* h0 K/ ^! x* q
  38.         uptime, usleep, uudecode, uuencode, vconfig, vi, vlock, watch, watchdog, wc, wget, which,. R8 ~' m9 O6 o  V$ y. l4 K* _
  39.         who, whoami, xargs, xz, xzcat, yes, zcat
    1 V% L' T) v( Q: @2 w

  40. * }4 d( o$ X) J* [1 }5 d# f
复制代码
  1. root@F650A:~ # nano -h
    3 y0 I: |6 ^. G4 w2 C, S8 n
  2. Usage: nano [OPTIONS] [[+LINE,COLUMN] FILE]...
      O4 Z: _1 y6 v) L( y$ ?  Z

  3. 6 ?& L! B5 N7 ~4 t! o2 }# ?
  4. Option          GNU long option         Meaning
    * v; B( m: Q( u
  5. +LINE,COLUMN                           Start at line LINE, column COLUMN
    9 F  Q4 F3 z) G) G
  6. -D             --boldtext              Use bold instead of reverse video text
    8 ?- j" [& k% \% ]: m
  7. -K             --rebindkeypad          Fix numeric keypad key confusion problem
    0 D. h- n/ M/ W/ e8 l
  8. -L             --nonewlines            Don't add newlines to the ends of files# ^/ C, B4 s) I; o
  9. -O             --morespace             Use one more line for editing6 L3 Q( ?) q. v2 C5 ~; o
  10. -R             --restricted            Restricted mode
    0 ^0 E% b3 H0 q2 M
  11. -T <#cols>     --tabsize=<#cols>       Set width of a tab to #cols columns
    3 L! Z- k( c1 G: u; D# r
  12. -V             --version               Print version information and exit1 ^2 Z6 @9 ]# r$ ~
  13. -c             --const                 Constantly show cursor position! K8 E0 ], x6 t$ c
  14. -d             --rebinddelete          Fix Backspace/Delete confusion problem- ~0 x9 e, a9 s8 x' W! w1 W- T+ @6 C% H
  15. -h             --help                  Show this help text
    4 B1 V9 H  f6 b* w
  16. -l             --nofollow              Don't follow symbolic links, overwrite# Z6 \* Q+ k/ _3 E8 s; t
  17. -n             --noread                Do not read the file (only write it)
    . `) Y9 d: J9 F
  18. -p             --preserve              Preserve XON (^Q) and XOFF (^S) keys: A* V& X# V% z0 q/ A  a6 _" {% g
  19. -t             --tempfile              Auto save on exit, don't prompt/ }; b0 B+ b( f; V: J# l: ^. u
  20. -v             --view                  View mode (read-only)- g, S. @5 l5 {7 R1 Z
  21. -x             --nohelp                Don't show the two help lines
    * d1 W3 b$ ~7 s
  22. -z             --suspend               Enable suspension
    8 ^  y- x# x2 F+ K
  23. root@F650A:~ # nano -V2 ^3 T0 U7 ~8 E3 k" ~
  24. GNU nano, version 2.4.29 l% o' q0 _7 _/ `( E
  25. (C) 1999..2015 Free Software Foundation, Inc.
    5 ]& W) r2 J8 i2 k9 \, S
  26. Email: nano@nano-editor.org    Web: http://www.nano-editor.org/1 G- v- b5 T0 ~' t
  27. Compiled options: --enable-tiny --disable-utf8
    % F9 M6 L7 w0 P& i
复制代码
  1. root@F650A:~ # dropbear -h
    ) X- f( Z8 P0 d, ]$ L% a! W
  2. Dropbear server v2015.67 https://matt.ucc.asn.au/dropbear/dropbear.html, J8 s5 t8 Y: @+ W
  3. Usage: dropbear [options]5 u# k1 L! I, Y% T2 J" j8 U
  4. -b bannerfile   Display the contents of bannerfile before user login  @# Q! _; H( P$ X
  5.                 (default: none)
    / `& x% Y9 m! H' [
  6. -r keyfile  Specify hostkeys (repeatable)
    4 s! w; n8 G. M2 _2 I3 C
  7.                 defaults:/ S" K3 ?4 ?% m0 K$ n- y7 z
  8.                 dss /etc/dropbear/dropbear_dss_host_key: r  U2 D) ]* J
  9.                 rsa /etc/dropbear/dropbear_rsa_host_key, u0 M- f8 l! i% J" [" ?
  10.                 ecdsa /etc/dropbear/dropbear_ecdsa_host_key$ b! m$ O) g6 c1 H9 y
  11. -R              Create hostkeys as required* ~8 L7 [. Z& O& Z& J
  12. -F              Don't fork into background
    . r( I+ P+ a2 s5 `! y
  13. -E              Log to stderr rather than syslog
    & I# B( o$ D! ^+ b
  14. -m              Don't display the motd on login4 A& |$ a" i$ h3 X8 u! J
  15. -w              Disallow root logins2 b  u9 Z- ~. z
  16. -s              Disable password logins
    0 j! O: ~- l8 N) w
  17. -g              Disable password logins for root* |8 M3 ~# \+ j! z& ]
  18. -B              Allow blank password logins
    9 e9 ?) q0 s6 l, W# S* U9 j
  19. -j              Disable local port forwarding8 K8 f- j7 D$ {( z7 T6 z8 F! Y
  20. -k              Disable remote port forwarding
    3 ~# Z# f! c/ M
  21. -a              Allow connections to forwarded ports from any host7 ~, u5 H' ^" d7 f& F# l
  22. -p [address:]port1 v" K' ?. g: S6 A4 y2 {
  23.                 Listen on specified tcp port (and optionally address),4 ~& l  ^5 g6 n( R1 ^9 m
  24.                 up to 10 can be specified
    ' [5 z/ w$ y& v* x, V! I( V
  25.                 (default port is 22 if none specified)
    ) |; c' w% X& u, D
  26. -P PidFile      Create pid file PidFile7 g% H7 k% n3 I+ S1 n# s% u
  27.                 (default /var/run/dropbear.pid)& I! B& K. V) Q' L$ s) B
  28. -i              Start for inetd
    8 J* `4 j4 e2 B, x6 Q3 N" h  b' b# W; O! `
  29. -W <receive_window_buffer> (default 24576, larger may be faster, max 1MB)
    $ h0 N! E* x9 q2 {( L
  30. -K <keepalive>  (0 is never, default 0, in seconds)
    * ~) w6 P5 b7 \- ~9 d
  31. -I <idle_timeout>  (0 is never, default 0, in seconds)
    + f* s" x  F+ p' R  S
  32. -V    Version0 v9 \) t- Y! {
复制代码

- t2 x8 p4 \, ]  |0 A. \
& h& K8 b& l2 I

本帖子中包含更多资源

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

×
发表于 2021-11-27 21:38:54 | 显示全部楼层
本帖最后由 btworm 于 2021-11-27 21:41 编辑 / B7 l9 p$ \( H
songee 发表于 2021-11-27 04:15$ p# r8 a2 G) U9 ^# J6 X% t
1.只要lxc相关命令可以正常运行,写好配置文件,选择符合CPU架构的rootfs,就可以把容器跑起来。
: s, j+ L8 J- ~% |+ G2.我的 ...
+ ^0 q. a) f" E7 Z9 q1 K
感谢指点!( p, T, c* ]3 T2 `
5 F( e$ D. R- R3 y
关于第2点
" `2 x4 o  R$ K华为光猫 / 只读,/etc,/usr,/lib这些目录也都依附于/, 所以都不可写, /opt目录不存在,当然也无法创建。
. f( A4 X! g+ P0 W- X
$ c! S5 A: u2 c/ b: G8 [' O- T之前担心/dev/pts, /proc, /sys只读,是因为以前玩路由器时,有个chroot脚本使用过这些目录,刚又看了遍那个脚本,使用的是 "-o bind"参数,所以主机目录是否可写就无所谓了。在华为猫上跑lxc应该没问题了3 g# `6 f9 M6 U- s

$ _+ `$ T) M; {, l  W/ T另外想问问,光猫容器内的应用对端口的监听是:( R5 m/ n$ R5 {7 g: g( Z
1.直接监听光猫的端口?! W/ S: n/ M/ b: Y& ^5 V6 q
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
( o) \* S" M/ ?HS8145V HS8145V5  F650A 都是512MB+256MB 2.4G+5G方案
" Z: ^8 k) w: _1 A价格都还好,特别F650A 因为会玩的人少价格特别便 ...
- M, i% i+ L% o' ^- J3 l
hs8145v技术成熟,更适合玩,而且其实f650a是512/128,nand flash少了一半,CPU一个尿性,价格差别不大的话,能hs8145v还是别选650。: n+ ]- C4 E, {8 B6 q
还有个大胆想法,lxc可以通过配置文件config修改子系统网络,从eth0桥接是不是就能在子系统多拨了,子系统专门离线和网络存储,不影响猫后面接的手机电脑上网,还是蛮有趣的
7 b( E) P+ D' R, l& S. F$ j
2 _  D: q4 j  Y4 g% u
% {, _1 ]: p7 [0 u
1 |/ }) T$ u) @. S: R& ~. K( e, \- G

点评

想加个好友交流的,回复被站长直接删了.....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 编辑 # p, X( s0 C5 {: d, @4 R2 [

1 G( I& L( s' |6 _2 D6 k/ G0 @! j6 F4 D8 N
(2020年原帖初步摸索,过程过于繁杂,不建议再按这部分思路操作)4 B) D) |% q2 ]0 E# X/ f
中兴、华为等带有saf模块的光猫,以官方版openwrt替换厂商定制版的思路总结一下,供大家参考。% R% J9 M9 n2 {' r6 R% c5 P5 I
1、准备工具
6 s1 H" |" E! X, I. c& \2 Y    F650A主系统没有 mtd 、 dd 和 vi 等工具,而自带的saf子系统正好都有,子系统位于framework分区即mtd6,挂载于/opt/upt/framework,cp过来可以直接使用。
root@F650A:~ # cp /opt/upt/framework/saf/rootfs/sbin/mtd /usr/bin/4 Q3 o, K9 v9 i0 M$ r- r3 e4 A$ `
root@F650A:~ # cp /opt/upt/framework/saf/rootfs/lib/libubox.so /lib/* @; d+ X# t' D
root@F650A:~ # cp /opt/upt/framework/saf/rootfs/bin/busybox /usr/bin/
. r3 {; ^: {/ Wroot@F650A:~ # cd /usr/bin/
8 b6 _, n2 d. P- wroot@F650A:/usr/bin # ln -s busybox dd! J8 ]8 x: g; {8 N7 H$ m  f
root@F650A:/usr/bin # ln -s busybox vi

4 P; L; ~/ l7 ^2 Y8 A# K5 F2、改进lxd-openwrt生成代码。
5 m3 u7 d! p+ X7 {. r- x    本节参考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如下
5 l6 q/ |& h" j5 T: s1 `1 C
*** build.sh                2020-02-19 01:50:10.972675562 -0100. C2 q" D6 t' E7 A$ x4 R$ [
--- build.sh.origin        2020-02-14 19:10:45.000000000 -0100
$ q+ `: C; N+ J***************
% A" {* J# V4 W, \*** 72,81 ****
7 i; i, s" H) o: n                  subarch=64: n; h6 [% Q+ R6 D1 |% S, ]
                  arch_ipk=x86_64: d7 o8 ]! \) U
                  ;;
7 f& _  d; X" F7 P2 R!         arm)
8 ?% r/ N% R' D# B& F( O  b, A!                 arch=bcm53xx
2 O0 l8 |& a# W2 }. z3 X5 \; v!                 subarch=generic
" i  N! o/ J9 H2 E; u2 I!                 arch_ipk=arm_cortex-a9
/ a4 F+ w4 h' A' i                  ;;" o+ f1 U$ n  y2 _3 C) ~" }
          *)% j7 u9 [$ w4 S! `
                  usage7 e7 S# F5 K+ C: E) a
--- 72,81 ----
6 q: S: v: f0 N2 C0 h1 [                  subarch=64' j/ p- r$ s! E1 G
                  arch_ipk=x86_64; w$ h( g+ _6 S9 \' `' b9 b9 g  Z
                  ;;1 _4 L# X; t0 y
!         aarch64)/ e1 S# T7 y1 ]9 U0 ~
!                 arch=armvirt' U# R, T( _+ K3 d- X
!                 subarch=64
2 V. h" g3 {% E$ s3 \+ `!                 arch_ipk=aarch64_generic
2 ?  k7 q9 |# b+ a' }                  ;;
1 T8 B, P; N) \0 h% ~          *)$ A# l( D; ]# }5 @$ }
                  usage6 [5 Y0 V2 y2 [: {! @) }) ^
***************
% X- {% c. ^7 o; y* v*** 87,97 ****
( z8 ~5 |7 `% n8 _! P: f" E  if test $ver = snapshot; then+ |( @0 _2 I% j9 v+ T$ Q
          openwrt_branch=snapshot5 n8 D; G5 Y2 `2 ]9 I5 E
          procd_url=https://github.com/openwrt/openwrt/trunk/package/system/procd$ I( m! K- i/ Z; C
!         openwrt_url=https://mirrors.cloud.tencent.com/lede/snapshots/targets/${arch}/${subarch}! a' Q6 z( ~3 j5 ~! c7 S
  else) N, `- }; n+ V$ b
          openwrt_branch=${dist}-${branch_ver}  R9 K  y2 M3 P# h: Q
          procd_url=https://github.com/openwrt/openwrt/branches/${openwrt_branch}/package/system/procd: w3 A" Q! b6 K$ [# |
!         openwrt_url=https://mirrors.cloud.tencent.com/lede/releases/${ver}/targets/${arch}/${subarch}
$ r6 B, J6 ~: B" E9 t  fi
) m. M5 J  ?. Z# T9 l  
' m7 B& d5 ~$ Y  procd_extra_ver=lxd-3( F! a3 |5 V$ U4 {& s2 J* K3 k/ c
--- 87,97 ----
% D6 ]: s: I3 }: p4 }* \# H6 V  if test $ver = snapshot; then/ M2 [% U1 f, N. y; o0 U
          openwrt_branch=snapshot8 m8 h+ c$ h( z2 u* f8 o; y# Q6 f
          procd_url=https://github.com/openwrt/openwrt/trunk/package/system/procd' @. V1 W7 |+ w) n" \
!         openwrt_url=https://downloads.openwrt.org/snapshots/targets/${arch}/${subarch}* a1 i2 Z) w0 F% S; e" @
  else5 f$ [. p% [& s0 ~
          openwrt_branch=${dist}-${branch_ver}* _' h4 v) i/ w/ ^- j
          procd_url=https://github.com/openwrt/openwrt/branches/${openwrt_branch}/package/system/procd
! B$ \0 Q0 }5 r2 h!         openwrt_url=https://downloads.openwrt.org/releases/${ver}/targets/${arch}/${subarch}
. M0 k- V, q& O, G! F# ~  fi
: b+ K) k! G: N" ?  
  q, D% e  A, v; S  procd_extra_ver=lxd-3
. V. y  I9 J# g# I% y4 C***************. e# [4 H8 n# G5 O
*** 112,125 ****
# B5 I8 v. w2 r7 J  }
: R; a& ~- \& |, ~$ _% y  4 e$ k" @6 D) A
  download_rootfs() {
3 W, {) Q' L( O9 N! #        detect_url "rootfs\.tar"
' o' S  {" d3 E  Z! #        local rootfs_url=$openwrt_url/$return' `( k4 I; h: |+ l- \9 ]5 A- e5 {( A
  $ H7 d8 @% n9 U2 i% z, R
          # global $rootfs
0 \: H7 X$ e0 i- E- @" C!         rootfs=dl/openwrt-19.07.1-bcm53xx-generic-rootfs.tar.gz
* e8 d+ b% K8 g0 R7 I  
2 L$ g) b& E1 I  J! #        download $rootfs_url $rootfs $rootfs
3 j$ R' f8 p5 ^! #        check $rootfs $rootfs_url! y3 Q4 W# J& F6 S5 o+ z
  }+ ], [' D' `' _: o$ s; j
  ( b2 |3 K0 w  b2 V/ [; M$ ?
  download_sdk() {
- M; C8 X9 d9 U* i1 z& i4 h--- 112,125 ----) f5 a) \- |. m& I, [9 }
  }1 P, m  R0 N, C8 v5 m
  
: e) y# t9 c0 f' a! v  download_rootfs() {
; V8 d8 G% Q3 [* k5 M9 F!         detect_url "rootfs\.tar"
6 z/ ]& p& [' n, S7 V!         local rootfs_url=$openwrt_url/$return& ^* M) P5 q0 g) i
  
$ y% @+ T& H- _4 E: I3 m6 N& U# w8 e          # global $rootfs
$ j; q# _: P$ x* X!         rootfs=dl/$(basename $rootfs_url)
0 V$ k  A' ]- L+ J5 X3 R# O  
; Y& U$ d# Q. ~& \! D, n!         download $rootfs_url $rootfs: P# F& M7 u2 x6 ?
!         check $rootfs $rootfs_url& U; ~5 p' X2 {6 i- p2 R3 g
  }
: P& v" Y0 q. t* y3 r1 ~; ?  $ r& {" Y" E- y  U1 j" C
  download_sdk() {
( h2 m$ _$ n* v% ?0 [
3、从腾讯镜像下载openwrt-19.07.1-bcm53xx-tplink-archer-c9-v1-squashfs.bin,从固件中提取rootfs并预处理。0 O2 @' H% w- O9 d) U) P( d# E
  1. x@x-Surface-Pro-3:~/下载$ binwalk openwrt-19.07.1-bcm53xx-tplink-archer-c9-v1-squashfs.bin
    5 x! N6 @$ z, w7 Z! L

  2. 9 C* l  Y/ T1 o" K  K" g) _
  3. DECIMAL       HEXADECIMAL     DESCRIPTION6 W9 T) G' F5 Q( A
  4. --------------------------------------------------------------------------------+ m  c' G# H; U5 V! j1 ~
  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
    : Z. x" c9 B, o( `
  6. 8345          0x2099          LZMA compressed data, properties: 0x5D, dictionary size: 65536 bytes, uncompressed size: 1801662 bytes
    ( t8 e  @: J9 q2 Q" e6 M
  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
    7 d# a7 O: O' a" B1 {- L/ e& ]2 s

  8. 7 V0 O& P9 |4 W% z5 G
  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
    2 l6 L5 ]) h" Q* j& L$ n
  10. 记录了1900548+0 的读入& u5 ^! n0 G$ Q7 j( J; T
  11. 记录了1900548+0 的写出
    / b* V3 _* X/ n1 I7 r
  12. 1900548 bytes (1.9 MB, 1.8 MiB) copied, 5.16823 s, 368 kB/s/ N: _. J* T5 {, W
  13. x@x-Surface-Pro-3:~/下载$ binwalk rootfs-squashfs.bin 6 e3 L$ m7 u3 S4 X

  14. & V4 p/ h* y, F8 Q
  15. DECIMAL       HEXADECIMAL     DESCRIPTION
    + @# i9 ?5 q" `  {9 S
  16. --------------------------------------------------------------------------------- @! o* U$ R& A) m" x
  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
    5 m! }( G4 m* g/ Y+ b+ H& c  g

  18. 9 p: c7 a- S4 V$ e; z& O
  19. x@x-Surface-Pro-3:~/下载$ unsquashfs rootfs-squashfs.bin 8 X$ t" i/ c/ a' C  u5 O, J
  20. Parallel unsquashfs: Using 4 processors
    / {! Z6 V! T3 J8 a
  21. 1071 inodes (1066 blocks) to write
    / Z( N) b2 `* f: E7 ]  a
  22. ) r0 ^( t- o$ x! C% e$ W
  23. , K% T9 e" m" T4 s" Y2 A% n% k: j
  24. create_inode: could not create character device squashfs-root/dev/console, because you're not superuser!
    + l7 G  c/ ~& c; n, }" f1 U
  25. [====================================================================================================| ] 1065/1066  99%& I4 i4 b4 z7 Z8 p

  26. + W! r# S* q5 X' V
  27. created 875 files+ h5 @5 s7 F+ v" `+ W, `9 k/ m
  28. created 103 directories
    ! b/ a1 Q" @/ x4 L( z
  29. created 195 symlinks
    " B) ^0 B1 `2 W
  30. created 0 devices
    ) K6 L% C  K/ l6 ?: f, D
  31. created 0 fifos
    : Q5 g+ i! t/ w* G* h5 W) k
  32. x@x-Surface-Pro-3:~/下载$ cd ./squashfs-root/
    , m8 B+ j& \$ V; i% }/ ?# D2 I0 C
  33. x@x-Surface-Pro-3:~/下载/squashfs-root$ gedit etc/opkg/distfeeds.conf
复制代码
将opkg软件源改为腾讯镜像
2 @4 Z& ]  p* E5 S1 S  w2 S
src/gz openwrt_core https://mirrors.cloud.tencent.co ... xx/generic/packages
5 d  M$ `1 _! h+ Fsrc/gz openwrt_kmods https://mirrors.cloud.tencent.co ... 92b7d7eca715b1ee0b83 m% S9 G9 i* u( m/ M
src/gz openwrt_base https://mirrors.cloud.tencent.co ... /arm_cortex-a9/base
' O# I; g% L& @% F) asrc/gz openwrt_luci https://mirrors.cloud.tencent.co ... /arm_cortex-a9/luci5 l: z: p4 K4 U- i
src/gz openwrt_packages https://mirrors.cloud.tencent.co ... _cortex-a9/packages9 W! |/ i; i& M4 e# H0 c
src/gz openwrt_routing https://mirrors.cloud.tencent.co ... m_cortex-a9/routing
) T. W. y) |) K; V: U' ~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 ./
    ( c/ W1 r  x# q1 y
  2. x@x-Surface-Pro-3:~/下载/squashfs-root$ cd ../
    + s) ^, X# B! j1 M
  3. x@x-Surface-Pro-3:~/下载$ mkdir lxd-openwrt-master/dl
    % w+ {  |4 f% V, _: K  T1 v; ^
  4. x@x-Surface-Pro-3:~/下载$ mv openwrt-19.07.1-bcm53xx-generic-rootfs.tar.gz lxd-openwrt-master/dl/
复制代码
执行修改过的build.sh3 o% _. w7 ]0 l+ h  P$ j! o
  1. x@x-Surface-Pro-3:~/下载$ cd lxd-openwrt-master/" A1 Z$ J0 N9 Q/ D! S  i
  2. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ ./build.sh -a arm -v 19.07.1! C7 x. ~1 S2 S. O& L
  3. ......
    , p! T  `( H, P# ^+ g+ f& p$ z
  4. Pack rootfs* H6 Y$ U/ o/ Q' x6 I
  5. Tarball built: bin/openwrt-19.07.1-bcm53xx-generic-lxd.tar.gz
    ( ]" K4 Y" n1 H6 p3 T0 D9 s
  6. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ mkdir ../openwrt-19.07.1-bcm53xx-generic-lxc; F8 z- K! c* g1 a& a
  7. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ tar zxf bin/openwrt-19.07.1-bcm53xx-generic-lxd.tar.gz -C ../openwrt-19.07.1-bcm53xx-generic-lxc1 h+ V) @* i  c' Q% E) u
  8. x@x-Surface-Pro-3:~/下载/lxd-openwrt-master$ cd ../openwrt-19.07.1-bcm53xx-generic-lxc// o9 Q0 S  u2 X4 L& }  S- u8 G
  9. x@x-Surface-Pro-3:~/下载/openwrt-19.07.1-bcm53xx-generic-lxc$ ls8 E0 a' G- J7 ]
  10. metadata.yaml  rootfs  templates
    2 V% w# I) v! R! Y
  11. x@x-Surface-Pro-3:~/下载/openwrt-19.07.1-bcm53xx-generic-lxc$
复制代码
  Z4 a3 r- f$ O5 l. ~
4、这时我们已经创建好lxc下可运行的openwrt19.07.1的rootfs,接下来处理lxc及rootfs的配置文件。- F- R2 [" s0 \" |3 v4 r
进光猫复制自带子系统的两个文件,再通过U盘或ftp传到Ubuntu的openwrt-19.07.1-bcm53xx-generic-lxc目录下,
9 O7 S# S/ f  w0 t; p- L
  1. root@F650A:~ # cp /opt/upt/framework/saf/config /mnt/USB_disc1/# ?* x( O; ]' o. v+ _5 u
  2. root@F650A:~ # cp /opt/upt/framework/pre-start.sh /mnt/USB_disc1/
复制代码
config为saf系统的配置文件,新系统下稍作修改,1 J, U" |- ?( ~0 h/ v  _
lxc.arch = arm
* D+ u1 P, ]) j% a4 Y5 Tlxc.utsname = openwrt2 {2 o6 b) z* L% z$ P
lxc.rootfs.mount = /usr/var/lib/lxc/openwrt/rootfs6 Q* L  ?* x) t3 U: M
lxc.rootfs.path = overlayfs:/opt/upt/framework1/rootfs:/opt/upt/apps/openwrt-rootfs
$ |' i- E7 C; z# {4 g% F& L# lxc.rootfs = /usr/var/lib/lxc/openwrt/rootfs ; a5 d8 R' P- b% A( Z9 Z5 ~! c$ \3 W9 C
lxc.haltsignal = SIGUSR14 n8 a* O( [8 N# Q$ P9 _% E
lxc.tty = 16 w4 e8 S4 e, b9 s* \6 U' C
lxc.pts = 1
" t$ P5 g6 M5 Plxc.hook.pre-start = /usr/var/lib/lxc/openwrt/pre-start.sh9 @- F# m9 ]$ X( I, ~& M; Q
lxc.aa_profile = lxc-container-default-with-nesting5 j  t6 B% m: b4 F8 d- ]# ?2 p% |
lxc.network.type = none% e- `% y) D8 n9 q/ h% A
lxc.mount.entry = sysfs sys sysfs defaults 0 0
8 ]2 [& m6 [0 U/ ?" R' Hlxc.mount.auto = cgroup-full:rw  ~! C& h. ~1 ~* `3 [8 z% ]  @
lxc.mount.entry = proc proc proc defaults 0 0
! ]1 _9 D* t4 P; k* F- llxc.mount.entry = /mnt mnt none rw,rbind 0 0- K5 H) J+ r2 v' `; N1 k
lxc.start.auto = 1

$ L- G+ H1 F0 u$ I- ?3 U) y* kpre-start.sh处理模拟终端,为避免重复挂载devpts,添加一行卸载代码,* D4 A% ^3 s' ~9 _9 q# q( W7 {
#!/bin/sh, C8 T0 j6 ?0 `, U
umount /dev/pts /dev/ptmx4 N" S. \. L4 i. E
mount -t devpts -o newinstance -o ptmxmode=0666,nosuid devpts /dev/pts
* N1 D5 ^5 _% M0 Q" D  jmount -o bind /dev/pts/ptmx /dev/ptmx

# e% n* P7 @: T$ d8 ~2 T! D再删除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镜像,
# q. G' c' p& }2 M( Z. B
  1. x@x-Surface-Pro-3:~/下载$ mksquashfs openwrt-19.07.1-bcm53xx-generic-lxc openwrt-19.07.1-bcm53xx-lxc.bin  p2 r8 ]$ X/ ?# R
  2. Parallel mksquashfs: Using 4 processors7 ?) c+ v: c: `2 m' D# l3 Z2 l  F; q
  3. Creating 4.0 filesystem on openwrt-19.07.1-bcm53xx-lxc.bin, block size 131072.
    ( @; _+ Z& K1 k8 I# M8 J6 a( }) V
  4. [=======================================================================================================/] 881/881 100%
    7 d" Z8 H" E( |( ?% q/ z, v) }; z) H

  5. 9 q$ }+ J$ \; j" x
  6. Exportable Squashfs 4.0 filesystem, gzip compressed, data block size 131072
    7 I$ |! e) e: x" G2 e- ~. L" I
  7.         compressed data, compressed metadata, compressed fragments,
    ; u6 I" Q( f) m
  8.         compressed xattrs, compressed ids
      ^. O1 ?9 O2 Z# Z& A8 J6 h; y
  9.         duplicates are removed
    - h' O& o6 a5 F6 n
  10. Filesystem size 3163.90 Kbytes (3.09 Mbytes)
    : q* o9 l" D8 I# D* H% b
  11.         48.94% of uncompressed filesystem size (6464.54 Kbytes)3 u8 p- h6 v* {! g( K! Y2 _
  12. Inode table size 9693 bytes (9.47 Kbytes)7 V4 T% ^" ~/ `
  13.         25.72% of uncompressed inode table size (37693 bytes)3 P) ^  I- {# g$ J1 J
  14. Directory table size 11372 bytes (11.11 Kbytes)
    , ]& V& I7 g& m2 n  H" y. d! M% u/ V  c7 x
  15.         47.17% of uncompressed directory table size (24108 bytes)% t4 u  f1 n  _( z) z( p/ g/ q1 `
  16. Number of duplicate files found 136
    3 I1 Q) `8 C  `; }" C# b( a8 \8 e
  17. Number of inodes 1145% d/ P9 p1 G! C# I3 Y, [- Z
  18. Number of files 873  \, y& l" f% D
  19. Number of fragments 39) T! |3 A0 E9 t
  20. Number of symbolic links  171
    * o, g1 k5 q4 N- P0 i0 R
  21. Number of device nodes 0+ v9 k; o- Q2 \+ b, ~5 J
  22. Number of fifo nodes 03 G! Z! |# K; r; ?
  23. Number of socket nodes 0
    ( g- _2 S( ?- O: p/ ^# ?
  24. Number of directories 101
    " j' K: p( g# g
  25. Number of ids (unique uids + gids) 1# u. G$ l- y; o
  26. Number of uids 1
    0 Y7 ]( b2 b& C0 t1 [& }. R8 [8 R1 P
  27.         x (1000)( P4 j. U- K! H
  28. Number of gids 1
    # {7 d6 V& ~$ `# g$ X$ y  H
  29.         x (1000)
    % l9 h. B6 W1 m, E
  30. x@x-Surface-Pro-3:~/下载$
复制代码

  h' l4 D- A" v/ Q4 [
+ ~! b  K% R7 m8 p! D& p5 T' a& Z3 `5、生成的openwrt-19.07.1-bcm53xx-lxc.bin传入光猫,'mtd' 写入mtd7分区。
: K$ H( M! L9 F# Y* f0 `刷之前先关掉saf,因saf有lxc-monitord进程守护,kill掉之后会自动运行,只好修改saf程序名,重启光猫。
& ~0 J5 u, c5 {" S: Y
  1. root@F650A:~ # mv /usr/sbin/saf /usr/sbin/saf.bak
    3 H, `! j$ t9 h4 `
  2. root@F650A:~ # reboot
复制代码
重启后telnet登录,'ps' 确认进程列表没有saf,备份然后写入并挂载。
root@F650A:~ # ps
( F1 n% D* d# n/ i, B5 U2 `  PID USER     VSZ   RSS  STAT  CPU COMMAND8 r7 Z- S- F( v! H# x, D
    1 root     23160   600  S     <1>  init) l2 I; z, @" {6 L7 d, l
    ......9 W7 D, B" @  W; `$ C
root@F650A:~ # dd if=/dev/mtd7 of=/mnt/USB_disc1/mtd7.bin bs=1M7 s$ y8 U; @3 c, q; v" v
8+0 records in; p0 p: x( A2 }
8+0 records out/ t  t3 n7 t+ c2 s( N) g3 m
root@F650A:~ # mtd write /mnt/USB_disc1/openwrt-19.07.1-bcm53xx-lxc.bin /dev/mtd74 v& z; }4 k+ l8 |! ]" d/ l/ e
Unlocking /dev/mtd7 ...
& I" ^0 {" u! X/ o2 c* P7 ]" Y0 H* }9 ^# B+ P# C' x  ?* a
Writing from /mnt/USB_disc1/openwrt-19.07.1-bcm53xx-lxc.bin to /dev/mtd7 ...
, t4 h. W# C9 N  c8 `  m7 B$ T, Mroot@F650A:~ # mount /dev/mtdblock7 /opt/upt/framework1

8 o* I0 A; F7 ^& ]6、开启OpenWRT新世界. E# v- z. i7 P5 y  {+ q; K- y
    写入mtd7分区并挂载之后,开始首次启动的准备工作。F650A的lxc默认路径在/usr/var/lib/lxc(一楼有说明),按config文件创建相应文件及文件夹,
5 n9 J3 [$ K8 ^6 i* y& u1 b% h' \5 `: O! ]0 ^
  1. root@F650A:~ # mkdir -p /usr/var/lib/lxc/openwrt
    # f" N; {) I0 z+ C
  2. root@F650A:~ # cd /usr/var/lib/lxc/openwrt8 q& g8 h! Y: ]3 B3 ?
  3. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/pre-start.sh pre-start.sh* t6 L+ b2 G( T9 e0 `0 l( X5 _
  4. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/config config; s; |4 t% _8 L6 h
  5. root@F650A:/usr/var/lib/lxc/openwrt # mkdir rootfs
    # j9 c" z! `, p( [
  6. root@F650A:/usr/var/lib/lxc/openwrt # mkdir /opt/upt/apps/openwrt-rootfs: h7 z7 B0 f# F" C9 W
  7. root@F650A:/usr/var/lib/lxc/openwrt # lxc-start -dn openwrt
    , [2 L- E& ^6 X4 l4 G* @
  8. root@F650A:/usr/var/lib/lxc/openwrt # ps
复制代码
此时的进程列表应该可以看到/usr/sbin/uhttpd、dropbear等,或者可以尝试打开浏览器 http://光猫ip/或ssh登录,如果看到Authorization Required提示登录或ssh提示登录用户名密码,表明lxc已成功运行,但此时无密码状态无法网页和ssh登录,只能通过控制台方式添加密码后才能实现。关闭openwrt容器,'ps' 确认,前台启动。7 }$ M9 Y% v; I. Q! E2 W
  1. root@F650A:/usr/var/lib/lxc/openwrt # lxc-stop -kn openwrt
    ( T& _3 X( C7 V5 F" H/ S
  2. root@F650A:/usr/var/lib/lxc/openwrt # ps" a. I* E$ g6 b9 e& f4 x) a+ E
  3. root@F650A:/usr/var/lib/lxc/openwrt # lxc-start -n openwrt
    & |( u2 }6 I# ], ^9 M9 U+ B, V
  4. <6>init: Console is alive
    5 b% v; U' O% D$ |( c% a1 O! V
  5. <6>kmodloader: loading kernel modules from /etc/modules-boot.d/*
    * y9 a, d9 y, ]* I1 S( O
  6. <6>kmodloader: done loading kernel modules from /etc/modules-boot.d/*6 Y+ }" G% }5 T3 A7 U% e
  7. <6>init: - preinit -
    - F0 s- x/ U* H, `
  8. WARNING: Variable 'network' does not exist or is not an array/object
    $ J; x; L1 e) @+ x/ {
  9. WARNING: Variable 'lan' does not exist or is not an array/object4 e- t6 V" q" _
  10. Press the [f] key and hit [enter] to enter failsafe mode" Z/ \7 ^& q9 j- ?
  11. Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
    3 A2 m5 ~. `+ R4 H
  12. <5>mount_root: mounting /dev/root3 ^5 M3 F+ M" a4 {* ?" ^4 m5 P7 E. p
  13. urandom-seed: Seeding with /etc/urandom.seed
    3 B; R; V8 d( u( h1 t& _
  14. <6>procd: - early -# O1 o  d! v7 ~% d7 e8 K- _
  15. <6>procd: - ubus -1 z4 M: h, x4 z$ |9 y* I5 d3 m- f
  16. <6>procd: - init -3 a& h  s/ Z, n9 O
  17. Please press Enter to activate this console.& t' R, o( y; k; x; H( }% ^
  18. <6>urngd: v1.0.2 started.
复制代码
此时回车便可看到openwrt的登入界面,添加密码。
  p6 Q9 _; @" W  V

  1. 5 Q4 d- R3 x0 y6 H, y
  2. BusyBox v1.30.1 () built-in shell (ash)
    - o" v8 X" g. Q8 Q

  3. 2 x! t# w4 D$ X/ x5 U; N
  4.   _______                     ________        __
    9 u% x- x$ Z  t: l
  5. |       |.-----.-----.-----.|  |  |  |.----.|  |_$ ^" ^- y9 Y0 L# U- n
  6. |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|# m: r3 F, T, b3 h
  7. |_______||   __|_____|__|__||________||__|  |____|9 |1 s. P7 ?  [) u, p
  8.           |__| W I R E L E S S   F R E E D O M" l+ _2 i- K! b9 E
  9. -----------------------------------------------------
    2 G1 x  o4 N7 M/ n% k4 d$ b9 Z) ~; y
  10. OpenWrt 19.07.1, r10911-c155900f66
    - u" Z& W9 s: @! h/ p
  11. -----------------------------------------------------) }) G( K. g, X* P  }1 ^5 r: v
  12. root@openwrt:/# passwd root
    * y8 r1 C/ {4 W& O- }: f0 F; Z/ a
  13. Changing password for root. m& V' i9 b% R
  14. New password:
    , Q. b" l" g& a) ?
  15. Bad password: too weak
    : {6 U9 V) ^/ t: B
  16. Retype password: 6 l# v' y* {: Y$ e1 U: _
  17. passwd: password for root changed by root
    % e& a& K1 t: w
  18. root@openwrt:/# exit
    ; ]2 X* [* n" ~  C
  19. Please press Enter to activate this console.
复制代码
控制台方式进入openwrt之后,exit无效,没找到正常的退出方式,只能关闭窗口,此后就可以通过网页和ssh正常登录。
6 y. w4 A& T4 C8 r9 ^4 R( k* @: t; R& r1 C; i" n; o; r; k
7、自启动及进程守护8 ^1 c, H& G; R9 b. A  a
    telnet登录光猫主系统,确认saf程序已备份,
6 Q4 h0 s* j3 B; k4 F* O% M( a$ q8 k
  1. root@F650A:~ # ls /usr/sbin/
    & Q' ~$ N+ W" w" T' P2 l& K3 |
  2. chroot       lsap         saf.bak      telnetd
    $ N2 Z' P- t' M
  3. root@F650A:~ # vi /usr/sbin/saf
复制代码
填入 (2021年5月更新:去除USB端口挂载判定,避免无挂载时LXC不能启动)
: Y5 B2 }, T% p2 D; n/ F  g
#!/bin/sh. C( D# r8 h6 {) Z# v
# add user-defined startup scripts here0 b3 q$ z/ d9 G+ p/ p9 U1 s
0 e7 E+ H; H. q0 E
  df | grep mtdblock7- P& a0 @5 I# \5 }% i$ f6 m/ `9 W
  if [ $? -ne 0 ]
8 T# K% w8 u2 u7 q5 _9 e- Z1 k    then
' ~; R' C4 x6 C1 O      /bin/mount -n -t squashfs -o ro /dev/mtdblock7 /opt/upt/framework1. w' O% q3 N% z9 Q/ x1 h
  fi2 U1 E, m( l- F- M1 X
##' p2 X4 s5 z" p4 E1 A2 a

( m. n  V' m, U6 f/ l( X#  ps | grep ntfsmount | grep -v grep- q. B0 a% `1 J1 C3 |
#  if [ $? -eq 0 ]
6 u* D9 h1 l0 p( S#    then
9 P$ f5 c- W' O6 o2 d      /dbus/usr/bin/lxc-start -dn openwrt1 x1 w8 h# a! v7 t5 ^
#  fi2 d8 F. M! Y8 P+ }5 l
##
+ S/ s- T* m' Z& n
或者在电脑编辑好内容,命名为saf,传入/usr/sbin/,'chmod +x' 添加执行权限,重启光猫。
0 \( Z- e& ?8 H! G$ X6 `; Y- l+ \. _7 j  _
8、后续问题! R) d, M8 }1 i: o2 A: u
    目前的openwrt安装或更新程序会报错,缺少 libustream-openssl 、ca-bundle 、ca-certificates 和 libopenssl1.1,还需要修改dns,添加中文等
; i9 ]( ?" r  \6 Y3 U8 B1 A3 X- ^& T$ Q' z) d7 T; f
  1. root@openwrt:~# opkg update) u; o. {9 W4 p( t- }$ _, d9 ~
  2. Downloading https://mirrors.cloud.tencent.com/lede/releases/19.07.1/targets/bcm53xx/generic/packages/Packages.gz
    6 G! M( y4 ~5 L' S6 w* ]2 C
  3. wget: SSL support not available, please install one of the libustream-.*[ssl|tls] packages as well as the ca-bundle and ca-certificates packages.
    ! y6 {3 w1 V  L- A
  4. *** Failed to download the package list from https://mirrors.cloud.tencent.com/lede/releases/19.07.1/targets/bcm53xx/generic/packages/Packages.gz
复制代码
这些安装包可以从腾讯的镜像站下载然后手动安装。
9 p9 z9 e3 N  V, c* }# {
  1. root@openwrt:~# cd /mnt/USB_disc1/
    ( h$ e0 W, j6 e  y
  2. root@openwrt:/mnt/USB_disc1# opkg install *.ipk
复制代码
修改dns
: W! d7 w# q5 v
  1. root@openwrt:/mnt/USB_disc1# rm /etc/resolv.conf
    8 Z$ Z  @; I6 d2 o
  2. root@openwrt:/mnt/USB_disc1# vi /etc/resolv.conf
复制代码
填入,保存
6 f' n1 \9 P7 t6 @" T  l6 ]- l2 D
nameserver      223.5.5.5$ f# B+ ~6 y2 C# N4 l4 J$ ^% i
nameserver      8.8.8.8# T  q8 |) h# k% ]3 V( R" A5 i3 A
nameserver      2001:da8::666

; \# z( T  ?6 X6 W# W/ h嫌过程繁琐的可以直接下载我配置好的镜像,从第5部分最后开始操作,将下载的openwrt-19.07.1-bcm53xx-lxc.bin和saf-lxc-start-openwrt放入光猫上的u盘,子系统默认root密码123456。
% Q$ s+ k5 g6 `, X9 u
  1. root@F650A:~ # dd if=/dev/mtd7 of=/mnt/USB_disc1/mtd7.bin bs=1M
    ) S, ~+ n& L9 I% W2 ~3 z* C1 r
  2. root@F650A:~ # mtd write /mnt/USB_disc1/openwrt-19.07.1-bcm53xx-lxc.bin /dev/mtd7
    9 V$ u6 e# V! }& D3 h+ Z/ m
  3. root@F650A:~ # mount /dev/mtdblock7 /opt/upt/framework1
    ) X+ ]* L0 O) H$ T( C8 V  x; E
  4. root@F650A:~ # mkdir -p /usr/var/lib/lxc/openwrt
    5 {; g+ P& c) W+ A- _
  5. root@F650A:~ # cd /usr/var/lib/lxc/openwrt3 a8 ~# F6 a( D7 Q" r4 |) i
  6. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/pre-start.sh pre-start.sh- O  G  O9 w0 f( u9 j# S
  7. root@F650A:/usr/var/lib/lxc/openwrt # ln -s /opt/upt/framework1/config config" V1 p/ Y5 J7 n1 ^
  8. root@F650A:/usr/var/lib/lxc/openwrt # mkdir rootfs* K" r% x/ c' j& B* j( G
  9. root@F650A:/usr/var/lib/lxc/openwrt # mkdir /opt/upt/apps/openwrt-rootfs
    ( h' K% T3 e+ j) k5 R( v
  10. root@F650A:/usr/var/lib/lxc/openwrt # lxc-start -dn openwrt
    ' m9 S# x6 o9 A8 [  s
  11. root@F650A:/usr/var/lib/lxc/openwrt # cd ~
    % U/ R; c3 ^; ?9 H" f" w
  12. root@F650A:~ # mv /usr/sbin/saf /usr/sbin/saf.bak( b8 h8 y+ v3 H; I4 R
  13. root@F650A:~ # cp /mnt/USB_disc1/saf-lxc-start-openwrt /usr/sbin/saf! P; f# z$ Y+ \3 u* \* u* [
  14. root@F650A:~ # chmod 0755 /usr/sbin/saf
复制代码
   虽然子系统的openwrt可以顺利运行,但经过我的测试,kmod类app大多无法正常工作。比如F650A内核不支持ext4文件系统,在子系统安装kmod-fs-ext4,尽管可以安装成功,但重启后提示 modprobe 启用ext4模块失败。
1 ^( U; Y9 \$ 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管理页面,需要更改光猫主系统,此操作的定制空间更大,有机会的话在后面回复中整理出自定义光猫固件的思路。
: B/ y* U6 [4 `' @' J6 I, p0 e
" e. L7 L% q& w4 o9 x* n5 J% h

本帖子中包含更多资源

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

×
发表于 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刷进去的?
$ q& O* c, `% f* E, M中兴非15.0.1出问题是你没清理/opt/upt/apps//apps目录
: ~! c% n8 @+ T几乎所有光猫为了节省空间?都会有部分lib和var目录重用主系统的文件,openwrt下e8clib和e8cvar可以看看。) i5 Q9 N3 T6 S; j1 Z% N
另外中兴编译的openwrt开始了uclibc的xlocale配置,这也是achaoge直接用omap源的APP无法运行的原因,我自己有手动开启xlocale后编译omap的openwrt放进去运行OK。5 x$ s; J: H1 n/ i5 i6 _5 k
有兴趣可以一起研究玩。
 楼主| 发表于 2020-2-20 21:40:34 | 显示全部楼层
anysoft 发表于 2020-2-20 12:58
, b9 v( X+ T  q1 q坐等lxc的教程,另外19openwrt是你自己编译的还是直接下载armv7的官方bin刷进去的?
) K  [7 ~4 L* J  |+ T中兴非15.0.1出问题是 ...

( c' Z; ^0 l* A2 _+ L7 I
( U+ X' J" S- J" Q9 w7 U, Bopenwrt1907用的官方rootfs经https://github.com/mikma/lxd-openwrt修改而来;xlocale的问题我在编译主系统的busybox时也发现了,官方用的应该是buildroot2015.08.1,如果有dtb和驱动甚至可以自己写个固件了。
发表于 2020-2-21 14:42:33 | 显示全部楼层
songee 发表于 2020-2-20 21:40
+ |9 s, A+ D, x- L! Z( nopenwrt1907用的官方rootfs经https://github.com/mikma/lxd-openwrt修改而来;xlocale的问题我在编译主 ...

& J: n- f$ o4 e! _! X0 J是的, 中兴使用的是buildroot-2015.8.1,这个strings 一下sendcmd 就可以看到
7 U# P4 [7 V* k: ~/ E8 o) r
; \2 ]* n0 T" d% N: ~7 y- e看了下操作步骤,其实如果内存足够,没必要关闭saf启动的天翼网关。: {' [, @4 E" `7 j
可以让lxc容器启动两个op应该是可以的,F650A和华为hs8145V应该都是512MB内存,内存足够,openwrt可以放到apps分区文件夹下,不一定要写入mtd7再手动挂载。& Y* o# J# g1 D( ^" f" y
( _6 d- c' h) {$ |* m1 u( Q% a# A4 [
我的HS8145V启动后内存只占用了30%,足够了。
  _9 s9 a9 B; {- p' t% l/ M6 D  h8 ?. C
另外主系统下的usr/sbin目录下文件不是内存加载的rootfs对应的squash文件?这个更改应该不会回写到文件系统,重启应该就会消失?
! @; W1 ~1 E) Z* q不晓得中兴和华为是不是一样的。可能中兴可以修改文件吧,华为的只能dd备份rootfs分区后自己解包修改打包后再dd写进去,会有砖的风险,砖了只能上编程器。3 c, l" @2 Q- u0 y% z+ H
. Z, u3 p. A+ k$ B( f7 j
至于端口问题可以在打包openwrt的时候先修改每个服务对应监听端口就不会冲突了。. o! a6 C6 D' K# z

本帖子中包含更多资源

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

×

点评

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

本版积分规则

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

粤公网安备 44152102000001号

GMT+8, 2024-3-29 17:52 , Processed in 0.046928 second(s), 8 queries , Redis On.

Powered by Discuz! X3.5 Licensed

Copyright © 2001-2020, Tencent Cloud.

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