Opening

After we install OpenWrt, the default storage space is very small. If you download the firmware of other big shots, the disk size is usually fixed when compiling the firmware. If you want to run Docker, you will not be able to pull down an image. If you want to make full use of soft routing, you need to expand OpenWrt, Then you can play happily.

explain

The expansion scheme of this tutorial is only tested and passed in the vmware virtual machine. The theory applies to the installation of physical machines. Please consider the reference article by yourself.

step

  1. Check the default available space before capacity expansion. Here, 129.40 MB is left.

     OpenWrt disk expansion scheme and practice

  1. Turn off OpenWrt. It is recommended to take a snapshot of the virtual machine to prevent time wasting due to explosive reinstallation. Then add a disk. I will directly add a 5G hard disk for testing, and then turn on the OpenWrt power supply.
  2. Install the necessary tools.

     Opkg update # Update Opkg install fdisk # The installation tool, if any, does not need to be executed
  3. Execute command fdisk -l , confirm your disk number

     root@OpenWrt :~# fdisk -l Disk /dev/loop0: 214.06 MiB, 224460800 bytes, 438400 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 (1065503 !=  1065534) will be corrected by write. The backup GPT table is corrupt, but the primary appears OK, so that will be used. The backup GPT table is not on the end of the device. Disk /dev/sda: 520.28 MiB, 545553920 bytes, 1065535 sectors Disk model: VMware Virtual S 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: 8E2DA755-0E50-0BD5-63C5-B1DC8E810D00 Device      Start     End Sectors  Size Type /dev/sda1     512   41471   40960   20M Linux filesystem /dev/sda2   41472 1065471 1024000  500M Linux filesystem /dev/sda128    34     511     478  239K BIOS boot Partition table entries are not in disk order. Disk /dev/sdb: 5 GiB, 5368709120 bytes, 10485760 sectors Disk model: VMware Virtual S Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
    You can see the number here /dev/sdb It's the 5G hard disk I just added
  4. use fdisk /dev/sdb Use the default values for all new partitions. Finally, enter w to save the partition table and exit. Follow the prompts.

     root@OpenWrt :~# fdisk /dev/sdb 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. Device does not contain a recognized partition table. Created a new DOS disklabel with disk identifier 0xbd5366e9. Command (m for help): n Partition type p   primary (0 primary, 0 extended, 4 free) e   extended (container for logical partitions) Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-10485759, default 2048):  Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-10485759, default 10485759):  Created a new partition 1 of type 'Linux' and of size 5 GiB. Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
  5. use mkfs.ext4 /dev/sdb The file system formats the partition.

     root@OpenWrt :~# mkfs.ext4 /dev/sdb mke2fs 1.46.5 (30-Dec-2021) Found a dos partition table in /dev/sdb Proceed anyway?  (y,N) y Creating filesystem with 1310720 4k blocks and 327680 inodes Filesystem UUID: 752b4263-c24e-46cb-8e35-7e991898e6f6 Superblock backups stored on blocks:  32768, 98304, 163840, 229376, 294912, 819200, 884736 Allocating group tables: done                             Writing inode tables: done                             Creating journal (16384 blocks): done Writing superblocks and filesystem accounting information: done
  6. Mount the disk after the partition and copy the original files in the/overlay directory to this directory.

     root@OpenWrt :~# mkdir - p/mnt/sdb # Create the mount directory root@OpenWrt :~# mount/dev/sdb/mnt/sdb # # mount root@OpenWrt :~# ls/mnt/sdb # Check whether the mount is successful, as long as there is a lost+found file lost+found root@OpenWrt :~# cp - r/overlay/*/mnt/sdb # # Copy files root@OpenWrt :/mnt/sdb # ls/mnt/sdb # # The following files are just right etc         lost+found  upper       work
  7. Next, go to the background of the OpenWrt system and find the mount point - click the Build Configuration Button, and then pull to the bottom mount point to see the disk we just mounted, and then click Modify.

     OpenWrt disk expansion scheme and practice

  1. Click Modify to enter the following interface, and make sure that enabling this mount point is checked. Select the mount point Use as external overlay , save&Apply, and then restart OpenWrt.

     OpenWrt disk expansion scheme and practice

  2. If the operation is correct, checking the free space again is the space we set.

     OpenWrt disk expansion scheme and practice

extend

Of course, some people will say that if I allocate 10G to the virtual disk, can I use the remaining space to expand? Of course, it is OK. Just select the number of the remaining space when formatting the disk. If you need this scheme, you can see some articles in the reference link at the end of the article.

Reference article

Two Schemes for OpenWrt Storage Space Expansion

OpenWrt Extension Root

Overlay expansion of OpenWrt disks under virtual machine

Soft Route Exploration Journey III: Expand openwrt overlay Updated on March 30

OpenWrt capacity expansion after installation (non overlay)

Article Contents