找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 4510|回复: 5

编译openwrt怎么更改分区大小

[复制链接]
我目前用的R6220

然后分区信息如下


#####################################################root@OpenWrt:~# mount
/dev/root on /rom type squashfs (ro,relatime,errors=continue)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/ubi0_1 on /overlay type ubifs (rw,noatime,assert=read-only,ubi=0,vol=1)
overlayfs:/overlay on / type overlay (rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work)
tmpfs on /dev type tmpfs (rw,nosuid,noexec,noatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,noatime,mode=600,ptmxmode=000)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)
bpffs on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,noatime,mode=700)

#####################################################root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 3.8M      3.8M         0 100% /rom
tmpfs                    58.9M    216.0K     58.7M   0% /tmp
/dev/ubi0_1              17.1M      3.5M     12.8M  21% /overlay
overlayfs:/overlay       17.1M      3.5M     12.8M  21% /
tmpfs                   512.0K         0    512.0K   0% /dev

#####################################################root@OpenWrt:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00100000 00020000 "u-boot"
mtd1: 00100000 00020000 "SC PID"
mtd2: 00400000 00020000 "kernel"
mtd3: 01c00000 00020000 "ubi"
mtd4: 00100000 00020000 "factory"
mtd5: 03c00000 00020000 "reserved"

#####################################################root@OpenWrt:~# cat  /proc/partitions
major minor  #blocks  name

  31        0       1024 mtdblock0
  31        1       1024 mtdblock1
  31        2       4096 mtdblock2
  31        3      28672 mtdblock3
  31        4       1024 mtdblock4
  31        5      61440 mtdblock5
254        0       3844 ubiblock0_0

#########################################################################################


可以看到,最下面有60M的预留空间是没有用的
我想把这60M的预留空间添加到根目录去
然后我就用docker编译固件

######################################################################

docker run --rm -v /root/docker/openwrt/bin:/home/build/openwrt/bin -it openwrt/imagebuilder:ramips-mt7621-openwrt-23.05

######################################################################
然后查看信息
make info |more

找到R6220的信息
netgear_r6220:
    NETGEAR R6220
    Packages: kmod-mt7603 kmod-usb3 kmod-usb-ledtrig-usbport -uboot-envtools kmod-mt76x2
    hasImageMetadata: 1
    SupportedDevices: netgear,r6220 r6220

######################################################################
cat /builder/target/linux/ramips/image/mt7621.mk
这个文件里面有定义r6220的镜像空间大小 28672k

define Device/netgear_r6220
  $(Device/netgear_sercomm_nand)
  DEVICE_MODEL := R6220
  SERCOMM_HWNAME := R6220
  SERCOMM_HWID := AYA
  SERCOMM_HWVER := A001
  SERCOMM_SWVER := 0x0086
  IMAGE_SIZE := 28672k
  DEVICE_PACKAGES += kmod-mt76x2
  SUPPORTED_DEVICES += r6220
endef
TARGET_DEVICES += netgear_r6220
######################################################################
cat /builder/target/linux/ramips/dts/mt7621_netgear_r6220.dts

下面是关键的内容 reg = <0x600000 0x1c00000>;
这个表示从0x600000开始 有一个0x1c00000大小的空间
通过计算得知0x1c00000刚好就是十进制的28672k 和上面的IMAGE_SIZE := 28672k吻合

&nand {
        status = "okay";

        partitions {
                compatible = "fixed-partitions";
                #address-cells = <1>;
                #size-cells = <1>;

                partition@0 {
                        label = "u-boot";
                        reg = <0x0 0x100000>;
                        read-only;
                };

                partition@100000 {
                        label = "SC PID";
                        reg = <0x100000 0x100000>;
                        read-only;
                };

                partition@200000 {
                        label = "kernel";
                        reg = <0x200000 0x400000>;
                };

                partition@600000 {
                        label = "ubi";
                        reg = <0x600000 0x7600000>;
                };

                factory: partition@7C00000 {
                        label = "factory";
                        reg = <0x7C00000 0x100000>;
                        read-only;
                };

                partition@7D00000 {
                        label = "reserved";
                        reg = <0x7D00000 0x100000>;
                        read-only;
                };
        };
};

######################################################################
然后修改大小
空间的总大小是7E00000  126M
我把最后的预留改为了1M
多余的空间都添加到ubi了
顺便把ubi和factory中间没用到的空间也利用上了

最后改完以后的分区信息如下

&nand {
        status = "okay";

        partitions {
                compatible = "fixed-partitions";
                #address-cells = <1>;
                #size-cells = <1>;

                partition@0 {
                        label = "u-boot";
                        reg = <0x0 0x100000>;
                        read-only;
                };

                partition@100000 {
                        label = "SC PID";
                        reg = <0x100000 0x100000>;
                        read-only;
                };

                partition@200000 {
                        label = "kernel";
                        reg = <0x200000 0x400000>;
                };

                partition@600000 {
                        label = "ubi";
                        reg = <0x600000 0x7600000>;
                };

                factory: partition@7C00000 {
                        label = "factory";
                        reg = <0x7C00000 0x100000>;
                        read-only;
                };

                partition@7D00000 {
                        label = "reserved";
                        reg = <0x7D00000 0x100000>;
                        read-only;
                };
        };
};



  IMAGE_SIZE := 120832k

######################################################################
开始编译
make PROFILE="netgear_r6220" image  PACKAGES="luci";

最后把编译好的bin文件复制出来 刷到路由器里面
ls /builder/bin/targets/ramips/mt7621
可以看到下面的文件
sha256sums
profiles.json
openwrt-23.05-snapshot-r23800-100a5606d6-ramips-mt7621-netgear_r6220.manifest

openwrt-23.05-snapshot-r23800-100a5606d6-ramips-mt7621-netgear_r6220-squashfs-kernel.bin
openwrt-23.05-snapshot-r23800-100a5606d6-ramips-mt7621-netgear_r6220-squashfs-rootfs.bin

openwrt-23.05-snapshot-r23800-100a5606d6-ramips-mt7621-netgear_r6220-squashfs-sysupgrade.bin

openwrt-23.05-snapshot-r23800-100a5606d6-ramips-mt7621-netgear_r6220-squashfs-factory.img

######################################################################
我在breed界面直接刷入固件,重启以后分区信息还是原来的

请问我编译的步骤是哪里做错了吗?
为什么我修改了分区没生效


我的恩山、我的无线 The best wifi forum is right here.
学习一下,正好也有个6220
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

来自手机 | 显示全部楼层
https://www.idzd.top/archives/2484/
看看

点评

我用docker编译镜像 但是卡在make menuconfig这里了 菜单选项很少 能帮忙看看是什么原因吗 过程如下 docker run --rm -v /root/docker/openwrt_sdk/sdk/:/home/sdk/ -it --privileged openwrt/sdk:ramips-mt762  详情 回复 发表于 2024-3-20 18:19
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| | 显示全部楼层
vision34 发表于 2024-3-20 00:34
https://www.idzd.top/archives/2484/
看看

我用docker编译镜像
但是卡在make menuconfig这里了  菜单选项很少
能帮忙看看是什么原因吗



过程如下
docker run --rm -v /root/docker/openwrt_sdk/sdk/:/home/sdk/ -it --privileged openwrt/sdk:ramips-mt7621-openwrt-23.05



然后输入make menuconfig  
选项很少 几乎没有选的



然后退出这个界面看到了很多报错


这个是什么原因?

是docker里面缺少东西吗?
还是说我运行docker的命令缺少了参数


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×

点评

可能是你在前面拉取源码的时候,因为网络原因(没有“师夷长技以制夷”),导致编译的时候部分源码不存在不完整  详情 回复 发表于 2024-4-11 18:00
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| | 显示全部楼层
./scripts/feeds update -a之后要执行./scripts/feeds install -a

op论坛的版主也这样回复的

我尝试了一下,用了一台深圳旁边的服务器
然后make menuconfig的时候貌似还是没有找到选路由器型号的选项
我就直接开始编译了,太慢了,我放弃了

目前这个路由器我就装了个KMS
默认的分区够用了

不折腾了
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

友谊 发表于 2024-3-20 18:19
我用docker编译镜像
但是卡在make menuconfig这里了  菜单选项很少
能帮忙看看是什么原因吗

可能是你在前面拉取源码的时候,因为网络原因(没有“师夷长技以制夷”),导致编译的时候部分源码不存在不完整
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

欢迎大家光临恩山无线论坛上一条 /1 下一条

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-29 00:33

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表