wndr3700v4 刷 openwrt 一些小优化

1. WNDR3700V4 扩展分区大小

刷完 OpenWrt-18.06.0 后,根分区只利用了 14 MB,大多数帖子都是通过修改源码分区表,重新编译固件而全部利用剩余空间,不过这样做可以一劳永逸。但很容易变砖,而且刷回原厂变砖的概率极大。索性还是不动分区表,直接重新新建一个分区即可。重新建立一个分区坑也比较多 😂

root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 2.5M      2.5M         0 100% /rom
tmpfs                    61.0M      6.7M     54.4M  11% /tmp
/dev/ubi0_1              14.0M      8.1M      5.1M  61% /overlay
overlayfs:/overlay       14.0M      8.1M      5.1M  61% /
tmpfs                   512.0K         0    512.0K   0% /dev

Create ubifs volumes in Linux (OpenWRT

When using a router flashed with OpenWRT, you may find that the capacity of the filesystem is much smaller than the real capacity. For example, the router I use is Netgear WNDR4300 which has a 128MB Nand flash. But when using the ‘df -h’ command to inspect the space usage status, I surprisingly found that the space of the total mounting point ‘/‘ is only 14MB.

So to find out the reason and try to expand usable space, I used the command “dmesg” and “cat /proc/mtd” to collect the information of mtd devices.

Then, make the ubifs I need.

ubiformat /dev/mtd11
ubiattach -p /dev/mtd11
ubimkvol /dev/ubi1 -N data -s 90MiB
mount -t ubifs ubi1:data /opt
Finally, add the following lines to /etc/rc.local to make it mount when router starts.
ubiattach -p /dev/mtd11
mount -t ubifs ubi1:data /opt

完活后的分区信息

root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 2.5M      2.5M         0 100% /rom
tmpfs                    61.0M      6.7M     54.4M  11% /tmp
/dev/ubi0_1              14.0M      8.1M      5.1M  61% /overlay
overlayfs:/overlay       14.0M      8.1M      5.1M  61% /
tmpfs                   512.0K         0    512.0K   0% /dev
ubi1:data                81.4M      4.9M     72.3M   6% /opt

2.修改 opkg 默认安装路径

参照官方 Wiki opkg

/etc/opkg.conf
src/gz snapshots http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages
dest root /
dest opt /opt
lists_dir ext /var/opkg-lists
option overlay_root /overlay

opkg install zsh git -d opt

# 添加环境变量
export LD_LIBRARY_PATH="/opt/lib:/opt/usr/lib"
export PATH=/usr/bin:/usr/sbin:/bin:/sbin:/opt/usr/bin:/opt/bin

3.安装 frpc 并设置开机自启

先去现在自己路由器架构相同的编译 ipk 包,如果不清楚自己路由器芯片的架构,当你使用 opkg install 安装软件的时候软件源的 url 里有你的芯片架构。
openwrt-frp

我的 wndr3700v4 是 mips_24kc 的架构

wget https://github.com/kuoruan/openwrt-frp/releases/download/v0.29.0-1/frpc_0.29.0-1_mips_24kc.ipk
opkg install frpc_0.29.0-1_mips_24kc.ipk -d opt
ln -s /opt/usr/bin/frpc /usr/bin/frpc

可能会报错 😂 需要安装 libustream-openssl ca-bundle ca-certificates 这三个包

root@OpenWrt:/opt# wget https://github.com/kuoruan/openwrt-frp/releases/download/v0.29.0-1/frpc_0.29.0-1_mips_24kc.ipk
wget: SSL support not available, please install one of the libustream-.*[ssl|tls] packages as well as the ca-bundle and ca-certificates packages.

opkg install libustream-openssl  ca-bundle ca-certificates

4.安装 git

根分区剩余空间太小了,于是就安装在单独的分区 opt 分区 下

opkg install git -d opt
ln -s /opt/usr/bin/git-upload-pack /usr/bin/git-upload-pack
ln -s /opt/usr/bin/git-upload-archive /usr/bin/git-upload-archive
ln -s /opt/usr/bin/git-receive-pack /usr/bin/git-receive-pack
ln -s /opt/usr/bin/git-receive-pack /usr/bin/git

5. https

opkg install libustream-openssl  ca-bundle ca-certificates