始终无法解决刷机后,系统变为read-only或者无法启动的问题。怀疑是mmc有问题。最终的解决方案是刷到U盘中。
写在前面
设备
- 咪咕盒子MG101
- 芯片类型 hi3798mv100
- 刷机包类型 mv100-mdmo1a-usb-flash.zip. 版本Hinas-20240201
- openwrt刷机包immortalwrt-21.02.7@armvirt/32
- 最终效果,U盘的sda1负责引导,sda2是一个immortalwrt,sda3是HiNas
刷机流程
- 按照HiNas官方刷一次系统
- 在能够进入系统的时候,立刻把fastboot分区删除
-
dd if=/dev/zero of=/dev/mmcblk0p1 bs=1024 count=1024
-
- 这样,启动权由U盘决定,又可以使用HiNas的内核
-
- 同时创建一个恢复系统(/dev/mmcblk0p7),见修改hinas的恢复分区
-
- 以后可以利用这个恢复系统安装系统
- 把U盘分成三个区, 第一个区是fat32,第二个区是ext4,第三个区是ext4
-
- 将
fastboot.bin
和启动到第二个区(sda2)的bootargs.bin
放到fat32分区
- 将
-
- 将openwrt的固件解压到sda2,HiNas解压到sda3
- 插入U盘开机
-
- 对于openwrt系统,开机后可能默认是主路由模式。关机,在恢复系统(/dev/mmcblk0p7)下修改
/etc/config/network
config interface 'lan' option device 'br-lan' option proto 'dhcp' #option proto 'static' #option ipaddr '192.168.1.1' #option netmask '255.255.255.0' #option ip6assign '60'
- 对于openwrt系统,开机后可能默认是主路由模式。关机,在恢复系统(/dev/mmcblk0p7)下修改
openwrt/immortalwrt配置
src/gz immortalwrt_core https://mirrors.cernet.edu.cn/immortalwrt/releases/21.02.7/targets/armvirt/32/packages
src/gz immortalwrt_base https://mirrors.cernet.edu.cn/immortalwrt/releases/21.02.7/packages/arm_cortex-a15_neon-vfpv4/base
src/gz immortalwrt_luci https://mirrors.cernet.edu.cn/immortalwrt/releases/21.02.7/packages/arm_cortex-a15_neon-vfpv4/luci
src/gz immortalwrt_packages https://mirrors.cernet.edu.cn/immortalwrt/releases/21.02.7/packages/arm_cortex-a15_neon-vfpv4/packages
src/gz immortalwrt_routing https://mirrors.cernet.edu.cn/immortalwrt/releases/21.02.7/packages/arm_cortex-a15_neon-vfpv4/routing
src/gz immortalwrt_telephony https://mirrors.cernet.edu.cn/immortalwrt/releases/21.02.7/packages/arm_cortex-a15_neon-vfpv4/telephony
#
opkg update
opkg install luci-app-samba4 luci-app-qbittorrent luci-app-zerotier luci-theme-argon openssh-sftp-server htop
#https://github.com/vernesong/OpenClash/releases
# opkg install luci-app-openclash_0.46.033-beta_all.ipk
刷HiNas和配置
- HiNas刷机后要等待五分钟
- HiNas中
poweroff
后是不会自动开机的
cd /tmp
mkdir a3
mount /dev/sda3 a3
mkdir b
mount /dev/sdb1 ./b
mkdir ubuntu
mount -o loop /tmp/b/Ubuntu-20.04.5-armhf-20240201-0d93d.img /tmp/ubuntu/
cp -a /tmp/ubuntu/* /tmp/a3/
#替换bootargs
设置
curl -s https://install.zerotier.com | sudo bash
cd /var/lib/zerotier-one
cp /tmp/a2/etc/config/zero/identity.* .
cp /tmp/a2/etc/config/zero/authtoken.secret .
zerotier-cli join 83048a063272598a
systemctl restart zerotier-one
systemctl enable zerotier-one
#
apt install ./mihomo-linux-armv7-v1.18.9.deb
systemctl enable mihomo
cp -r /tmp/a2/usr/share/openclash/ui /var/www/html/clashui
#clash页面ui
#http://ip/clashui/dashboard/index.html
#http://ip/clashui/yacd/index.html
#也可以把他们添加到hinas的首页
卸载用不到的, 只保留了
- dav共享 alist
- 文件上传 filebrowser
- 万一用到呢 Aria、tty
apt purge transmission-histb ddns-histb typecho-histb frpc-histb h5ai-histb tailscale-histb
清理主页
/var/www/html/icons_lan/wan/home.php
qbittorrent
- 不要用hinas仓库的,会被pt站拦截
- 只能用开源的
apt install qbittorrent-nox
vi /etc/systemd/system/qbittorrent.service
##
##
[Unit]
Description=qBittorrent Daemon Service
After=network.target
[Service]
User=root
ExecStart=/usr/bin/qbittorrent-nox
ExecStop=/usr/bin/killall -w qbittorrent-nox
[Install]
WantedBy=multi-user.target
##
systemctl daemon-reload
systemctl enable qbittorrent
U盘格式化命令
opkg install fdisk dosfstools
fdisk /dev/sdb
d
n,p,1-3,+1G,w
mkfs.fat -F 32 /dev/sdb1
mkfs.ext4 /dev/sdb2
mkfs.ext4 /dev/sdb3
迁移系统
mount /dev/sda2 a
mount /dev/sdb2 b
cp -a a/* b/
备份系统
ubuntu下面备份
tar -czvf /tmp/system_backup.tar.gz -C /tmp/b . --exclude=./proc --exclude=./sys --exclude=./dev --exclude=./tmp --exclude=./mnt
op下面备份,–exclude 不受支持
echo "/proc
/sys
/dev
/tmp
/mnt" > /tmp/exclude.txt
tar -czvf /tmp/system_backup.tar.gz -C /tmp/b -X /tmp/exclude.txt .
恢复
tar --preserve-permissions -xzvf /path/to/system_backup.tar.gz -C /mnt/target
创建bootargs
mkbootargs
从神雕大佬的ubuntu镜像中解压出来传到openwrt中就可以用
for boot in sda2 sda3 sdb2 sdb3
do
echo "baudrate=115200
ethaddr=00:11:22:33:44:55
ipaddr=192.168.1.10
netmask=255.255.255.0
gatewayip=192.168.1.1
serverip=192.168.1.1
bootcmd=mmc read 0 0x1FFFFC0 0x7000 0xA000;bootm 0x1FFFFC0
bootargs_512M=mem=512M mmz=ddr,0,0,48M vmalloc=500M
bootargs_1G=mem=1G mmz=ddr,0,0,48M vmalloc=500M
bootargs_2G=mem=2G mmz=ddr,0,0,48M vmalloc=500M
bootargs_768M=mem=768M mmz=ddr,0,0,48M vmalloc=500M
bootargs_1536M=mem=1536M mmz=ddr,0,0,48M vmalloc=500M
bootargs_3840M=mem=3840M mmz=ddr,0,0,48M vmalloc=500M
bootargs=console=ttyAMA0,115200 root=/dev/$boot rootfstype=ext4 rootwait blkdevparts=mmcblk0:1M(boot),1M(bootargs),4M(baseparam),4M(pqparam),4M(logo),20M(kernel),64M(busybox),512M(backup),-(ubuntu)
bootdelay=0
stdin=serial
stdout=serial
stderr=serial" > bootargs.$boot.txt
mkbootargs -s 64 -r bootargs.$boot.txt -o bootargs.$boot.bin
done
本文首发于我的博客@cndaqiang.
本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!