Cannot resize my root partition on BPI-R3

Hello,

I am looking to extend the basic partition on the BPI R3. I managed to write the image (OpenWRT snapshot Index of /snapshots/targets/mediatek/filogic/) to the internal eMMC memory without any problem. Only, the root partition storage space is ridiculous compared to the actual eMMC memory capacity.

I tried several methods without success. I can’t resize the partition properly. With parted, I managed to change the size of the “/dev/mmcblk0p5” volume.

Old :

image

Actually :

image

But, available space is not correct :

image

Can you help me ? I haven’t found anything that helps me…

Thank you.

You have to resize filesystem too,not only change partition table. Command depends on filesystem type.

You need to resize the filesystem in the (now bigger) /dev/mmcblk0p66 (which is split-off from /dev/mmcblk0p5).

But why do you like to add the remains space to the root filesystem in first place? As rootfs overlay is re-created ever time you upgrade the system imho it doesn’t make sense to keep anything big there anyway. It’s much better to create additional volumes, e.g. using uvol or by simply creating one large additional partition.

What command should I use to resize the filesystem? Because resizefs.f2fs doesn’t work… Do I also need to modify the /dev/mmcblk0p66 partition? I don’t clearly understand what I should do. Some tutorials explain differently and I can’t figure out what actually applies to the R3 model.

I’ve also tried creating another partition and mounting it elsewhere (extroot: https://openwrt.org/docs/guide-user/additional-software/extroot_configuration) but that doesn’t work either. The partition is never mounted over the other and the displayed partition size always remains the same.

On the R3 the /dev/mmcblk0p66 device is automatically mapped as the remaining space on /dev/mmcblk0p5 after parsing the uImage.FIT for kernel, device tree and read-only squashfs rootfs (squashfs filesystem is mapped as /dev/mmcblk0p65). So those p65 and p66 partitions are not actual GPT partitions but rather p65 is the filesystem sub-image of the uImage.FIT stored in p5 and p66 is the remaining space on p5 after the uImage.FIT.

Hence you only need to edit the size of /dev/mmcblk0p5, then reboot, then use resizefs.f2fs with /dev/mmcblk0p66 which will automatically reflect the changed size of the /dev/mmcblk0p5 partition after reboot.

For extroot to work you need to install block-mount (or better to deal also with removable media: install blockd).

In general I’d still recommend you to install uvol which allows you to manage additional storage volumes more easily. In order to automatically allocate all unused storage on the device used to boot and store the root filesystem you can install the autopart package.

Sidenote: The first part of your post is in French and you should write in English here.

1 Like

Sorry, it’s a mistake… I started writing in French then I came back later to finish writing my text before posting it…

Great ! autopart saved me and you too :rofl:

I will try other configurations to see if everything is ok.

Everything is okay !

For others : Boot in recovery or on nand (jumpers in H L H L [NAND] or L H H L [eMMC])

Install “parted” (“opkg install parted”)

Use parted to resize partitions 3 and 4 to the right size (that the sectors follow each other because there are empty spaces between the partitions).

Resize partition 5, the system will indicate that the disk (GPT) does not have its maximum size, “fix” and resize the partition to the maximum of its value (“unit s” [sectors], “print free” [show free space after last partition], “resizepart” then enter partition number [5], ending size [15269854s] in my case).

Then quit and install “autopart” (“opkg install autopart”), I don’t know what is used by autopart at the end, but it takes care of refreshing the partition size which will be at the correct dimension after reboot.

Thanks @dangowrt :+1::kissing_heart:

For what you are doing you don’t even need autopart (which would try to use the remaining space you have now already allocated to the production partition).

Yes, in my case it did nothing since there was no more space available at the end of the disk (no error, no message).

Without using autopart, on restart, I did not see the total space but always about 100MB. I think it’s running a command to refresh the partitions or something.

In case you are building OpenWrt from source, the size of the production partition can also be defined in menuconfig:

screenshot

This sets the configuration variable CONFIG_TARGET_ROOTFS_PARTSIZE in .config which you can also edit when using the ImageBuilder.

1 Like

i can’t get resize.f2fs to work. always get this error.

root@OpenWrt:/# resize.f2fs /dev/mmcblk0p66
Info: Mounted device!
Info: Check FS only on RO mounted device
        Error: Failed to open the device!

root@OpenWrt:/# parted
[   72.615289] mtdblock: MTD device 'reserved' is NAND, please consider using UBI block devices instead.
[   72.625300] mtdblock: MTD device 'ubi' is NAND, please consider using UBI block devices instead.
[   72.639108] mtdblock: MTD device 'bl2' is NAND, please consider using UBI block devices instead.
[   72.648579] mtdblock: MTD device 'fip' is NAND, please consider using UBI block devices instead.
GNU Parted 3.4
Using /dev/mmcblk0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: MMC 008GB0 (sd/mmc)
Disk /dev/mmcblk0: 7818MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name          Flags
128     17.4kB  4194kB  4177kB                             bios_grub
 1      4194kB  4719kB  524kB                ubootenv      hidden, legacy_boot
 2      4719kB  6816kB  2097kB               factory       hidden
 3      6816kB  11.0MB  4194kB               fip           boot, hidden, esp
 4      12.6MB  46.1MB  33.6MB               recovery      boot, hidden, esp
 6      46.1MB  67.1MB  21.0MB               owrt-volumes  lvm
 5      67.1MB  835MB   768MB                production

(parted)

tried the autopart too, but still only showing 25mb free space. grafik

anyone has a hint on what failed?

You cannot resize /dev/mmcblk0p66 because that’s not really a partition but rather just the remaining space left after the uImage.FIT on /dev/mmcblk0p5, I have explained this in detail just a few posts above.

So i need to use ‘resize.f2fs’ with the ‘dev/mmcblk0p5’ partition which will automatically reflect the changed size in ‘/dev/mmcblk0p66’ partition after reboot?

Sorry, I may not have been fully awake when replying to your post. The partition table looks good, you have successful edited and expanded mmcblk0p5. To use resize.f2fs you need to boot into the recovery firmware or boot from SPI-NAND, so that the partition will not be in use while you are trying to resize it.

command is not included in recovery i assume.

You can install it via opkg. It will be gone after reboot, but good enough for a single use.

Do what it says :wink: Mount and unmount it first to replay logs before resizing.

okay… i seriously don’t understand whyever that would be needed, but it indeed works… Thanks a lot!

root@OpenWrt:/# mount /dev/mmcblk0p66 /mnt
root@OpenWrt:/# umount /dev/mmcblk0p66
root@OpenWrt:/# resize.f2fs /dev/mmcblk0p66
Info: MKFS version
  "Linux version 5.15.80 (builder@buildhost) (aarch64-openwrt-linux-musl-gcc (OpenWrt GCC 11.3.0 r21380-5429411f73) 11.3.0, GNU ld (GNU Binutils) 2.37) #0 SMP Fri Dec 2 15:57:48 2022"
Info: FSCK version
  from "Linux version 5.15.80 (builder@buildhost) (aarch64-openwrt-linux-musl-gcc (OpenWrt GCC 11.3.0 r21380-5429411f73) 11.3.0, GNU ld (GNU Binutils) 2.37) #0 SMP Fri Dec 2 15:57:48 2022"
    to "Linux version 5.15.80 (builder@buildhost) (aarch64-openwrt-linux-musl-gcc (OpenWrt GCC 11.3.0 r21380-5429411f73) 11.3.0, GNU ld (GNU Binutils) 2.37) #0 SMP Fri Dec 2 15:57:48 2022"
Info: superblock features = 0 :
Info: superblock encrypt level = 0, salt = 00000000000000000000000000000000
Info: Segments per section = 1
Info: Sections per zone = 1
Info: total FS sectors = 191392 (93 MB)
Info: CKPT version = 351ed6c6
Info: Duplicate valid checkpoint to mirror position 1024 -> 512
Info: Write valid nat_bits in checkpoint
[FIX] (move_one_curseg_info:2857)  --> Move curseg[0] 3 -> 4 after 1000

[FIX] (move_one_curseg_info:2857)  --> Move curseg[1] 5 -> 9 after 1000

[FIX] (move_one_curseg_info:2857)  --> Move curseg[2] 6 -> a after 1000

[FIX] (move_one_curseg_info:2857)  --> Move curseg[3] 0 -> b after 1000

[FIX] (move_one_curseg_info:2857)  --> Move curseg[4] 1 -> c after 1000

[FIX] (move_one_curseg_info:2857)  --> Move curseg[5] 2 -> d after 1000

Info: Write valid nat_bits in checkpoint
Try to do defragement: Done
[migrate_ssa: 270] Info: Done to migrate SSA blocks: sum_blkaddr = 0xe00 -> 0xe00
[migrate_nat: 387] Info: Done to migrate NAT blocks: nat_blkaddr = 0xa00 -> 0xa00
[migrate_sit: 445] Info: Done to restore new SIT blocks: 0x600
Info: Write valid nat_bits in checkpoint
[rebuild_checkpoint: 591] Info: Done to rebuild checkpoint blocks
[update_superblock: 701] Info: Done to update superblock

Done: 0.000000 secs
root@OpenWrt:/#



root@OpenWrt:/# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 5.5M      5.5M         0 100% /rom
tmpfs                   997.9M     68.0K    997.8M   0% /tmp
/dev/mmcblk0p66         719.8M    141.6M    578.1M  20% /overlay
overlayfs:/overlay      719.8M    141.6M    578.1M  20% /
tmpfs                   512.0K         0    512.0K   0% /dev
root@OpenWrt:/#

for some reason 141 mb is used now… more than full 104mb of available space before… but whatever. it works!

F2FS calculated free space is very conservative and always reserves a large part of the storage volume.

1 Like

I am also struggling with this problem.

image

I am using my bpi3 device in emmc mode.

BusyBox v1.35.0 (2022-12-10 16:36:12 UTC) built-in shell (ash) OpenWrt SNAPSHOT, r21438-8327e0fb72

i wrote down all the steps i took to increase Root partition.

if you follow step by step you can easily increase it: [BPI-R3]How to flash Openwrt snapshot on EMMC? Post nr5

2 Likes