测试硬件:AXT1800
1.升级固件
访问 http://192.168.8.1/ ,设置密码,升级固件(下载axt1800最新固件后,本地升级):https://dl.gl-inet.cn/router/axt1800/stable
2.挂载TF卡
参考:https://docs.gl-inet.cn/router/4/features/memory_mount/
df -h
Filesystem Size Used Available Use% Mounted on
/dev/mmcblk0p1 59.4G 768.0K 59.4G 0% /tmp/mountd/disk1_part1
卸载“网络存储”功能,如果不卸载网络存储功能,后续会有报错导致无法挂载内存:
umount /dev/mmcblk0p1
安装相关工具
opkg update && opkg install block-mount kmod-usb-storage kmod-fs-ext4 e2fsprogs kmod-fs-vfat
查看TF卡的分区信息:
blkid /dev/mmcblk0*
/dev/mmcblk0: PTTYPE="dos"
/dev/mmcblk0p1: UUID="c0553506-a9c2-439a-807b-d349f1f26785" BLOCK_SIZE="4096" TYPE="ext4"
TYPE 这里为exfat 或 ext4等
格式化TF卡:
mkfs.ext4 /dev/mmcblk0p1 << EOF
> EOF
给TF卡制作根文件系统:
mount -t ext4 /dev/mmcblk0p1 /mnt
mkdir /tmp/root
mount -o bind / /tmp/root
cp /tmp/root/* /mnt -a
umount /tmp/root
umount /mnt
配置自动挂载,并重启
block detect > /etc/config/fstab
uci set fstab.@mount[0].target='/overlay'
uci set fstab.@mount[0].enabled='1'root
uci commit fstab
reboot
貌似这样折腾后,相当于重置了系统,需要重新设置密码和时区。
设置swap
root# cat /proc/swaps
Filename Type Size Used Priority
root@GL-AXT1800:/usr/bin# df -h
Filesystem Size Used Available Use% Mounted on
mtd:ubi_rootfs 41.0M 41.0M 0 100% /rom
tmpfs 196.4M 48.7M 147.8M 25% /tmp
/dev/mmcblk0p1 58.3G 240.7M 55.1G 0% /overlay
overlayfs:/overlay 58.3G 240.7M 55.1G 0% /
tmpfs 512.0K 0 512.0K 0% /dev
/dev/mmcblk0p1 58.3G 240.7M 55.1G 0% /tmp/mountd/disk1_part1
root@GL-AXT1800:/usr/bin# cd /tmp/mountd/disk1_part1/
root@GL-AXT1800:/tmp/mountd/disk1_part1# dd if=/dev/zero of=/tmp/mountd/disk1_part1/swapfile bs=1M count=2048
2048+0 records in
2048+0 records out
root@GL-AXT1800:/tmp/mountd/disk1_part1# mkswap /tmp/mountd/disk1_part1/swapfile
Setting up swapspace version 1, size = 2147479552 bytes
root@GL-AXT1800:/tmp/mountd/disk1_part1# swapon /tmp/mountd/disk1_part1/swapfile
root@GL-AXT1800:/tmp/mountd/disk1_part1# free -m
total used free shared buff/cache available
Mem: 402300 143692 28192 49876 230416 161892
Swap: 2097148 0 2097148
卸载swap:
swapoff /tmp/mountd/disk1_part1/swapfile
设置开机自动挂载swap
vi /etc/init.d/auto_swap
START 中的数值越大,越后启动
#!/bin/sh /etc/rc.common
START=99
start(){
swapon /tmp/mountd/disk1_part1/swapfile
echo "swapon /tmp/mountd/disk1_part1/swapfile"
}
stop()
{
swapoff /tmp/mountd/disk1_part1/swapfile
echo "swapoff /tmp/mountd/disk1_part1/swapfile"
}
给权限,设置自动启动:
chmod +x /etc/init.d/auto_swap
service autoSwap enable
3.其他设置
访问 http://192.168.8.1/ ,设置密码、时区
更换openwrt shell解析器为bash,解决history不保存问题:
opkg update && opkg install bash
修改 root 用户的 shell 解释器
vi /etc/passwd
修改第一行(第一行就是 root 用户)中的 /bin/ash,改成 /bin/bash
重新ssh登录进去即可。
系统架构(axt1800 默认是32位系统):
uname -m
armv7l
- arm64和aarch64对应64位ARM架构(ARMv8),常见于移动设备和嵌入式系统。
- armv7l和arm对应32位ARM架构(ARMv7),常见于较旧的移动设备和嵌入式系统。
- x86_64、x64和amd64对应64位x86架构,常见于个人电脑和服务器。
- x86和i386对应32位x86架构,常见于较旧的个人电脑。(基本上可以淘汰了)
其他设置:
- 系统后台:概要,关闭LED
4.网络设置
4.1.VPS侧
ssh-keygen -t rsa -b 4096
现在,在当前用户的根目录中生成了一个 .ssh 的隐藏目录,内含两个密钥文件。id_rsa 为私钥,id_rsa.pub 为公钥。
保存私钥 id_rsa 文件到本地软路由,然后在VPS侧输入以下命令安装公钥, 将公钥写入到 authorized_keys 文件:
cd ~/.ssh/
cat id_rsa.pub >> authorized_keys
开启密钥登录选项,编辑 /etc/ssh/sshd_config 文件找到以下参数进行更改或直接添加:
RSAAuthentication yes
PubkeyAuthentication yes
重启服务:
service sshd restart
4.2. 软路由侧
mkdir ~/.ssh/
vi ~/.ssh/id_rsa
把vps上的id_rsa内容复制到 id_rsa
修改权限:
sudo chmod 600 ~/.ssh/id_rsa
参考:
- https://openwrt.org/docs/guide-user/services/ssh/sshtunnel
- https://oldwiki.archive.openwrt.org/doc/uci/sshtunnel
安装sshtunnel:
opkg update && opkg install sshtunnel
vi /etc/config/sshtunnel
config server vps_server
option user VPS_user_name
option hostname VPS_IP
option port VPS_SSH_port
option retrydelay 5
option CheckHostIP yes
option Compression yes
option CompressionLevel 9
option IdentityFile /VPS_user_name/.ssh/id_rsa
option LogLevel INFO
# option PKCS11Provider /lib/pteidpkcs11.so
option ServerAliveCountMax 3
option ServerAliveInterval 5
option StrictHostKeyChecking accept-new
option TCPKeepAlive yes
option VerifyHostKeyDNS yes
config tunnelD proxy
option server vps_server
option localaddress 192.168.8.1
option localport 4055
执行命令:
/etc/init.d/sshtunnel enable && /etc/init.d/sshtunnel start
相关命令:
/etc/init.d/sshtunnel enable
/etc/init.d/sshtunnel start
/etc/init.d/sshtunnel status
/etc/init.d/sshtunnel restart
/etc/init.d/sshtunnel stop
Available commands:
start Start the service
stop Stop the service
restart Restart the service
reload Reload configuration files (or restart if service does not implement reload)
enable Enable service autostart
disable Disable service autostart
enabled Check if service is started on boot
running Check if service is running
status Service status
trace Start with syscall trace
安装privoxy:
opkg update && opkg install privoxy
vi /etc/config/privoxy
config privoxy 'privoxy'
option confdir '/etc/privoxy'
option logdir '/var/log'
option logfile 'privoxy.log'
list listen_address '0.0.0.0:8118'
option forward_socks5 '/ 192.168.8.1:4055 .'
执行:
/etc/init.d/privoxy enabled && /etc/init.d/privoxy start
相关命令,没有status:
Syntax: /etc/init.d/privoxy [command]
Available commands:
start Start the service
stop Stop the service
restart Restart the service
reload Reload configuration files (or restart if service does not implement reload)
enable Enable service autostart
disable Disable service autostart
enabled Check if service is started on boot
手机代理:
192.168.8.1
8118
PC浏览器 SwitchyOmega:
协议:HTTP
192.168.8.1
8118
重启系统:
reboot
5.安装python3到tf卡
- 安装成功了部分模块
- 无法安装NumPy,pandas: numpy 需要特定版本的 OpenWrt才开始支持,另外就是 OpenWrt需要特定的编译选项,才能支持全版本的NumPy
部分参考资料:
- https://stackoverflow.com/questions/53457004/python-oserror-errno-28-no-space-left-on-device
- https://cloud.tencent.com/developer/article/2446273
- 可以为NumPy编译OpenBLAS for ARMV7: http://www.openmathlib.org/OpenBLAS/docs/install/
mkdir /tmp/mountd/disk1_part1/opt
mkdir /tmp/mountd/disk1_part1/tmp
vi /etc/opkg.conf
添加外置存储路径:
dest tf /tmp/mountd/disk1_part1/opt
vi /etc/profile
配置环境变量:
export LD_LIBRARY_PATH="/tmp/mountd/disk1_part1/opt/usr/lib:/tmp/mountd/disk1_part1/opt/lib"
export PATH="/usr/sbin:/usr/bin:/sbin:/bin:/tmp/mountd/disk1_part1/opt/usr/bin:/tmp/mountd/disk1_part1/opt/usr/sbin"
export TMPDIR=/tmp/mountd/disk1_part1/tmp
让修改后的profile立即生效:
source /etc/profile
安装前可以设置命令行代理:
export http_proxy="http://192.168.8.1:8118"
export https_proxy="http://192.168.8.1:8118"
安装:
opkg update
opkg install python3-base -d tf
opkg install python3-pip -d tf
opkg install python3 -d tf
升级pip,setuptools
python -m pip install --upgrade pip
pip install --upgrade setuptools
安装常用软件,指定目录 /tmp/mountd/disk1_part1/opt/usr/lib/python3.9/site-packages
pip install requests -t /tmp/mountd/disk1_part1/opt/usr/lib/python3.9/site-packages
pip install bs4 -t /tmp/mountd/disk1_part1/opt/usr/lib/python3.9/site-packages
安装pandas,依赖:https://pypi.org/project/pandas/#dependencies
- python-dateutil
- pytz
- numpy
pip install pytz -t /tmp/mountd/disk1_part1/opt/usr/lib/python3.9/site-packages
pip install python-dateutil -t /tmp/mountd/disk1_part1/opt/usr/lib/python3.9/site-packages
无法安装numpy:
pip install numpy -t /tmp/mountd/disk1_part1/opt/usr/lib/python3.9/site-packages
Collecting numpy
Using cached numpy-2.0.2.tar.gz (18.9 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
error: subprocess-exited-with-error
× pip subprocess to install backend dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
Installing backend dependencies ... error
error: subprocess-exited-with-error
× pip subprocess to install backend dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
OpenWrt-22.03.0 中可以安装python3-numpy,但是如果需要完全功能的版本,the INSTALL_GFORTRAN symbol needs\\ to be enabled in the OpenWrt core/toolchain.\\ \\
, 参考: https://openwrt.org/packages/pkgdata/python3-numpy
ackage: python3-numpy
Name:python3-numpy
Version:1.24.3-1
Description:NumPy is the fundamental package for array computing with Python.\\ \\ By default, this package is built without some modules.\\ For some modules to be available, the INSTALL_GFORTRAN symbol needs\\ to be enabled in the OpenWrt core/toolchain.\\ \\
Installed size:5915k
BDependencies:libc, librt, libpthread, python3
Categories:languages---python
Repositories:community-packages
Architectures:aarch64_cortex-a53, aarch64_cortex-a72, aarch64_generic, arc_archs, arm_arm1176jzf-s_vfp, arm_cortex-a15_neon-vfpv4, arm_cortex-a7_neon-vfpv4, arm_cortex-a8_vfpv3, arm_cortex-a9_neon, i386_pentium4, mipsel_24kc_24kf, powerpc_464fp, x86_64
OpenWrt release:OpenWrt-22.03.0
File size:5908kB
License:BSD-3-Clause
Maintainer:Alexandru Ardelean
Bug report:Bug reports
Source code:Sources