banner
miaoer

miaoer

喵二の小博客 https://www.miaoer.net xLog 分站
tg_channel
telegram
bilibili

OpenWrt router space not enough? Try expanding the root of the overlay.

Previously, I shared that the expanded overlay is a copy of the original OpenWrt /overlay partition and is mounted as an external overlay. However, in the latest OpenWrt/LEDE and CatWrt compiled based on LEDE, it cannot be expanded either. Although some have succeeded in expanding it, the success rate is not high. This summary is based on the first method in the video by Bilibili UP master 韩风 Talk, which has a relatively high success rate because I abandoned the second method as I could not refresh the capacity in the firmware successfully.

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 invaluable; if needed, please back up before proceeding, or you can even create a snapshot for the virtual machine.




For the previous external overlay, you can refer to my blog post OpenWrt Expansion Overlay Partition Tutorial


Preparation#

First, open the terminal and SSH into the soft router. Here, I use the ttyd that comes with the CatWrt EFI boot firmware.

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 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 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 select a partition. Since this OpenWrt has not undergone any partitioning operations, we choose 3.

Partition number (3-127, default 3): _

Here, we need 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 new partition's end sector, we can directly use the g unit we are most familiar with, 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:~# 

This successfully creates the partition. 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 done, proceed to the LuCi web backend to operate. Go to System - Mount Points and find the Mount Point section, then 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, select Use as root filesystem (/).

Check the box to enable this mount point .

image

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 modify these commands slightly to copy the root files to the mount point.

I have modified it; actually, just compare it, and you will see that only sda1 in the example has been changed to sda3. Just 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 press Enter manually. If you see different messages like (find something) near the end, please ensure you did not skip steps that caused 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 excess space in the software package. Open System - Packages, and as shown, the expansion is successful. If you did not succeed in expanding, it is still recommended to delete sda3 and reset the OpenWrt configuration.

image


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 expanding the overlay. 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, select 4.

Since the end sector after expansion (/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; here, choose +10g.

Type w and press Enter to save successfully.

Type 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 to xLog by Mix Space. The original link is https://www.miaoer.net/posts/network/expansion-overlay

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.