OpenWrt Disk Expansion Tutorial Supporting Two Modes

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;

OpenWrt Disk Expansion Tutorial Supporting Two Modes

2. Open the software package and see that the currently used space is only 661M;OpenWrt Disk Expansion Tutorial Supporting Two Modes

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;OpenWrt Disk Expansion Tutorial Supporting Two Modes

4. Enter the command to check the disk partition status:

fdisk -l

OpenWrt Disk Expansion Tutorial Supporting Two Modes

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);OpenWrt Disk Expansion Tutorial Supporting Two Modes

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

OpenWrt Disk Expansion Tutorial Supporting Two Modes

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;OpenWrt Disk Expansion Tutorial Supporting Two Modes

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);OpenWrt Disk Expansion Tutorial Supporting Two Modes

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);OpenWrt Disk Expansion Tutorial Supporting Two Modes

10. Enter w and press Enter to confirm saving;OpenWrt Disk Expansion Tutorial Supporting Two Modes

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

OpenWrt Disk Expansion Tutorial Supporting Two Modes

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

OpenWrt Disk Expansion Tutorial Supporting Two Modes

13. Return to the OpenWrt soft router menu, go to the mount point, and add;OpenWrt Disk Expansion Tutorial Supporting Two Modes

14. In the UUID dropdown menu, select the newly created 14g partition;OpenWrt Disk Expansion Tutorial Supporting Two Modes

15. Select “Use as root filesystem (/)” for the mount point;OpenWrt Disk Expansion Tutorial Supporting Two Modes

16. Select all the commands displayed on the screen and copy them;OpenWrt Disk Expansion Tutorial Supporting Two Modes

17. Check the box in “Enabled” and save;OpenWrt Disk Expansion Tutorial Supporting Two Modes

18. Confirm that the 14g mount point has been added, check the enabled box, save and apply;OpenWrt Disk Expansion Tutorial Supporting Two Modes

19. Paste the command copied from step 16 into a text editor, and find /dev/sda1;OpenWrt Disk Expansion Tutorial Supporting Two Modes

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;OpenWrt Disk Expansion Tutorial Supporting Two Modes

21. Paste it into the SSH tool window, press Enter to run;OpenWrt Disk Expansion Tutorial Supporting Two Modes

22. Wait patiently for a while until all commands are executed and return to the state starting with root@, indicating that it is done;OpenWrt Disk Expansion Tutorial Supporting Two Modes

23. Restart the OpenWrt soft router;OpenWrt Disk Expansion Tutorial Supporting Two Modes

24. After the restart, go back to the software package to check, and the available space has changed to 12.85g, indicating successful expansion!OpenWrt Disk Expansion Tutorial Supporting Two Modes

Leave a Comment