四、联网
只要有一个Linux,就给我提供了很好的“折腾”的环境。首先,我想要试试我的开源项目sysstat(一个简单的系统占用查看工具),我的输入/输出:
[root@milkv-duo]~
--1970-01-01 00:17:04-- https://gitcode.com/BiaoZyx/sysstat/releases/download/v2.0.0/sysstat
Resolving gitcode.com... failed: Try again.
wget: unable to resolve host address 'gitcode.com'
奇怪的是,并没有网络连接,我仔细一瞧:“1970-01-01 00:17:04”——这个时候我还没有出生呢!现在,时间戳出现问题,导致无法联网(一种普遍的检测方式,通过时间戳拦截访问),一种方法是进行时间同步。
但很快我意识到事情的严重性,看下面输出:
[root@milkv-duo]~
Exiting, name server cannot be used: Try again (-3) 1 Jan 00:32:57 ntpdate[401]: name server cannot be used: Try again (-3)
居然无法进行时间同步?看来只能先换一种策略了。先进行WiFi网络的连接:
(引用官方操作方法)
“
方法一
编辑如下文件(/etc/wpa_supplicant.conf),替换 ssid 和 psk 为要连接的 WIFI 账号和密码:
ctrl_interface=/var/run/wpa_supplicant
ap_scan=1
update_config=1
network={
ssid="wifi_test"
psk="12345678"
key_mgmt=WPA-PSK
}
再执行如下命令:
wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf
即可连接 WIFI,连接之后可以通过 ifconfig 或者 ip a 命令查看分配的 IP 地址。
如果需要开机自动连接 WIFI,可以把以下命令放到 /mnt/system/auto.sh 文件中。
interface="wlan0"
max_attempts=100
attempt=0
log_file="/var/log/auto.sh.log"
echo "start auto.sh" > "$log_file"
while [ $attempt -lt $max_attempts ]; do
ip link show "$interface" > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "$(date +'%Y-%m-%d %H:%M:%S') $interface interface exists, starting wpa_supplicant..." >> "$log_file"
wpa_supplicant -B -i "$interface" -c /etc/wpa_supplicant.conf >> "$log_file"
break
else
echo "$(date +'%Y-%m-%d %H:%M:%S') $interface interface not found, waiting..." >> "$log_file"
sleep 1
attempt=$((attempt + 1))
fi
done
if [ $attempt -eq $max_attempts ]; then
echo "$(date +'%Y-%m-%d %H:%M:%S') Interface $interface not found after $max_attempts attempts" >> "$log_file"
fi
”
我按照官网来,官方镜像仅提供了一个vi作为编辑器(这已经不错了)
输入:
vi /etc/wpa_supplicant.conf
进行代码的编辑。
其他则全部照搬。如,联网:
[root@milkv-duo]~
Successfully initialized wpa_supplicant
…………
终于做完了一切,再试试安装sysstat:
[root@milkv-duo]~
--2025-06-28 10:42:39-- https://gitcode.com/BiaoZyx/sysstat/releases/download/v2.0.0/sysstat
Resolving gitcode.com... 116.205.2.91
Connecting to gitcode.com|116.205.2.91|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://file-cdn.gitcode.com/5634378/releases/untagger_2084b40dee07421d9884cd8eef097887/sysstat?auth_key=1751107360-2552b640646d442abd88d5efb4d5d706-0-b8da8cd30f117f2c9da626d971ff98e408d5cdb1c0f669b91bbe21420ecb6958 [following]
--2025-06-28 10:42:40-- https://file-cdn.gitcode.com/5634378/releases/untagger_2084b40dee07421d9884cd8eef097887/sysstat?auth_key=1751107360-2552b640646d442abd88d5efb4d5d706-0-b8da8cd30f117f2c9da626d971ff98e408d5cdb1c0f669b91bbe21420ecb6958
Resolving file-cdn.gitcode.com... 221.229.160.35, 221.229.160.34, 221.229.160.33, ...
Connecting to file-cdn.gitcode.com|221.229.160.35|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2150 (2.1K) [application/octet-stream]
Saving to: 'sysstat'
sysstat 100%[=================================================>] 2.10K --.-KB/s in 0s
2025-06-28 10:42:40 (42.6 MB/s) - 'sysstat' saved [2150/2150]
[root@milkv-duo]~
autologin
[root@milkv-duo]~
[root@milkv-duo]~
===== SYSTEM OVERVIEW =====
OS: |NAME=Buildroot
Kernel: |5.10.4-tag-
Arch: |aarch64
uptime: invalid option -- 'p'
Try 'uptime --help' for more information.
Uptime: |
===== RESOURCE USAGE =====
Memory: |27Mi/316Mi (8.5%)
Disk: |236M/739M (35%)
grep: unrecognized option: P
BusyBox v1.37.0 (2025-05-30 15:02:52 CST) multi-call binary.
Usage: grep [-HhnlLoqvsrRiwFE] [-m N] [-A|B|C N] { PATTERN | -e PATTERN... | -f FILE... } [FILE]...
Search for PATTERN in FILEs (or stdin)
-H Add 'filename:' prefix
-h Do not add 'filename:' prefix
-n Add 'line_no:' prefix
-l Show only names of files that match
-L Show only names of files that don't match
-c Show only count of matching lines
-o Show only the matching part of line
-q Quiet. Return 0 if PATTERN is found, 1 otherwise
-v Select non-matching lines
-s Suppress open and read errors
-r Recurse
-R Recurse and dereference symlinks
-i Ignore case
-w Match whole words only
-x Match whole lines only
-F PATTERN is a literal (not regexp)
-E PATTERN is an extended regexp
-m N Match up to N times per file
-A N Print N lines of trailing context
-B N Print N lines of leading context
-C N Same as '-A N -B N'
-e PTRN Pattern to match
-f FILE Read pattern from file
grep: unrecognized option: P
BusyBox v1.37.0 (2025-05-30 15:02:52 CST) multi-call binary.
Usage: grep [-HhnlLoqvsrRiwFE] [-m N] [-A|B|C N] { PATTERN | -e PATTERN... | -f FILE... } [FILE]...
Search for PATTERN in FILEs (or stdin)
-H Add 'filename:' prefix
-h Do not add 'filename:' prefix
-n Add 'line_no:' prefix
-l Show only names of files that match
-L Show only names of files that don't match
-c Show only count of matching lines
-o Show only the matching part of line
-q Quiet. Return 0 if PATTERN is found, 1 otherwise
-v Select non-matching lines
-s Suppress open and read errors
-r Recurse
-R Recurse and dereference symlinks
-i Ignore case
-w Match whole words only
-x Match whole lines only
-F PATTERN is a literal (not regexp)
-E PATTERN is an extended regexp
-m N Match up to N times per file
-A N Print N lines of trailing context
-B N Print N lines of leading context
-C N Same as '-A N -B N'
-e PTRN Pattern to match
-f FILE Read pattern from file
IP: |N/A N/A
===== HARDWARE INFO =====
CPU: |Unknown
Temp: |48.6°C
Users: |
===== PROCESSES =====
PID USER %CPU %MEM CMD
这里,翻车了,因为这个脚本使用的是systemed的环境,但这块板子用的是Busy-Box。但不可否认——联上网了!