How to change partition size when building OpenWrt

I am currently using R6220
The partition information is as follows
########################################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

################################################
As you can see, the reserved space of 60M at the bottom is useless
I want to add this 60M reserved space to the root directory
Then I used Docker to building the firmware
################################################
docker run --rm -v /root/docker/openwrt/bin:/home/build/openwrt/bin -it openwrt/imagebuilder:ramips-mt7621-openwrt-23.05

######################################################################
cat /builder/target/linux/ramips/image/mt7621.mk
This file show the image space size of 28672k for r6220

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

&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;
		};
	};
};

######################################################################
Then modify the size
The total size of the space is 7E00000 126M
I changed the final reservation to 1M
All the extra space has been added to ubi
By the way, I also utilized the unused space between ubi and factory

The partition information after the final modification is as follows

&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;
		};
	};
};
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 := 120832k
  DEVICE_PACKAGES += kmod-mt76x2
  SUPPORTED_DEVICES += r6220
endef
TARGET_DEVICES += netgear_r6220

######################################################################
Start building

make PROFILE="netgear_r6220" image  PACKAGES="luci";

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

Finally, copy the compiled bin file and flash it into the router

######################################################################
But after the router restarts, the partition information remains the same as before

May I ask where I made a mistake in the building steps?

please fix your formatting ....

2 posts were split to a new topic: Building OpenWrt through Docker