banner
miaoer

miaoer

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

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

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.

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.

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).

Here, we are prompted to choose a partition. Since this OpenWrt has not undergone any partitioning operations, we choose 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.

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.

Type w and press Enter to save successfully.

Now that the partition has been successfully created, you can check if the partition was successful with fdisk -l.

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.

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 .

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 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.

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.

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.

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 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).

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

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