This tutorial has been tested on the OpenWrt soft router system compiled by the author, as well as on the OpenWrt soft router system compiled using Lean’s source code. Other non-Lean source code compiled OpenWrt soft router systems have not been tested, hence this note.
1. Open the disk management of the OpenWrt soft router system, and see that the disk size is 16G, with currently unpartitioned space of 15.02G;
2. Open the software package and see that the currently used space is only 661M;
3. Use an SSH tool on your computer (I am using MobaXterm) to log in to OpenWrt’s SSH with the root account. If you see a prompt starting with root@, you are correct;
4. Enter the command to check the disk partition status:
fdisk -l
5. The disk name is /dev/sda (remember this name for later use; it may differ on different machines), the disk size is 16G, and there are currently two partitions: /dev/sda1 and /dev/sda2. The last sector value of the /dev/sda2 partition is 2049023 (remember this value for later use);
6. Enter the command to operate on the disk partition (do not copy /dev/sda; write the name that your disk shows):
fdisk /dev/sda
7. Press n to create a new partition. The system will prompt whether it is primary or extended (if using UEFI firmware, this prompt will not appear). Press p (if using UEFI firmware, this step is not needed), then press 3;
8. The screen will prompt a sector value that needs to be greater than the value shown in step 5. Here it shows 2050048, so just press Enter (if the displayed value is smaller than before, you need to enter a value greater than the one shown in step 5);
9. Enter the value to expand according to your actual situation. The default value is the sector value. Since it is inconvenient to calculate the hard disk size in sector values, you can directly enter the capacity size. Here, the available space is 15.02G, so I enter +14g and press Enter (note: the expansion value entered cannot exceed the actual available space);
10. Enter w and press Enter to confirm saving;
11. Enter the command again to check the disk partition status, and you can see an additional partition /dev/sda3, with a size of 14g:
fdisk -l
12. Enter the command to format the /dev/sda3 partition (do not copy /dev/sda3; write the name that your disk shows):
mkfs.ext4 /dev/sda3
13. Return to the OpenWrt soft router menu, go to the mount point, and add;
14. In the UUID dropdown menu, select the newly created 14g partition;
15. Select “Use as root filesystem (/)” for the mount point;
16. Select all the commands displayed on the screen and copy them;
17. Check the box in “Enabled” and save;
18. Confirm that the 14g mount point has been added, check the enabled box, save and apply;
19. Paste the command copied from step 16 into a text editor, and find /dev/sda1;
20. Change it to the name of the last created partition (here my name is /dev/sda3; do not copy it, write the name that your partition shows), after modification, select all and copy;
21. Paste it into the SSH tool window, press Enter to run;
22. Wait patiently for a while until all commands are executed and return to the state starting with root@, indicating that it is done;
23. Restart the OpenWrt soft router;
24. After the restart, go back to the software package to check, and the available space has changed to 12.85g, indicating successful expansion!