Skip to content

opkg 与常用软件包

基本用法

bash
opkg update                    # 每次装东西前先跑,列表不持久
opkg install luci-app-upnp
opkg remove luci-app-upnp
opkg list-installed
opkg list | grep ddns          # 搜
opkg info luci-app-sqm

opkg update 拉下来的索引放在 /tmp,重启就没了,所以每次装东西前都要跑一次。

空间

软件包装在 overlay 分区,小机器只有几 MB:

bash
df -h /overlay

快满了就别装了。装满会导致配置保存失败、LuCI 打不开,甚至启动不了。空间紧的机型用在线固件选择器把包打进固件里,比装到 overlay 省空间。

换源

国内直连官方源慢,改 /etc/opkg/distfeeds.conf,把域名换成镜像站。常用的有中科大 mirrors.ustc.edu.cn 和清华 mirrors.tuna.tsinghua.edu.cn,路径保持不变。ImmortalWrt 也有对应镜像。

bash
sed -i 's|downloads.openwrt.org|mirrors.ustc.edu.cn/openwrt|g' /etc/opkg/distfeeds.conf
opkg update

常用的包

用途
luci-i18n-base-zh-cn中文界面
luci-app-ddns + ddns-scripts动态域名
luci-app-upnpUPnP,游戏机 / BT 需要
luci-app-wol网络唤醒
luci-app-sqm流控,缓解 bufferbloat
luci-app-statistics流量 / 负载图表
luci-app-ttyd网页终端
luci-app-attendedsysupgrade在线升级,保留已装的包
luci-app-adblock广告域名屏蔽
htop curl nano tcpdump-mini排错工具

luci-app-* 装了通常还要装对应的 luci-i18n-*-zh-cn 才有中文。

升级后包会丢

sysupgrade 只保留配置,不保留 overlay 里装的包。升级完得重装一遍,或者用 attended sysupgrade 把包一起编进新固件。见升级

opkg 正在被 apk 替代

OpenWrt 主线(24.10 之后的 snapshot)已经把包管理器换成了 apk,命令变成 apk update / apk add。24.10 稳定版和 ImmortalWrt 24.10 还是 opkg。以后升到新大版本时注意看 release notes。

个人笔记,写给未来忘事的自己。