最近光猫玩得起劲,发现busybox
真的是好东西
这研究不要紧,被我发现了buxybox自带init
命令!
本来想要自己做一个BusyOS的,结果发现已经有成熟的方案了:alpine
!
手中没有x86的主机,所以我把目光放到了我的闲置Cm311-1 (S905L3)
(上次玩的是MGV3000,这两台机器主板相似度达到了惊人的90%)
折腾思路
alpine官网很快,即使安装完alpine apk
也不需要换源
- standard 是网络安装镜像
- EXTENDED 是本地安装镜像
- NETBOOT 需要远程服务器,是网络启动镜像
- RASPBERRY PI版本和GENERIC ARM版本与我们的启动方式(android U-BOOT)不兼容
- MINI ROOT FILESYSTEM 只支持docker和WSL等虚拟化容器
- VIRTUAL 适用于虚拟机
- XEN 与arm不兼容
这就很头疼了,因此我们需要以armbian为跳板,用MINI ROOT FILESYSTEM安装基础外围
使用u盘启动
额......请看我的文章,我就不赘述了
安装alpine
我们需要让armbian-install
帮助我们调整分区
第一次U盘启动可能需要设置,按照我的教程走就行
armbian:~:# armbian-install
[ STEPS ] Installing Armbian to internal eMMC...
[ STEPS ] Checking dependencies...
[ INFO ] Dependency check completed. Proceeding installation...
[ STEPS ] Initializing the environment...
[ INFO ] Use mainline u-boot: [ no ]
[ INFO ] Using ampart tool: [ yes ]
[ INFO ] Show all lists: [ no ]
[ INFO ] Internal eMMC : [ /dev/mmcblk2 ]
[ STEPS ] Start selecting device...
--------------------------------------------------------------------------------------
ID SOC MODEL DTB
--------------------------------------------------------------------------------------
101 s905d Phicomm-N1 meson-gxl-s905d-phicomm-n1.dtb
102 s905d Phicomm-N1(DMA-thresh) meson-gxl-s905d-phicomm-n1-thresh.dtb
103 s905d MECOOL-KI-Pro meson-gxl-s905d-mecool-ki-pro.dtb
104 s905d SML-5442TW meson-gxl-s905d-sml5442tw.dtb
105 s905x HG680P meson-gxl-s905x-p212.dtb
106 s905x B860H meson-gxl-s905x-b860h.dtb
107 s905x Nexbox-a95x meson-gxl-s905x-nexbox-a95x.dtb
108 s905x TX9 meson-gxl-s905x-tx9.dtb
109 s905x T95,XiaoMI-3S,X96 meson-gxl-s905x-p212.dtb
110 s905x TBee meson-gxl-s905x-tbee.dtb
--------------------------------------------------------------------------------------
111 s905w TX3-Mini meson-gxl-s905w-tx3-mini.dtb
112 s905w W95 meson-gxl-s905w-p281.dtb
113 s905w X96-Mini meson-gxl-s905w-x96-mini.dtb
114 s905w X96W,FunTV,MXQ-Pro-4K meson-gxl-s905w-x96w.dtb
115 s905l UNT402A,M201-S,MiBox-4C meson-gxl-s905l3b-m302a.dtb
116 s905l MG101,Mibox-4 meson-gxl-s905l-venz-v10.dtb
117 s905l2 MGV2000,MGV3000,M301A meson-gxl-s905l2-x7-5g.dtb
118 s905l2 E900v21E,MGV2000-K,e900v21d meson-gxl-s905l2-x7-5g.dtb
119 s905l2 Wojia-TV-IPBS9505 meson-gxl-s905l2-ipbs9505.dtb
120 s905l3 CM311-1,HG680-LC,M401A,UNT402A meson-gxl-s905l2-x7-5g.dtb
--------------------------------------------------------------------------------------
121 s905l3 CM211-1,M411A,B860AV3.2-M meson-gxl-s905l3b-m302a.dtb
122 s905l3 UNT400G1,E900V22D-2 meson-gxl-s905l2-x7-5g.dtb
123 s905l3b E900V22D,TY1608 meson-gxl-s905l2-x7-5g.dtb
124 s905l3b E900V21E,E900V22E,MGV2000 meson-gxl-s905l3b-e900v22e.dtb
125 s905l3b M302A,M304A,CM211-1,CM311-1 meson-gxl-s905l3b-m302a.dtb
126 s905l3b UNT403A meson-gxl-s905l3b-m302a.dtb
127 s905l3b RG020ET-CA meson-gxl-s905l3b-e900v22e.dtb
128 s905l3b IP103H,TY1608,BV310,B860AV-2.1M meson-gxl-s905l3b-m302a.dtb
129 s905lb BesTV-R3300L,SumaVision-Q7,MG101 meson-gxl-s905x-p212.dtb
130 s905lb Q96-mini meson-gxl-s905x-p212.dtb
--------------------------------------------------------------------------------------
131 s905mb S65 meson-gxl-s905x-p212.dtb
0 Other Customize Enter-custom-dtb-name
--------------------------------------------------------------------------------------
[ OPTIONS ] Please Input ID: 120
[ INFO ] Input Box ID: [ 120 ]
[ INFO ] Model Name: [ CM311-1,HG680-LC,M401A,UNT402A ]
[ INFO ] FDTFILE: [ meson-gxl-s905l2-x7-5g.dtb ]
[ INFO ] MAINLINE_UBOOT: [ ]
[ INFO ] BOOTLOADER_IMG: [ ]
[ INFO ] UBOOT_OVERLOAD: [ u-boot-p212.bin ]
[ INFO ] NEED_OVERLOAD: [ no ]
[ STEPS ] Which type of filesystem do you want for your root?
-----------------------------------------------
ID TYPE
-----------------------------------------------
1 ext4
2 btrfs
-----------------------------------------------
[ OPTIONS ] Please Input ID (1/2): 1
[ INFO ] Input Type ID: [ 1 ]
[ INFO ] Type of filesystem: [ ext4 ]
[ STEPS ] Partitioning eMMC...
[ INFO ] Start backing up the default bootloader.
4+0 records in
4+0 records out
4194304 bytes (4.2 MB, 4.0 MiB) copied, 1.73648 s, 2.4 MB/s
[ 254.098623] mmcblk2: p1 p2
[ INFO ] Delete the existing [ 2 ] partitions.
[ 254.271353] mmcblk2: p2
[ 254.387583] mmcblk2:
[ STEPS ] Successfully partitioned internal eMMC with amaprt.
[ INFO ] Start create MBR and partittion.
[ 254.597356] mmcblk2:
[ 254.714620] mmcblk2: p1
[ INFO ] 03. Write the mybox bootloader: [ /usr/lib/u-boot/mybox-bootloader.img ]
444+0 records in
444+0 records out
444 bytes copied, 0.00430079 s, 103 kB/s
[ 254.892213] mmcblk2: p1 p2
8191+0 records in
8191+0 records out
4193792 bytes (4.2 MB, 4.0 [ 255.315733] mmcblk2: p1 p2
MiB) copied, 0.453593 s, 9.2 MB/s
[ STEPS ] Processing BOOTFS partition...
[ INFO ] Formatting BOOTFS partition...
mkfs.fat 4.2 (2021-01-31)
[ INFO ] Copying BOOTFS ...
[ INFO ] Update the [ uEnv.txt ] file.
[ INFO ] Update the [ extlinux.conf ] file.
[ STEPS ] Start processing the rootfs partition...
[ INFO ] Formatting ROOTFS ...
/dev/mmcblk2p2 contains a ext4 file system labelled 'ROOTFS_EMMC'
last mounted on /root on Thu Jan 1 08:00:15 1970
[ 292.400037] EXT4-fs (mmcblk2p2): mounted filesystem with ordered data mode. Opts: (null). Quota mode: none.
[ INFO ] Copying ROOTFS ...
[ INFO ] Copying [ etc ] ...
^C
armbian:~:#
在出现 Copying ROOTFS 时Ctrl+C终止
右键复制链接,使用curl下载并解压到ddbr
cd /ddbr/install
rm -rf *
curl -L https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/aarch64/alpine-minirootfs-3.19.1-aarch64.tar.gz | tar xz
安装设置必须软件包
首先切换到alpine,安装必须外围
chroot . sh
# OpenRC 系统管理框架
apk add openrc
# 可选,用nano代替vi
apk add nano
# 使用ssh
apk add openssh
nano /etc/ssh/sshd_config
rc-status enable sshd default
修改两处:17、36行
然后运行passwd
,更改ROOT密码(否则SSH一定无法登录)
继续复制命令并运行:
# 安装网络管理
apk add networkmanager
rc-update add networkmanager default
# 安装系统工具
apk add chrony util-linux tzdata
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
echo "Asia/Shanghai" > /etc/timezone
rc-status chronyd default
rc-update add devfs boot
rc-update add procfs boot
rc-update add sysfs boot
rc-update add devfs boot
rc-update add procfs boot
rc-update add sysfs boot
rc-update add networking default
rc-update add sshd default
rc-update add chronyd default
# 重启
sync
exit
reboot
拔掉u盘启动系统,然后找服务器IP就可以SSH登录了!
疑难解答
apk: temporary error (try again later)
/ # apk add nano
fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/main/aarch64/APKINDEX.tar.gz
WARNING: updating and opening https://dl-cdn.alpinelinux.org/alpine/v3.19/main: temporary error (try again later)
fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/community/aarch64/APKINDEX.tar.gz
WARNING: updating and opening https://dl-cdn.alpinelinux.org/alpine/v3.19/community: temporary error (try again later)
ERROR: unable to select packages:
nano (no such package):
required by: world[nano]
找个梯子或者更改源,比如我使用光猫的clash服务
/ # export HTTP_PROXY=http://192.168.1.1:7890
/ # export HTTPS_PROXY=http://192.168.1.1:7890
/ # apk add nano
fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/main/aarch64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.19/community/aarch64/APKINDEX.tar.gz
(1/3) Installing ncurses-terminfo-base (6.4_p20231125-r0)
(2/3) Installing libncursesw (6.4_p20231125-r0)
(3/3) Installing nano (7.2-r1)
Executing busybox-1.36.1-r15.trigger
OK: 9 MiB in 18 packages
modprobe报错
* Loading modules ...
modprobe: can't change directory to '/lib/modules': No such file or directory
modprobe: can't change directory to '/lib/modules': No such file or direc [ ok ]
modprobe: can't change directory to '/lib/modules': No such file or directory
将/lib/modules
从U盘拷过去即可,很简单
cp /lib/modules /ddbr/install/lib
本文由 zlh 创作,采用 知识共享署名4.0 国际许可协议进行许可。
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名。