Previously, the overlay expansion I shared involved copying the original OpenWrt /overlay partition and mounting it as an external overlay. However, in the latest OpenWrt/LEDE and CatWrt compiled based on LEDE, it is also not expandable. Although some have succeeded in expanding it, the success rate is not high. This summary is based on the first method from the Bilibili UP master 韩风 Talk video, which has a relatively high success rate because I did not successfully refresh the capacity in the firmware for the second method, so I gave up.
First, I would like to thank 韩风 for providing the method. If needed, you can check out his video; I will summarize it here.
In the v22.11 firmware, there is 100M of available space, which is strongly not recommended for beginners as a must-have option for installing OpenWrt! There are thresholds, and data is priceless. If needed, you can back up first before proceeding, or even create a snapshot for the virtual machine.
For the previous external overlay, you can refer to my blog post OpenWrt Overlay Partition Expansion Tutorial.
Preparation#
First, open the terminal and SSH into the soft router. Here, I am using CatWrt EFI boot firmware's built-in ttyd.
Let's first check the partition situation of the soft router with fdisk -l
.
root@CatWrt:~# fdisk -l
Disk /dev/loop0: 184.88 MiB, 193855488 bytes, 378624 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
GPT PMBR size mismatch (852511 != 7129087) will be corrected by write.
Disk /dev/sda: 3.4 GiB, 3650093056 bytes, 7129088 sectors
Disk model: VMware Virtual I
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 0EAC8D5A-F014-DB49-E8EB-FA846A473B00
Device Start End Sectors Size Type
/dev/sda1 512 33279 32768 16M Linux filesystem
/dev/sda2 33280 852479 819200 400M Linux filesystem
/dev/sda128 34 511 478 239K BIOS boot
Partition table entries are not in disk order.
You can see that the EFI version of the firmware has an additional 239k /dev/sda128 compared to the traditional mode, but the end sector is still at 819200. Remember this end sector, as many details later will revolve around this endpoint!
Next, we will proceed with the partitioning work. First, you need to understand whether your firmware needs to be upgraded. In CatWrt, we strongly recommend reserving 200M of free space, which now needs to be reserved after /dev/sda2.
First, enter the partition management tool by typing fdisk /dev/sda
.
Note that the sectors cannot be repeated!
Then type n
to create a new partition.
root@CatWrt:~# fdisk /dev/sda
Welcome to fdisk (util-linux 2.38).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
GPT PMBR size mismatch (852511 != 7129087) will be corrected by write.
This disk is currently in use - repartitioning is probably a bad idea.
It's recommended to umount all file systems, and swapoff all swap
partitions on this disk.
Command (m for help): _
Here, we are prompted to choose between a primary partition or an extended partition. We choose primary by entering p
(I did not encounter this, not everyone has it).
Select (default p): _
Here, we are prompted to choose a partition. Since this OpenWrt has not undergone any partitioning operations, we choose 3
.
Partition number (3-127, default 3): _
Here, we are prompted to give the /dev/sda3
partition a starting sector. According to future upgrade needs, we will add 409600 to the end sector of the /dev/sda2 partition.
That is, 2048 x 200, which is a 200M partition, reserving from the end point (≈852479) 860000 to 1269600 for upgrades, meaning we will start partitioning from sector 1270000.
Here, fill in 1270000.
First sector (852480-7129054, default 854016): _
For the end sector of the new partition, we can directly use the familiar g unit to start, and it is recommended to fill in +2g.
Last sector, +/-sectors or +/-size{K,M,G,T,P} (1270000-7129054, default 7127039): +2g
Type w
and press Enter to save successfully.
Created a new partition 3 of type 'Linux filesystem' and of size 2 GiB.
Command (m for help): w
The partition table has been altered.
Syncing disks.
root@CatWrt:~#
Now that the partition has been successfully created, you can check if the partition was successful with fdisk -l
.
root@CatWrt:~# fdisk -l
Disk /dev/loop0: 184.88 MiB, 193855488 bytes, 378624 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sda: 3.4 GiB, 3650093056 bytes, 7129088 sectors
Disk model: VMware Virtual I
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 0EAC8D5A-F014-DB49-E8EB-FA846A473B00
Device Start End Sectors Size Type
/dev/sda1 512 33279 32768 16M Linux filesystem
/dev/sda2 33280 852479 819200 400M Linux filesystem
/dev/sda3 1270000 5464063 4194064 2G Linux filesystem
/dev/sda128 34 511 478 239K BIOS boot
Partition table entries are not in disk order.
Formatting#
At this point, the partitioning work is complete, but it still needs to be formatted to ext4. Type mkfs.ext4 /dev/sda3
and press Enter.
root@CatWrt:~# mkfs.ext4 /dev/sda3
mke2fs 1.46.5 (30-Dec-2021)
Creating filesystem with 524258 4k blocks and 131072 inodes
Filesystem UUID: ff7a2c4a-fd56-42ad-a9ac-45ade1c5819a
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
Mounting#
Now that this is complete, the next step is to operate in the LuCi web backend. Go to System - Mount Points and find the Mount Point section to click Add
.
In the UUID section, select the newly created partition, which is ff7a2c4a-fd56-42ad-a9ac-45ade1c5819a (/dev/sda3, 2047 MB)
.
For the mount point, choose Use as root filesystem (/)
.
Check the box to enable this mount point √
.
Just now, we clicked to use the mount point as the root filesystem, and a string of code popped up in the root directory preparation. This is not an error; we need to slightly modify these commands to copy the root files to the mount point.
I have modified it; actually, comparing it, you can see that it is just changing sda1 in the example to sda3. You can directly enter these commands in the terminal.
mkdir -p /tmp/introot
mkdir -p /tmp/extroot
mount --bind / /tmp/introot
mount /dev/sda3 /tmp/extroot
tar -C /tmp/introot -cvf - . | tar -C /tmp/extroot -xf -
umount /tmp/introot
umount /tmp/extroot
reboot
The last command is to reboot, and you need to manually press Enter. If you see different outputs like (find something) near the end, please ensure you haven't skipped steps that could cause errors or firmware issues.
Following this guide, you should be able to expand successfully.
……
./www/uuandriod.png
./www/uuios.png
./boot/
./home/
./home/ftp/
./run/
./run/docker/
./run/docker/plugins/
./run/mount/
./run/blkid/
./run/blkid/blkid.tab
./run/blkid/blkid.tab.old
root@CatWrt:~# umount /tmp/introot
root@CatWrt:~# umount /tmp/extroot
root@CatWrt:~# reboot
After rebooting, the simplest way to check is to see if there is still extra space in the packages. Open System - Packages, and as shown, the expansion was successful. If you did not succeed in expanding, it is still recommended to delete sda3 and reset the OpenWrt configuration.
Docker#
Regarding Docker partitioning, I won't go into too much detail here. You can combine the above content and refer to the previous blog post on overlay expansion. You can also operate according to fdisk instead of cfdisk.
Type fdisk /dev/sda
.
Create a new partition n
.
Choose between a primary partition or an extended partition. We choose primary by entering p
(I did not encounter this, not everyone has it).
Select (default p): _
Choose a partition; here we select 4
.
Since the end sector after expanding (/dev/sda3) is at 5464063, we set the starting sector to 5466000
and press Enter.
Next, fill in how much space to allocate for the Docker partition, choosing +10g
.
Type w
and press Enter to save successfully.
Input mkfs.ext4 /dev/sda4
to format the Docker partition (/dev/sda4).
Go to System - Mount Points, and add the newly created partition /dev/sda4.
Set the mount point to Use as Docker data partition (/opt)
.
Check the box to enable the mount point √
.
Save and apply, and it is recommended to reboot to see that the Docker partition has been successfully expanded.
This article is synchronized and updated by Mix Space to xLog. The original link is https://www.miaoer.net/posts/network/expansion-overlay