路由器

OpenWRT为NetgearR6800重新分区并构建镜像

2026-05-27 #OpenWRT

引言

先解释一下为什么要分区。默认情况下,固件打包时会将 rootfs_data(即 overlay)的大小硬编码在镜像中。 即使你的闪存芯片有 128MB 或 256MB,如果镜像配置只分了 40MB 给 overlay,那剩下的空间就处于“物理存在但不可使用”的状态。正常官方构建的镜像可用的overlay只有25MB左右,如果想装一个Xary根本不够,所以需要重新分区。

构建步骤

注:不要使用root用户

1.安装基础依赖

1
2
3
4
5
6
7
8
#ubuntu25
sudo apt install -y ack antlr3 asciidoc autoconf automake autopoint binutils bison build-essential \
bzip2 ccache clang cmake cpio curl device-tree-compiler flex gawk gcc-multilib g++-multilib gettext \
genisoimage git gperf haveged help2man intltool libc6-dev-i386 libelf-dev libfuse-dev libglib2.0-dev \
libgmp3-dev libltdl-dev libmpc-dev libmpfr-dev libncurses5-dev libncursesw5-dev libpython3-dev \
libreadline-dev libssl-dev libtool llvm lrzsz msmtp ninja-build p7zip p7zip-full patch pkgconf \
python3 python3-pyelftools python3-setuptools qemu-utils rsync scons squashfs-tools subversion \
swig texinfo uglifyjs upx-ucl unzip vim wget xmlto xxd zlib1g-dev

2.拉取OpenWRT镜像

1
2
3
# 这里采用了v24.10.6,当然你也可以选择更新的版本
git clone -b v24.10.6 https://github.com/openwrt/openwrt.git
cd openwrt

3.配置分区表

点击这里下载mt7621_netgear_sercomm_bzv.dtsi
将mt7621_netgear_sercomm_bzv.dtsi的内容替换至openwrt/target/linux/ramips/dts/mt7621_netgear_sercomm_bzv.dtsi

修改openwrt/target/linux/ramips/image/mt7621.mk 的 define Device/netgear_r6800 的 IMAGE_SIZE 为 77824k

此处mt7621_netgear_sercomm_bzv.dtsi感谢 @韬焘

3.配置构建目标

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig
#R6800 配置选项
#Target System (MediaTek Ralink MIPS) ---> │ │
#Subtarget (MT7621 based boards) ---> │ │
#Target Profile (NETGEAR R6800) --->

#1.启用luci网页 不然没有web界面
> LuCI > 1. Collections > luci
#2.启用中文这一步必须优先配置 不然会影响其他插件的中文
> LuCI > 2. Modules > Translations > zh
# 勾选
> LuCI > 4. Themes > Argon主题
#3.启用passwall
##3.1禁用dnsmasq 启用dnsmasq-full
> Base system > dnsmasq
##3.2顺便勾选 block-mount 和 badblocks 以启用自动挂载功能。
> Base system > block-mount
> Utilities —> Filesystem —> badblocks
# 不懂不要勾
> LuCI > 3. Applications > luci-app-passwall
#4.启用ddns-script
> LuCI > 3. Applications > luci-app-ddns
#4.1启用ddns-scripts-cloudflare
> Network > IP Addresses and Names > ddns-scripts-cloudflare
#4.2添加openvpn
> LuCI > 3. Applications > luci-app-openvpn
> Network > VPN > openvpn-openssl
#5.配置sftp不然ideaSSH连不上OpenWrt,不用勾选openssh-server,默认有ssh
> Network > SSH > openssh-sftp-server
#6.配置usb
> Kernel modules > USB Support > kmod-usb-core
> Kernel modules > USB Support > kmod-usb2 #(USB 2.0 支持)
> Kernel modules > USB Support > kmod-usb3 #(USB 3.0 支持)
> Kernel modules > USB Support > kmod-usb-storage
> Kernel modules > USB Support > kmod-usb-storage-extras #(可选,支持额外设备)
> Kernel modules > Filesystems > kmod-fs-ext4 #(支持 ext4 文件系统)
> Kernel modules > Filesystems > kmod-fs-exfat #(支持 exFAT 文件系统)
> Kernel modules > Filesystems > kmod-fs-vfat #(支持 FAT 文件系统)
> Kernel modules > Filesystems > kmod-fs-ntfs3 #(支持 NTFS 文件系统)
#7.添加UTF8编码,CP437编码,ISO8859-1编码
> Kernel modules > Native Language Support > kmod-nls-utf8
#8.添加工具
> Utilities > Disc > fdisk
> Utilities > usbutils
> Utilities > Shells > bash
> Utilities > Editors > vim

4.构建

1
2
3
4
5
6
#先下载
make download -j8 V=s
#尝试构建
make -j1 V=s
#当然也可以直接拉满,出了错在-j1
make -j$(nproc) V=s

5.验证

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
root@OpenWrt:/# ubinfo -d 0 -a
ubi0
Volumes count: 2
Logical eraseblock size: 126976 bytes, 124.0 KiB
Total amount of logical eraseblocks: 608 (77201408 bytes, 73.6 MiB)
Amount of available logical eraseblocks: 0 (0 bytes)
Maximum count of volumes 128
Count of bad physical eraseblocks: 0
Count of reserved physical eraseblocks: 20
Current maximum erase counter value: 5
Minimum input/output unit size: 2048 bytes
Character device major/minor: 251:0
Present volumes: 0, 1

Volume ID: 0 (on ubi0)
Type: dynamic
Alignment: 1
Size: 169 LEBs (21458944 bytes, 20.4 MiB)
State: OK
Name: rootfs
Character device major/minor: 251:1
-----------------------------------
Volume ID: 1 (on ubi0)
Type: dynamic
Alignment: 1
Size: 415 LEBs (52695040 bytes, 50.2 MiB)
State: OK
Name: rootfs_data
Character device major/minor: 251:2
root@OpenWrt:/#

6.注意

如果第一次刷写后发现分区大小不对,不要惊慌,保留配置再刷一次即可,如果第二次刷写分区还是不对,那可能是你没改成功

附录

nmrpflash

1
2
3
4
5
6
nmrpflash.exe -L
eth12 10.10.100.3 1c:87:2c:64:ae:b1

# 镜像我自己测试官方/潘多拉/OpenWRT都可以
nmrpflash.exe -i eth12 -f R6800.img
nmrpflash.exe -i eth12 -f R6800.trx

成果

success.png

致谢

韬焘

评论
分享
Views
Users
Today