Skip to content

Instantly share code, notes, and snippets.

@kenchou
Last active February 12, 2025 10:57
Show Gist options
  • Save kenchou/381452b1fe6904100694b5db50710d2f to your computer and use it in GitHub Desktop.
Save kenchou/381452b1fe6904100694b5db50710d2f to your computer and use it in GitHub Desktop.
小米/红米路由器挂载 overlay
#!/bin/sh /etc/rc.common
START=00
. /lib/functions/preinit.sh
start() {
[ -e /data/overlay ] || mkdir /data/overlay
[ -e /data/overlay/upper ] || mkdir /data/overlay/upper
[ -e /data/overlay/work ] || mkdir /data/overlay/work
mount --bind /data/overlay /overlay
fopivot /overlay/upper /overlay/work /rom 1
#Fixup miwifi misc, and DO NOT use /overlay/upper/etc instead, /etc/uci-defaults/* may be already removed
/bin/mount -o noatime,move /rom/data /data 2>&-
/bin/mount -o noatime,move /rom/etc /etc 2>&-
/bin/mount -o noatime,move /rom/ini /ini 2>&-
/bin/mount -o noatime,move /rom/userdisk /userdisk 2>&-
return 0
}
# 【小米/红米】路由器需要额外的“固化”步骤,否则重启路由器后修改会丢失
uci set firewall.miwifi_overlay=include
uci set firewall.miwifi_overlay.type='script'
uci set firewall.miwifi_overlay.path='/data/etc/init.d/miwifi_overlay.sh'
uci set firewall.miwifi_overlay.enabled='1'
uci commit firewall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment